|
|
|
@ -31,20 +31,22 @@ func TestIntComparator(t *testing.T) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestStringComparator(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
func TestTimeComparator(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
now := time.Now()
|
|
|
|
|
|
|
|
|
|
// i1,i2,expected
|
|
|
|
|
// s1,s2,expected
|
|
|
|
|
tests := [][]interface{}{
|
|
|
|
|
{now, now, 0},
|
|
|
|
|
{now.Add(24 * 7 * 2 * time.Hour), now, 1},
|
|
|
|
|
{now, now.Add(24 * 7 * 2 * time.Hour), -1},
|
|
|
|
|
{"a", "a", 0},
|
|
|
|
|
{"a", "b", -1},
|
|
|
|
|
{"b", "a", 1},
|
|
|
|
|
{"aa", "aab", -1},
|
|
|
|
|
{"", "", 0},
|
|
|
|
|
{"a", "", 1},
|
|
|
|
|
{"", "a", -1},
|
|
|
|
|
{"", "aaaaaaa", -1},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for _, test := range tests {
|
|
|
|
|
actual := TimeComparator(test[0], test[1])
|
|
|
|
|
actual := StringComparator(test[0], test[1])
|
|
|
|
|
expected := test[2]
|
|
|
|
|
if actual != expected {
|
|
|
|
|
t.Errorf("Got %v expected %v", actual, expected)
|
|
|
|
@ -52,22 +54,19 @@ func TestTimeComparator(t *testing.T) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestStringComparator(t *testing.T) {
|
|
|
|
|
func TestTimeComparator(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
// s1,s2,expected
|
|
|
|
|
now := time.Now()
|
|
|
|
|
|
|
|
|
|
// i1,i2,expected
|
|
|
|
|
tests := [][]interface{}{
|
|
|
|
|
{"a", "a", 0},
|
|
|
|
|
{"a", "b", -1},
|
|
|
|
|
{"b", "a", 1},
|
|
|
|
|
{"aa", "aab", -1},
|
|
|
|
|
{"", "", 0},
|
|
|
|
|
{"a", "", 1},
|
|
|
|
|
{"", "a", -1},
|
|
|
|
|
{"", "aaaaaaa", -1},
|
|
|
|
|
{now, now, 0},
|
|
|
|
|
{now.Add(24 * 7 * 2 * time.Hour), now, 1},
|
|
|
|
|
{now, now.Add(24 * 7 * 2 * time.Hour), -1},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for _, test := range tests {
|
|
|
|
|
actual := StringComparator(test[0], test[1])
|
|
|
|
|
actual := TimeComparator(test[0], test[1])
|
|
|
|
|
expected := test[2]
|
|
|
|
|
if actual != expected {
|
|
|
|
|
t.Errorf("Got %v expected %v", actual, expected)
|
|
|
|
|