2 * PROJECT: ReactOS api tests
3 * LICENSE: GPLv2+ - See COPYING in the top level directory
4 * PURPOSE: Tests for GetVolumeInformation
5 * PROGRAMMER: Pierre Schweitzer <pierre@reactos.org>
11 TestGetVolumeInformationA(VOID
)
14 CHAR Outbuf
[MAX_PATH
];
15 DWORD i
, MCL
, Flags
, Len
;
17 memset(Outbuf
, 0xAA, MAX_PATH
);
18 Ret
= GetVolumeInformationA("C:\\", NULL
, 0, NULL
, &MCL
, &Flags
, Outbuf
, MAX_PATH
);
19 ok(Ret
!= FALSE
, "GetVolumeInformationA failed: %ld\n", GetLastError());
20 for (i
= 0; i
< MAX_PATH
; ++i
)
27 ok(i
!= MAX_PATH
, "String was not null terminated!\n");
29 memset(Outbuf
, 0xAA, MAX_PATH
);
31 Ret
= GetVolumeInformationA("C:\\", NULL
, 0, NULL
, &MCL
, &Flags
, Outbuf
, Len
+ 1);
32 ok(Ret
!= FALSE
, "GetVolumeInformationA failed: %ld\n", GetLastError());
33 for (i
= 0; i
< MAX_PATH
; ++i
)
40 ok(i
!= MAX_PATH
, "String was not null terminated!\n");
41 ok(i
== Len
, "String was truncated\n");
43 memset(Outbuf
, 0xAA, MAX_PATH
);
45 SetLastError(0xdeadbeef);
46 Ret
= GetVolumeInformationA("C:\\", NULL
, 0, NULL
, &MCL
, &Flags
, Outbuf
, Len
);
47 ok(Ret
!= TRUE
, "GetVolumeInformationA succeed\n");
48 ok(GetLastError() == ERROR_BAD_LENGTH
, "Expected ERROR_BAD_LENGTH error, got %ld\n", GetLastError());
49 ok(Outbuf
[0] != 0xAA, "Output buffer was not written to\n");
50 for (i
= 0; i
< MAX_PATH
; ++i
)
57 ok(i
== MAX_PATH
, "String was null terminated!\n");
58 for (i
= 0; i
< MAX_PATH
; ++i
)
60 if (Outbuf
[i
] != 0xAA)
65 ok(i
!= MAX_PATH
, "String was not written to!\n");
66 ok(i
< Len
, "Buffer has been overruned\n");
70 TestGetVolumeInformationW(VOID
)
73 WCHAR Outbuf
[MAX_PATH
];
74 DWORD i
, MCL
, Flags
, Len
;
76 memset(Outbuf
, 0xAA, sizeof(Outbuf
));
77 Ret
= GetVolumeInformationW(L
"C:\\", NULL
, 0, NULL
, &MCL
, &Flags
, Outbuf
, MAX_PATH
);
78 ok(Ret
!= FALSE
, "GetVolumeInformationW failed: %ld\n", GetLastError());
79 for (i
= 0; i
< MAX_PATH
; ++i
)
86 ok(i
!= MAX_PATH
, "String was not null terminated!\n");
88 memset(Outbuf
, 0xAA, sizeof(Outbuf
));
90 Ret
= GetVolumeInformationW(L
"C:\\", NULL
, 0, NULL
, &MCL
, &Flags
, Outbuf
, Len
+ 1);
91 ok(Ret
!= FALSE
, "GetVolumeInformationW failed: %ld\n", GetLastError());
92 for (i
= 0; i
< MAX_PATH
; ++i
)
99 ok(i
!= MAX_PATH
, "String was not null terminated!\n");
100 ok(i
== Len
, "String was truncated\n");
102 memset(Outbuf
, 0xAA, sizeof(Outbuf
));
104 SetLastError(0xdeadbeef);
105 Ret
= GetVolumeInformationW(L
"C:\\", NULL
, 0, NULL
, &MCL
, &Flags
, Outbuf
, Len
);
106 ok(Ret
!= TRUE
, "GetVolumeInformationW succeed\n");
107 ok(GetLastError() == ERROR_BAD_LENGTH
, "Expected ERROR_BAD_LENGTH error, got %ld\n", GetLastError());
108 ok(Outbuf
[0] != 0xAA, "Output buffer was not written to\n");
109 for (i
= 0; i
< MAX_PATH
; ++i
)
116 ok(i
== MAX_PATH
, "String was null terminated!\n");
117 ok(i
>= Len
, "Buffer has not been overrun\n");
120 START_TEST(GetVolumeInformation
)
122 TestGetVolumeInformationW();
123 TestGetVolumeInformationA();