Commit 776c633a 776c633a789778b8c6fd20db0c400b618904fbb8 by Nicolas Perriault

added tests for version comparison utils

1 parent 99463643
...@@ -306,4 +306,63 @@ t.comment('unique()'); ...@@ -306,4 +306,63 @@ t.comment('unique()');
306 }); 306 });
307 })(); 307 })();
308 308
309 t.done(112); 309 t.comment('cmpVersion() tests');
310 (function() {
311 t.assertEquals(utils.cmpVersion('1.0.0', '2.0.0'), -1,
312 'cmpVersion() can compare version strings');
313 t.assertEquals(utils.cmpVersion('1.0.0-DEV', '2.0.0-BOOM'), -1,
314 'cmpVersion() can compare version strings');
315 t.assertEquals(utils.cmpVersion('1.0.0', '1.1.0'), -1,
316 'cmpVersion() can compare version strings');
317 t.assertEquals(utils.cmpVersion('1.1.0', '1.0.0'), 1,
318 'cmpVersion() can compare version strings');
319 t.assertEquals(utils.cmpVersion('0.0.3', '0.0.4'), -1,
320 'cmpVersion() can compare version strings');
321 t.assertEquals(utils.cmpVersion('0.0.3', '1.0.3'), -1,
322 'cmpVersion() can compare version strings');
323 t.assertEquals(utils.cmpVersion('0.1', '1.0.3.8'), -1,
324 'cmpVersion() can compare version strings');
325 t.assertEquals(utils.cmpVersion({major: 1, minor: 2, patch: 3},
326 {major: 1, minor: 2, patch: 4}), -1,
327 'cmpVersion() can compare version objects');
328 t.assertEquals(utils.cmpVersion({major: 2, minor: 0, patch: 3},
329 {major: 1, minor: 0, patch: 4}), 1,
330 'cmpVersion() can compare version objects');
331 t.assertEquals(utils.cmpVersion({major: 0, minor: 0, patch: 3},
332 {major: 1, minor: 0, patch: 3}), -1,
333 'cmpVersion() can compare version objects');
334 t.done();
335 })();
336
337 t.comment('gteVersion() tests');
338 (function() {
339 t.assert(utils.gteVersion('1.1.0', '1.0.0'),
340 'gteVersion() checks for a greater or equal version');
341 t.assertNot(utils.gteVersion('1.0.0', '1.1.0'),
342 'gteVersion() checks for a greater or equal version');
343 t.assert(utils.gteVersion({major: 1, minor: 1, patch: 0},
344 {major: 1, minor: 0, patch: 0}),
345 'gteVersion() checks for a greater or equal version');
346 t.assertNot(utils.gteVersion({major: 1, minor: 0, patch: 0},
347 {major: 1, minor: 1, patch: 0}),
348 'gteVersion() checks for a greater or equal version');
349 t.done();
350 })();
351
352 t.comment('ltVersion() tests');
353 (function() {
354 t.assert(utils.ltVersion('1.0.0', '1.1.0'),
355 'ltVersion() checks for a lesser version');
356 t.assertNot(utils.ltVersion('1.1.0', '1.0.0'),
357 'ltVersion() checks for a lesser version');
358 t.assert(utils.ltVersion({major: 1, minor: 0, patch: 0},
359 {major: 1, minor: 1, patch: 0}),
360 'ltVersion() checks for a lesser version');
361 t.assertNot(utils.ltVersion({major: 1, minor: 1, patch: 0},
362 {major: 1, minor: 0, patch: 0}),
363 'ltVersion() checks for a lesser version');
364 t.done();
365 })();
366
367
368 t.done(130);
......