advapi32: Test RegSetValueEx[AW]() for adding some sequential
strings as one.
wine-devel at winehq.org
wine-devel at winehq.org
Fri Jun 2 13:46:44 CDT 2006
Here I used some term of "Intra-zeroed String", as haven't came up with anything more appropriate.
9x truncates intrazeroed string at a first zero occurrence. Still I haven't tested wheather it does so on a write or read operation. NT stores all the intrazeroed string in a registry.
I am sorry for a such big macro. :-(
---
dlls/advapi32/tests/registry.c | 85 ++++++++++++++++++++++++++++++++++++++++
1 files changed, 85 insertions(+), 0 deletions(-)
2819d8b939da499b2753259fc1959c393f2a8a05
diff --git a/dlls/advapi32/tests/registry.c b/dlls/advapi32/tests/registry.c
index 2c079d2..185e893 100644
--- a/dlls/advapi32/tests/registry.c
+++ b/dlls/advapi32/tests/registry.c
@@ -60,6 +60,90 @@ static void setup_main_key(void)
assert (!RegCreateKeyA( HKEY_CURRENT_USER, "Software\\Wine\\Test", &hkey_main ));
}
+#define test_hkey_main_Value(name, is_intrazeroed_string, AW) \
+do { \
+ SetLastError(0xfaceabee); \
+ ret = RegQueryValueEx##AW(hkey_main, name##AW, NULL, &type, NULL, &cbData); \
+ GLE = GetLastError(); \
+ ok(ret == ERROR_SUCCESS && (GLE == 0xfaceabee || GLE == ERROR_CALL_NOT_IMPLEMENTED), \
+ "RegQueryValueEx%s failed: %ld, GLE=%ld\n", #AW, ret, GLE); \
+ win9x = (win9x)?(TRUE):(GLE == ERROR_CALL_NOT_IMPLEMENTED); \
+ if(GLE == ERROR_CALL_NOT_IMPLEMENTED) break; \
+ \
+ str_byte_len = (lstrlen##AW(is_intrazeroed_string##AW) + 1) * \
+ sizeof(is_intrazeroed_string##AW[0]); \
+ ok(type == REG_SZ, "RegQueryValueEx%s returned type %ld\n", #AW, type); \
+ \
+ if(win9x && is_intrazeroed_string) { \
+ /* 9x truncates intrazeroed strings to the first zero */ \
+ /* though still unknown wheather it does so on read or write op */ \
+ ok(cbData < sizeof(is_intrazeroed_string##AW), "cbData=%ld must be < than %d\n", \
+ cbData, sizeof(is_intrazeroed_string##AW)); \
+ ok(cbData == str_byte_len, "cbData=%ld instead of (6) %ld\n", \
+ cbData, str_byte_len); \
+ break; \
+ } \
+ ok(cbData == sizeof(is_intrazeroed_string##AW), \
+ "cbData=%ld instead of %d\n", cbData, sizeof(is_intrazeroed_string##AW)); \
+ if(is_intrazeroed_string) \
+ ok(cbData > str_byte_len, "cbData=%ld must be > than %ld\n", cbData, str_byte_len); \
+ else \
+ ok(cbData == str_byte_len, "cbData=%ld instead of %ld\n", cbData, str_byte_len); \
+} while (0)
+
+static void test_set_value(void)
+{
+ int win9x=FALSE;
+ DWORD ret, GLE=0;
+ DWORD type, cbData, str_byte_len;
+
+ WCHAR name1W[] = {'C','l','e','a','n','S','i','n','g','l','e','S','t','r','i','n','g', 0};
+ WCHAR name2W[] = {'S','o','m','e','I','n','t','r','a','Z','e','r','o','e','d','S','t','r','i','n','g', 0};
+ WCHAR string1W[] = {'T','h','i','s','N','e','v','e','r','B','r','e','a','k','s', 0};
+ WCHAR string2W[] = {'T','h','i','s', 0 ,'B','r','e','a','k','s', 0 , 0 ,'A', 0 , 0 , 0 , 0 ,'L','o','t', 0 , 0 , 0 , 0 , 0};
+
+ char name1A[] = "CleanSingleString";
+ char name2A[] = "SomeIntraZeroedString";
+ char string1A[] = "ThisNeverBreaks";
+ char string2A[] = "This\0Breaks\0\0A\0\0\0Lot\0\0\0\0\0";
+
+#define A
+#define W
+#define string1 FALSE // normal string
+#define string2 TRUE // intrazeroed string
+
+ /* test RegSetValueExA with normal string */
+ ret = RegSetValueExA(hkey_main, name1A, 0, REG_SZ, (LPBYTE)string1A, sizeof(string1A));
+ ok(ret == ERROR_SUCCESS, "RegSetValueExA failed: %ld, GLE=%ld\n", ret, GetLastError());
+ test_hkey_main_Value(name1, string1, A);
+ test_hkey_main_Value(name1, string1, W);
+
+ /* test RegSetValueExA with intrazeroed string */
+ ret = RegSetValueExA(hkey_main, name2A, 0, REG_SZ, (LPBYTE)string2A, sizeof(string2A));
+ ok(ret == ERROR_SUCCESS, "RegSetValueExA failed: %ld, GLE=%ld\n", ret, GetLastError());
+ test_hkey_main_Value(name2, string2, A);
+ test_hkey_main_Value(name2, string2, W);
+
+ if(win9x) return;
+
+ /* test RegSetValueExW with normal string */
+ ret = RegSetValueExW(hkey_main, name1W, 0, REG_SZ, (LPBYTE)string1W, sizeof(string1W));
+ ok(ret == ERROR_SUCCESS, "RegSetValueExW failed: %ld, GLE=%ld\n", ret, GetLastError());
+ test_hkey_main_Value(name1, string1, A);
+ test_hkey_main_Value(name1, string1, W);
+
+ /* test RegSetValueExW with intrazeroed string */
+ ret = RegSetValueExW(hkey_main, name2W, 0, REG_SZ, (LPBYTE)string2W, sizeof(string2W));
+ ok(ret == ERROR_SUCCESS, "RegSetValueExW failed: %ld, GLE=%ld\n", ret, GetLastError());
+ test_hkey_main_Value(name2, string2, A);
+ test_hkey_main_Value(name2, string2, W);
+
+#undef string1
+#undef string2
+#undef A
+#undef W
+}
+
static void create_test_entries(void)
{
DWORD qw[2] = { 0x12345678, 0x87654321 };
@@ -656,6 +740,7 @@ static void test_regconnectregistry( voi
START_TEST(registry)
{
setup_main_key();
+ test_set_value();
create_test_entries();
test_enum_value();
test_query_value_ex();
--
1.0.4
More information about the wine-patches
mailing list