2 * Unit test suite for version functions
4 * Copyright 2006 Robert Shearman
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include "wine/test.h"
26 OSVERSIONINFOEX info = { sizeof(info) };
29 ret = VerifyVersionInfo(&info, VER_MAJORVERSION | VER_MINORVERSION,
30 VerSetConditionMask(0, VER_MAJORVERSION, VER_GREATER_EQUAL));
31 todo_wine ok(ret, "VerifyVersionInfo failed with error %ld\n", GetLastError());
33 ret = VerifyVersionInfo(&info, VER_BUILDNUMBER | VER_MAJORVERSION |
34 VER_MINORVERSION/* | VER_PLATFORMID | VER_SERVICEPACKMAJOR |
35 VER_SERVICEPACKMINOR | VER_SUITENAME | VER_PRODUCT_TYPE */,
36 VerSetConditionMask(0, VER_MAJORVERSION, VER_GREATER_EQUAL));
37 todo_wine ok(!ret && (GetLastError() == ERROR_OLD_WIN_VERSION),
38 "VerifyVersionInfo should have failed with ERROR_OLD_WIN_VERSION instead of %ld\n", GetLastError());
40 /* tests special handling of VER_SUITENAME */
42 ret = VerifyVersionInfo(&info, VER_SUITENAME,
43 VerSetConditionMask(0, VER_SUITENAME, VER_AND));
44 ok(ret, "VerifyVersionInfo failed with error %ld\n", GetLastError());
46 ret = VerifyVersionInfo(&info, VER_SUITENAME,
47 VerSetConditionMask(0, VER_SUITENAME, VER_OR));
48 ok(ret, "VerifyVersionInfo failed with error %ld\n", GetLastError());
50 /* test handling of version numbers */
52 /* v3.10 is always less than v4.x even
53 * if the minor version is tested */
54 info.dwMajorVersion = 3;
55 info.dwMinorVersion = 10;
56 ret = VerifyVersionInfo(&info, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
57 VerSetConditionMask(VerSetConditionMask(0, VER_MINORVERSION, VER_GREATER_EQUAL),
58 VER_MAJORVERSION, VER_GREATER_EQUAL));
59 todo_wine ok(ret, "VerifyVersionInfo failed with error %ld\n", GetLastError());
61 info.dwMinorVersion = 0;
62 info.wServicePackMajor = 10;
63 ret = VerifyVersionInfo(&info, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
64 VerSetConditionMask(VerSetConditionMask(0, VER_MINORVERSION, VER_GREATER_EQUAL),
65 VER_MAJORVERSION, VER_GREATER_EQUAL));
66 todo_wine ok(ret, "VerifyVersionInfo failed with error %ld\n", GetLastError());
68 info.wServicePackMajor = 0;
69 info.wServicePackMinor = 10;
70 ret = VerifyVersionInfo(&info, VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
71 VerSetConditionMask(VerSetConditionMask(0, VER_MINORVERSION, VER_GREATER_EQUAL),
72 VER_MAJORVERSION, VER_GREATER_EQUAL));
73 todo_wine ok(ret, "VerifyVersionInfo failed with error %ld\n", GetLastError());
75 GetVersionEx((OSVERSIONINFO *)&info);
76 info.wServicePackMinor++;
77 ret = VerifyVersionInfo(&info, VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
78 VerSetConditionMask(0, VER_MINORVERSION, VER_GREATER_EQUAL));
79 todo_wine ok(!ret && (GetLastError() == ERROR_OLD_WIN_VERSION),
80 "VerifyVersionInfo should have failed with ERROR_OLD_WIN_VERSION instead of %ld\n", GetLastError());
82 /* test the failure hierarchy for the four version fields */
84 GetVersionEx((OSVERSIONINFO *)&info);
85 info.wServicePackMajor++;
86 ret = VerifyVersionInfo(&info, VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
87 VerSetConditionMask(0, VER_MINORVERSION, VER_GREATER_EQUAL));
88 todo_wine ok(!ret && (GetLastError() == ERROR_OLD_WIN_VERSION),
89 "VerifyVersionInfo should have failed with ERROR_OLD_WIN_VERSION instead of %ld\n", GetLastError());
91 GetVersionEx((OSVERSIONINFO *)&info);
92 info.dwMinorVersion++;
93 ret = VerifyVersionInfo(&info, VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
94 VerSetConditionMask(0, VER_MINORVERSION, VER_GREATER_EQUAL));
95 ok(!ret && (GetLastError() == ERROR_OLD_WIN_VERSION),
96 "VerifyVersionInfo should have failed with ERROR_OLD_WIN_VERSION instead of %ld\n", GetLastError());
98 GetVersionEx((OSVERSIONINFO *)&info);
99 info.dwMajorVersion++;
100 ret = VerifyVersionInfo(&info, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
101 VerSetConditionMask(0, VER_MINORVERSION, VER_GREATER_EQUAL));
102 todo_wine ok(!ret && (GetLastError() == ERROR_OLD_WIN_VERSION),
103 "VerifyVersionInfo should have failed with ERROR_OLD_WIN_VERSION instead of %ld\n", GetLastError());
105 ret = VerifyVersionInfo(&info, VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
106 VerSetConditionMask(0, VER_MINORVERSION, VER_GREATER_EQUAL));
107 todo_wine ok(ret, "VerifyVersionInfo failed with error %ld\n", GetLastError());
110 /* shows that build number fits into the hierarchy after major version, but before minor version */
111 GetVersionEx((OSVERSIONINFO *)&info);
112 info.dwBuildNumber++;
113 ret = VerifyVersionInfo(&info, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
114 VerSetConditionMask(0, VER_MINORVERSION, VER_GREATER_EQUAL));
115 todo_wine ok(!ret && (GetLastError() == ERROR_OLD_WIN_VERSION),
116 "VerifyVersionInfo should have failed with ERROR_OLD_WIN_VERSION instead of %ld\n", GetLastError());
118 ret = VerifyVersionInfo(&info, VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
119 VerSetConditionMask(0, VER_MINORVERSION, VER_GREATER_EQUAL));
120 todo_wine ok(ret, "VerifyVersionInfo failed with error %ld\n", GetLastError());
122 /* test bad dwOSVersionInfoSize */
123 GetVersionEx((OSVERSIONINFO *)&info);
124 info.dwOSVersionInfoSize = 0;
125 ret = VerifyVersionInfo(&info, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR,
126 VerSetConditionMask(0, VER_MINORVERSION, VER_GREATER_EQUAL));
127 todo_wine ok(!ret && (GetLastError() == ERROR_OLD_WIN_VERSION),
128 "VerifyVersionInfo should have failed with ERROR_OLD_WIN_VERSION instead of %ld\n", GetLastError());