Direct-BT v3.3.0-1-gc2d430c
Direct-BT - Direct Bluetooth Programming.
TestVersionNumber.java
Go to the documentation of this file.
1/**
2 * Author: Sven Gothel <sgothel@jausoft.com>
3 * Copyright (c) 2021 Gothel Software e.K.
4 * Copyright (c) 2012 Gothel Software e.K.
5 * Copyright (c) 2012 JogAmp Community.
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining
8 * a copy of this software and associated documentation files (the
9 * "Software"), to deal in the Software without restriction, including
10 * without limitation the rights to use, copy, modify, merge, publish,
11 * distribute, sublicense, and/or sell copies of the Software, and to
12 * permit persons to whom the Software is furnished to do so, subject to
13 * the following conditions:
14 *
15 * The above copyright notice and this permission notice shall be
16 * included in all copies or substantial portions of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 */
26
27package jau.test.util;
28
29import java.io.IOException;
30
31import org.jau.util.VersionNumber;
32import org.junit.Assert;
33import org.junit.FixMethodOrder;
34import org.junit.Test;
35import org.junit.runners.MethodSorters;
36
37import jau.test.junit.util.JunitTracer;
38
39@FixMethodOrder(MethodSorters.NAME_ASCENDING)
40public class TestVersionNumber extends JunitTracer {
41
42 @Test
43 public void test01() {
44 final String vs00 = "1.0.16";
45 final String vs01 = "OpenGL ES GLSL ES 1.0.16";
46 final String vs02 = "1.0.16 OpenGL ES GLSL ES";
47 final VersionNumber vn0 = new VersionNumber(1, 0, 16);
48 Assert.assertTrue(vn0.hasMajor());
49 Assert.assertTrue(vn0.hasMinor());
50 Assert.assertTrue(vn0.hasSub());
51
52 VersionNumber vn;
53
54 vn = new VersionNumber(vs00);
55 Assert.assertTrue(vn.hasMajor());
56 Assert.assertTrue(vn.hasMinor());
57 Assert.assertTrue(vn.hasSub());
58 Assert.assertEquals(vn0, vn);
59
60 vn = new VersionNumber(vs01);
61 Assert.assertTrue(vn.hasMajor());
62 Assert.assertTrue(vn.hasMinor());
63 Assert.assertTrue(vn.hasSub());
64 Assert.assertEquals(vn0, vn);
65
66 vn = new VersionNumber(vs02);
67 Assert.assertTrue(vn.hasMajor());
68 Assert.assertTrue(vn.hasMinor());
69 Assert.assertTrue(vn.hasSub());
70 Assert.assertEquals(vn0, vn);
71 }
72 @Test
73 public void test01b() {
74 final String delim = ",";
75
76 final String vs00 = "1,0,16";
77 final String vs01 = "OpenGL ES GLSL ES 1,0,16";
78 final String vs02 = "1,0,16 OpenGL ES GLSL ES";
79 final VersionNumber vn0 = new VersionNumber(1, 0, 16);
80 Assert.assertTrue(vn0.hasMajor());
81 Assert.assertTrue(vn0.hasMinor());
82 Assert.assertTrue(vn0.hasSub());
83
84 VersionNumber vn;
85
86 vn = new VersionNumber(vs00, delim);
87 Assert.assertTrue(vn.hasMajor());
88 Assert.assertTrue(vn.hasMinor());
89 Assert.assertTrue(vn.hasSub());
90 Assert.assertEquals(vn0, vn);
91
92 vn = new VersionNumber(vs01, delim);
93 Assert.assertTrue(vn.hasMajor());
94 Assert.assertTrue(vn.hasMinor());
95 Assert.assertTrue(vn.hasSub());
96 Assert.assertEquals(vn0, vn);
97
98 vn = new VersionNumber(vs02, delim);
99 Assert.assertTrue(vn.hasMajor());
100 Assert.assertTrue(vn.hasMinor());
101 Assert.assertTrue(vn.hasSub());
102 Assert.assertEquals(vn0, vn);
103 }
104
105 @Test
106 public void test02() {
107 final String vs00 = "4.20";
108 final String vs01 = "COMPANY via Stupid tool 4.20";
109 final String vs02 = "4.20 COMPANY via Stupid tool";
110 final VersionNumber vn0 = new VersionNumber(4, 20, 0);
111 Assert.assertTrue(vn0.hasMajor());
112 Assert.assertTrue(vn0.hasMinor());
113 Assert.assertTrue(vn0.hasSub());
114
115 VersionNumber vn;
116
117 vn = new VersionNumber(vs00);
118 Assert.assertTrue(vn.hasMajor());
119 Assert.assertTrue(vn.hasMinor());
120 Assert.assertTrue(!vn.hasSub());
121 Assert.assertEquals(vn0, vn);
122
123 vn = new VersionNumber(vs01);
124 Assert.assertTrue(vn.hasMajor());
125 Assert.assertTrue(vn.hasMinor());
126 Assert.assertTrue(!vn.hasSub());
127 Assert.assertEquals(vn0, vn);
128
129 vn = new VersionNumber(vs02);
130 Assert.assertTrue(vn.hasMajor());
131 Assert.assertTrue(vn.hasMinor());
132 Assert.assertTrue(!vn.hasSub());
133 Assert.assertEquals(vn0, vn);
134 }
135
136 @Test
137 public void test02b() {
138 final String delim = ",";
139
140 final String vs00 = "4,20";
141 final String vs01 = "COMPANY via Stupid tool 4,20";
142 final String vs02 = "4,20 COMPANY via Stupid tool";
143 final VersionNumber vn0 = new VersionNumber(4, 20, 0);
144 Assert.assertTrue(vn0.hasMajor());
145 Assert.assertTrue(vn0.hasMinor());
146 Assert.assertTrue(vn0.hasSub());
147
148 VersionNumber vn;
149
150 vn = new VersionNumber(vs00, delim);
151 Assert.assertTrue(vn.hasMajor());
152 Assert.assertTrue(vn.hasMinor());
153 Assert.assertTrue(!vn.hasSub());
154 Assert.assertEquals(vn0, vn);
155
156 vn = new VersionNumber(vs01, delim);
157 Assert.assertTrue(vn.hasMajor());
158 Assert.assertTrue(vn.hasMinor());
159 Assert.assertTrue(!vn.hasSub());
160 Assert.assertEquals(vn0, vn);
161
162 vn = new VersionNumber(vs02, delim);
163 Assert.assertTrue(vn.hasMajor());
164 Assert.assertTrue(vn.hasMinor());
165 Assert.assertTrue(!vn.hasSub());
166 Assert.assertEquals(vn0, vn);
167 }
168
169 @Test
170 public void test03() {
171 final String vs00 = "A10.11.12b";
172 final String vs01 = "Prelim Text 10.Funny11.Weird12 Something is odd";
173 final String vs02 = "Prelim Text 10.Funny11l1.Weird12 2 Something is odd";
174 final VersionNumber vn0 = new VersionNumber(10, 11, 12);
175 Assert.assertTrue(vn0.hasMajor());
176 Assert.assertTrue(vn0.hasMinor());
177 Assert.assertTrue(vn0.hasSub());
178
179 VersionNumber vn;
180
181 vn = new VersionNumber(vs00);
182 Assert.assertTrue(vn.hasMajor());
183 Assert.assertTrue(vn.hasMinor());
184 Assert.assertTrue(vn.hasSub());
185 Assert.assertEquals(vn0, vn);
186
187 vn = new VersionNumber(vs01);
188 Assert.assertTrue(vn.hasMajor());
189 Assert.assertTrue(vn.hasMinor());
190 Assert.assertTrue(vn.hasSub());
191 Assert.assertEquals(vn0, vn);
192
193 vn = new VersionNumber(vs02);
194 Assert.assertTrue(vn.hasMajor());
195 Assert.assertTrue(vn.hasMinor());
196 Assert.assertTrue(vn.hasSub());
197 Assert.assertEquals(vn0, vn);
198 }
199
200 @Test
201 public void test03b() {
202 final String delim = ",";
203
204 final String vs00 = "A10,11,12b";
205 final String vs01 = "Prelim Text 10,Funny11,Weird12 Something is odd";
206 final String vs02 = "Prelim Text 10,Funny11l1,Weird12 2 Something is odd";
207 final VersionNumber vn0 = new VersionNumber(10, 11, 12);
208 Assert.assertTrue(vn0.hasMajor());
209 Assert.assertTrue(vn0.hasMinor());
210 Assert.assertTrue(vn0.hasSub());
211
212 VersionNumber vn;
213
214 vn = new VersionNumber(vs00, delim);
215 Assert.assertTrue(vn.hasMajor());
216 Assert.assertTrue(vn.hasMinor());
217 Assert.assertTrue(vn.hasSub());
218 Assert.assertEquals(vn0, vn);
219
220 vn = new VersionNumber(vs01, delim);
221 Assert.assertTrue(vn.hasMajor());
222 Assert.assertTrue(vn.hasMinor());
223 Assert.assertTrue(vn.hasSub());
224 Assert.assertEquals(vn0, vn);
225
226 vn = new VersionNumber(vs02, delim);
227 Assert.assertTrue(vn.hasMajor());
228 Assert.assertTrue(vn.hasMinor());
229 Assert.assertTrue(vn.hasSub());
230 Assert.assertEquals(vn0, vn);
231 }
232
233 @Test
234 public void test04() {
235 final String vs00 = "A10.11.12b (git-d6c318e)";
236 final String vs01 = "Prelim Text 10.Funny11.Weird12 Something is odd (git-d6c318e)";
237 final String vs02 = "Prelim Text 10.Funny11l1.Weird12 2 Something is odd (git-d6c318e)";
238 final VersionNumber vn0 = new VersionNumber(10, 11, 12);
239 Assert.assertTrue(vn0.hasMajor());
240 Assert.assertTrue(vn0.hasMinor());
241 Assert.assertTrue(vn0.hasSub());
242
243 VersionNumber vn;
244
245 vn = new VersionNumber(vs00);
246 Assert.assertTrue(vn.hasMajor());
247 Assert.assertTrue(vn.hasMinor());
248 Assert.assertTrue(vn.hasSub());
249 Assert.assertEquals(vn0, vn);
250
251 vn = new VersionNumber(vs01);
252 Assert.assertTrue(vn.hasMajor());
253 Assert.assertTrue(vn.hasMinor());
254 Assert.assertTrue(vn.hasSub());
255 Assert.assertEquals(vn0, vn);
256
257 vn = new VersionNumber(vs02);
258 Assert.assertTrue(vn.hasMajor());
259 Assert.assertTrue(vn.hasMinor());
260 Assert.assertTrue(vn.hasSub());
261 Assert.assertEquals(vn0, vn);
262 }
263 @Test
264 public void test04b() {
265 final String delim = ",";
266
267 final String vs00 = "A10,11,12b (git-d6c318e)";
268 final String vs01 = "Prelim Text 10,Funny11,Weird12 Something is odd (git-d6c318e)";
269 final String vs02 = "Prelim Text 10,Funny11l1,Weird12 2 Something is odd (git-d6c318e)";
270 final VersionNumber vn0 = new VersionNumber(10, 11, 12);
271 Assert.assertTrue(vn0.hasMajor());
272 Assert.assertTrue(vn0.hasMinor());
273 Assert.assertTrue(vn0.hasSub());
274
275 VersionNumber vn;
276
277 vn = new VersionNumber(vs00, delim);
278 Assert.assertTrue(vn.hasMajor());
279 Assert.assertTrue(vn.hasMinor());
280 Assert.assertTrue(vn.hasSub());
281 Assert.assertEquals(vn0, vn);
282
283 vn = new VersionNumber(vs01, delim);
284 Assert.assertTrue(vn.hasMajor());
285 Assert.assertTrue(vn.hasMinor());
286 Assert.assertTrue(vn.hasSub());
287 Assert.assertEquals(vn0, vn);
288
289 vn = new VersionNumber(vs02, delim);
290 Assert.assertTrue(vn.hasMajor());
291 Assert.assertTrue(vn.hasMinor());
292 Assert.assertTrue(vn.hasSub());
293 Assert.assertEquals(vn0, vn);
294 }
295
296 public static void main(final String args[]) throws IOException {
297 final String tstname = TestVersionNumber.class.getName();
298 org.junit.runner.JUnitCore.main(tstname);
299 }
300
301}
static void main(final String args[])