2 * Copyright 2019 Józef Kucia for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #include "vkd3d_common.h"
20 #include "vkd3d_test.h"
22 static void check_version(const char *v
, int expected_major
, int expected_minor
)
26 vkd3d_parse_version(v
, &major
, &minor
);
27 ok(major
== expected_major
&& minor
== expected_minor
,
28 "Got %d.%d, expected %d.%d for %s.\n",
29 major
, minor
, expected_major
, expected_minor
, v
);
32 static void test_parse_version(void)
34 check_version("", 0, 0);
35 check_version(".3", 0, 3);
36 check_version(".4.5", 0, 4);
38 check_version("1", 1, 0);
39 check_version("2", 2, 0);
41 check_version("1.0", 1, 0);
42 check_version("1.1", 1, 1);
43 check_version("2.3.0", 2, 3);
46 static void check_contiguous(uint32_t mask
, bool expected_result
)
48 bool r
= vkd3d_bitmask_is_contiguous(mask
);
49 ok(r
== expected_result
, "Got %#x for bitmask %#"PRIx32
".\n", r
, mask
);
52 static void test_bitmask_is_contiguous(void)
54 check_contiguous(0x00000000, true);
56 check_contiguous(0x00000001, true);
57 check_contiguous(0x00000002, true);
58 check_contiguous(0x00000003, true);
59 check_contiguous(0x00000004, true);
60 check_contiguous(0x00000005, false);
61 check_contiguous(0x00000006, true);
62 check_contiguous(0x00000007, true);
63 check_contiguous(0x00000008, true);
64 check_contiguous(0x00000009, false);
65 check_contiguous(0x0000000a, false);
66 check_contiguous(0x0000000b, false);
67 check_contiguous(0x0000000c, true);
68 check_contiguous(0x0000000d, false);
69 check_contiguous(0x0000000e, true);
70 check_contiguous(0x0000000f, true);
72 check_contiguous(0x10000000, true);
73 check_contiguous(0x20000000, true);
74 check_contiguous(0x30000000, true);
75 check_contiguous(0x40000000, true);
76 check_contiguous(0x50000000, false);
77 check_contiguous(0x60000000, true);
78 check_contiguous(0x70000000, true);
79 check_contiguous(0x80000000, true);
80 check_contiguous(0x90000000, false);
81 check_contiguous(0xa0000000, false);
82 check_contiguous(0xb0000000, false);
83 check_contiguous(0xc0000000, true);
84 check_contiguous(0xd0000000, false);
85 check_contiguous(0xe0000000, true);
86 check_contiguous(0xf0000000, true);
88 check_contiguous(0xf000000f, false);
89 check_contiguous(0x0f0000f0, false);
90 check_contiguous(0x00f00f00, false);
92 check_contiguous(0x000000ff, true);
93 check_contiguous(0x00000ff0, true);
94 check_contiguous(0x0000ff00, true);
95 check_contiguous(0x000ff000, true);
96 check_contiguous(0x00ff0000, true);
97 check_contiguous(0xff000000, true);
99 check_contiguous(0xfff00000, true);
100 check_contiguous(0xffff0000, true);
101 check_contiguous(0xffff0000, true);
102 check_contiguous(0xfffff000, true);
103 check_contiguous(0xffffff00, true);
104 check_contiguous(0xfffffff0, true);
105 check_contiguous(0xffffffff, true);
107 check_contiguous(0x0000001c, true);
108 check_contiguous(0x000001c0, true);
109 check_contiguous(0x00001c00, true);
110 check_contiguous(0x0001c000, true);
111 check_contiguous(0x001c0000, true);
112 check_contiguous(0x01c00000, true);
113 check_contiguous(0x1c000000, true);
116 START_TEST(vkd3d_common
)
118 run_test(test_parse_version
);
119 run_test(test_bitmask_is_contiguous
);