github.com/kayoticsully/syncthing@v0.8.9-0.20140724133906-c45a2fdc03f8/cmd/syncthing/upgrade_test.go (about)

     1  // Copyright (C) 2014 Jakob Borg and Contributors (see the CONTRIBUTORS file).
     2  // All rights reserved. Use of this source code is governed by an MIT-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package main
     6  
     7  import "testing"
     8  
     9  var testcases = []struct {
    10  	a, b string
    11  	r    int
    12  }{
    13  	{"0.1.2", "0.1.2", 0},
    14  	{"0.1.3", "0.1.2", 1},
    15  	{"0.1.1", "0.1.2", -1},
    16  	{"0.3.0", "0.1.2", 1},
    17  	{"0.0.9", "0.1.2", -1},
    18  	{"1.1.2", "0.1.2", 1},
    19  	{"0.1.2", "1.1.2", -1},
    20  	{"0.1.10", "0.1.9", 1},
    21  	{"0.10.0", "0.2.0", 1},
    22  	{"30.10.0", "4.9.0", 1},
    23  }
    24  
    25  func TestCompareVersions(t *testing.T) {
    26  	for _, tc := range testcases {
    27  		if r := compareVersions(tc.a, tc.b); r != tc.r {
    28  			t.Errorf("compareVersions(%q, %q): %d != %d", tc.a, tc.b, r, tc.r)
    29  		}
    30  	}
    31  }