On 04/25/2015 08:41 PM, Thomas Faber wrote:
> + /* class name with buffer one char too small */
> + memset(classbuffer, 0x55, sizeof(classbuffer));
> + classlen = sizeof(subkey_class) - 1;
> + ret = RegQueryInfoKeyA(subkey, classbuffer, &classlen, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
> + ok(ret == ERROR_MORE_DATA, "ret = %d\n", ret);
> + todo_wine ok(classlen == sizeof(subkey_class) - 2, "classlen = %u\n", classlen);
> + todo_wine ok(classbuffer[0] == 's', "classbuffer[0] = 0x%x\n", classbuffer[0]);
> + todo_wine ok(classbuffer[1] == 'u', "classbuffer[1] = 0x%x\n", classbuffer[1]);
> + todo_wine ok(classbuffer[10] == 's', "classbuffer[10] = 0x%x\n", classbuffer[10]);
> + todo_wine ok(classbuffer[11] == 0, "classbuffer[11] = 0x%x\n", classbuffer[11]);
> + ok(classbuffer[12] == 0x55, "classbuffer[12] = 0x%x\n", classbuffer[12]);
I think it would be more readable if you tested it against a string.
Also hardcoded offsets could be avoided in this case.
> + memset(classbufferW, 0x55, sizeof(classbufferW));
> + classlen = sizeof(subkey_class) - 1;
> + ret = RegQueryInfoKeyW(subkey, classbufferW, &classlen, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
> + todo_wine ok(ret == ERROR_INSUFFICIENT_BUFFER, "ret = %d\n", ret);
> + ok(classlen == sizeof(subkey_class) - 2 /* win8 */ ||
> + classlen == strlen(subkey_class), "classlen = %u\n", classlen);
> + ok(classbufferW[0] == 0x5555, "classbufferW[0] = 0x%x\n", classbufferW[0]);
> + ok(classbufferW[1] == 0x5555, "classbufferW[1] = 0x%x\n", classbufferW[1]);
> + ok(classbufferW[10] == 0x5555, "classbufferW[10] = 0x%x\n", classbufferW[10]);
> + ok(classbufferW[11] == 0x5555, "classbufferW[11] = 0x%x\n", classbufferW[11]);
> + ok(classbufferW[12] == 0x5555, "classbufferW[12] = 0x%x\n", classbufferW[12]);
If first element is not changed, it's really unlikely that anything else
did.
> + ok(classbuffer[12] == 0, "classbuffer[12] = 0x%x\n", classbuffer[12]);
> + ok(classbuffer[13] == 0x55, "classbuffer[13] = 0x%x\n", classbuffer[13]);
...
> + ok(!lstrcmpW(classbufferW, subkey_classW), "classbufferW = %s\n", wine_dbgstr_w(classbufferW));
> + ok(classbufferW[12] == 0, "classbufferW[12] = 0x%x\n", classbufferW[12]);
> + ok(classbufferW[13] == 0x5555, "classbufferW[13] = 0x%x\n", classbufferW[13]);
Could you replace offsets with calculated string length instead so it
still works for different strings.