source: core/java/test/scalatest/net/i2p/util/VersionComparatorSpec.scala @ 4266a10

Last change on this file since 4266a10 was 4266a10, checked in by str4d <str4d@…>, 8 years ago

Added more tests to VersionComparatorSpec? to further cover the implementation

  • Property mode set to 100644
File size: 1.8 KB
Line 
1package net.i2p.util
2
3import org.scalatest.FunSpec
4import org.scalatest.matchers.ShouldMatchers
5
6class VersionComparatorSpec extends FunSpec with ShouldMatchers {
7    val vc = new VersionComparator
8
9    describe("A VersionComparator") {
10        it("should find that 0.1.2 equals 0.1.2") {
11            vc.compare("0.1.2", "0.1.2") should equal (0)
12        }
13        it("should find that 0.1.2 is less than 0.1.3") {
14            vc.compare("0.1.2", "0.1.3") should equal (-1)
15        }
16        it("should find that 0.1.3 is greater than 0.1.2") {
17            vc.compare("0.1.3", "0.1.2") should equal (1)
18        }
19        it("should find that 0.1.2.3.4 is greater than 0.1.2") {
20            vc.compare("0.1.2.3.4", "0.1.2") should equal (1)
21        }
22        it("should find that 0.1.2 is less than 0.1.2.3.4") {
23            vc.compare("0.1.2", "0.1.2.3.4") should equal (-1)
24        }
25        it("should find that 0.1.3 is greater than 0.1.2.3.4") {
26            vc.compare("0.1.3", "0.1.2.3.4") should equal (1)
27        }
28        it("should find that 0.1.2 is equal to 0-1-2") {
29            vc.compare("0.1.2", "0-1-2") should equal (0)
30        }
31        it("should find that 0.1.2 is equal to 0_1_2") {
32            vc.compare("0.1.2", "0_1_2") should equal (0)
33        }
34        it("should find that 0.1.2-foo is equal to 0.1.2-bar") {
35            vc.compare("0.1.2-foo", "0.1.2-bar") should equal (0)
36        }
37        it("should find that -0.1.2 is less than -0.1.3") {
38            vc.compare("-0.1.2", "-0.1.3") should equal (-1)
39        }
40        it("should find that 0..2 is greater than 0.1.2") {
41            vc.compare("0..2", "0.1.2") should equal (1)
42        }
43        it("should find that 0.1.2 is less than 0..2") {
44            vc.compare("0.1.2", "0..2") should equal (-1)
45        }
46    }
47}
Note: See TracBrowser for help on using the repository browser.