1 module dud.semver.checktest;
2 
3 @safe pure private:
4 import std.exception : assertThrown, assertNotThrown;
5 import std.stdio;
6 import std.format : format;
7 
8 import dud.semver.checks;
9 import dud.semver.parse;
10 import dud.semver.semver;
11 import dud.semver.versionrange;
12 import dud.semver.versionunion;
13 import dud.semver.exception;
14 
15 import dud.semver.testdata;
16 
17 unittest { // VersionUnion, VersionUnion
18 	assert( allowsAny(vu1, vu1));
19 	assert( allowsAny(vu1, vu2));
20 	assert( allowsAny(vu1, vu3));
21 	assert( allowsAny(vu1, vu4));
22 	assert( allowsAny(vu1, vu5));
23 
24 	assert( allowsAny(vu2, vu1));
25 	assert( allowsAny(vu2, vu2));
26 	assert( allowsAny(vu2, vu3));
27 	assert( allowsAny(vu2, vu4));
28 	assert( allowsAny(vu2, vu5));
29 
30 	assert( allowsAny(vu3, vu1));
31 	assert( allowsAny(vu3, vu2));
32 	assert( allowsAny(vu3, vu3));
33 	assert( allowsAny(vu3, vu4));
34 	assert( allowsAny(vu3, vu5));
35 
36 	assert( allowsAny(vu4, vu1));
37 	assert( allowsAny(vu4, vu2));
38 	assert( allowsAny(vu4, vu3));
39 	assert( allowsAny(vu4, vu4));
40 	assert(!allowsAny(vu4, vu5));
41 
42 	assert( allowsAny(vu5, vu1));
43 	assert( allowsAny(vu5, vu2));
44 	assert( allowsAny(vu5, vu3));
45 	assert(!allowsAny(vu5, vu4));
46 	assert( allowsAny(vu5, vu5));
47 }
48 
49 unittest { // VersionUnion, VersionRange
50 	assert( allowsAny(vu1, vr1));
51 	assert( allowsAny(vu1, vr2));
52 	assert( allowsAny(vu1, vr3));
53 	assert( allowsAny(vu1, vr4));
54 	assert(!allowsAny(vu1, vr5));
55 
56 	assert( allowsAny(vu2, vr1));
57 	assert( allowsAny(vu2, vr2));
58 	assert( allowsAny(vu2, vr3));
59 	assert( allowsAny(vu2, vr4));
60 	assert(!allowsAny(vu2, vr5));
61 
62 	assert( allowsAny(vu3, vr1));
63 	assert( allowsAny(vu3, vr2));
64 	assert( allowsAny(vu3, vr3));
65 	assert( allowsAny(vu3, vr4));
66 	assert(!allowsAny(vu3, vr5));
67 
68 	assert(!allowsAny(vu4, vr1));
69 	assert( allowsAny(vu4, vr2));
70 	assert( allowsAny(vu4, vr3));
71 	assert( allowsAny(vu4, vr4));
72 	assert(!allowsAny(vu4, vr5));
73 
74 	assert( allowsAny(vu5, vr1));
75 	assert(!allowsAny(vu5, vr2));
76 	assert( allowsAny(vu5, vr3));
77 	assert(!allowsAny(vu5, vr4));
78 	assert( allowsAny(vu5, vr5));
79 }
80 
81 unittest { // VersionUnion, SemVer
82 	assert(!allowsAny(vu1, v1));
83 	assert( allowsAny(vu1, v2));
84 	assert(!allowsAny(vu1, v3));
85 	assert(!allowsAny(vu1, v4));
86 
87 	assert(!allowsAny(vu2, v1));
88 	assert( allowsAny(vu2, v2));
89 	assert(!allowsAny(vu2, v3));
90 	assert( allowsAny(vu2, v4));
91 
92 	assert(!allowsAny(vu3, v1));
93 	assert(!allowsAny(vu3, v2));
94 	assert( allowsAny(vu3, v3));
95 	assert( allowsAny(vu3, v4));
96 
97 	assert(!allowsAny(vu4, v1));
98 	assert(!allowsAny(vu4, v2));
99 	assert(!allowsAny(vu4, v3));
100 	assert( allowsAny(vu4, v4));
101 
102 	assert(!allowsAny(vu5, v1));
103 	assert( allowsAny(vu5, v2));
104 	assert(!allowsAny(vu5, v3));
105 	assert(!allowsAny(vu5, v4));
106 }
107 
108 unittest { // VersionRange, VersionUnion
109 	assert( allowsAny(vr1, vu1));
110 	assert( allowsAny(vr1, vu2));
111 	assert( allowsAny(vr1, vu3));
112 	assert(!allowsAny(vr1, vu4));
113 	assert( allowsAny(vr1, vu5));
114 
115 	assert( allowsAny(vr2, vu1));
116 	assert( allowsAny(vr2, vu2));
117 	assert( allowsAny(vr2, vu3));
118 	assert( allowsAny(vr2, vu4));
119 	assert(!allowsAny(vr2, vu5));
120 
121 	assert( allowsAny(vr3, vu1));
122 	assert( allowsAny(vr3, vu2));
123 	assert( allowsAny(vr3, vu3));
124 	assert( allowsAny(vr3, vu4));
125 	assert( allowsAny(vr3, vu5));
126 
127 	assert( allowsAny(vr4, vu1));
128 	assert( allowsAny(vr4, vu2));
129 	assert( allowsAny(vr4, vu3));
130 	assert( allowsAny(vr4, vu4));
131 	assert(!allowsAny(vr4, vu5));
132 
133 	assert(!allowsAny(vr5, vu1));
134 	assert(!allowsAny(vr5, vu2));
135 	assert(!allowsAny(vr5, vu3));
136 	assert(!allowsAny(vr5, vu4));
137 	assert( allowsAny(vr5, vu5));
138 }
139 
140 unittest { // VersionRange, VersionRange
141 	assert( allowsAny(vr1, vr1));
142 	assert(!allowsAny(vr1, vr2));
143 	assert( allowsAny(vr1, vr3));
144 	assert(!allowsAny(vr1, vr4));
145 	assert(!allowsAny(vr1, vr5));
146 
147 	assert(!allowsAny(vr2, vr1));
148 	assert( allowsAny(vr2, vr2));
149 	assert( allowsAny(vr2, vr3));
150 	assert( allowsAny(vr2, vr4));
151 	assert(!allowsAny(vr2, vr5));
152 
153 	assert( allowsAny(vr3, vr1));
154 	assert( allowsAny(vr3, vr2));
155 	assert( allowsAny(vr3, vr3));
156 	assert( allowsAny(vr3, vr4));
157 	assert(!allowsAny(vr3, vr5));
158 
159 	assert(!allowsAny(vr4, vr1));
160 	assert( allowsAny(vr4, vr2));
161 	assert( allowsAny(vr4, vr3));
162 	assert( allowsAny(vr4, vr4));
163 	assert(!allowsAny(vr4, vr5));
164 
165 	assert(!allowsAny(vr5, vr1));
166 	assert(!allowsAny(vr5, vr2));
167 	assert(!allowsAny(vr5, vr3));
168 	assert(!allowsAny(vr5, vr4));
169 	assert( allowsAny(vr5, vr5));
170 }
171 
172 unittest { // VersionRange, SemVer
173 	assert(!allowsAny(vr1, v1));
174 	assert( allowsAny(vr1, v2));
175 	assert(!allowsAny(vr1, v3));
176 	assert(!allowsAny(vr1, v4));
177 
178 	assert(!allowsAny(vr2, v1));
179 	assert(!allowsAny(vr2, v2));
180 	assert(!allowsAny(vr2, v3));
181 	assert( allowsAny(vr2, v4));
182 
183 	assert(!allowsAny(vr3, v1));
184 	assert(!allowsAny(vr3, v2));
185 	assert( allowsAny(vr3, v3));
186 	assert( allowsAny(vr3, v4));
187 
188 	assert(!allowsAny(vr4, v1));
189 	assert(!allowsAny(vr4, v2));
190 	assert(!allowsAny(vr4, v3));
191 	assert(!allowsAny(vr4, v4));
192 
193 	assert(!allowsAny(vr5, v1));
194 	assert(!allowsAny(vr5, v2));
195 	assert(!allowsAny(vr5, v3));
196 	assert(!allowsAny(vr5, v4));
197 }