Debian Codegraph @

utils/comparator_test.go

raw symbols SCIP
1 // Copyright (c) 2015, Emir Pasic. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 package utils
6
7 import (
8 "testing"
9 "time"
10 )
11
12 func TestTimeComparator(t *testing.T) {
13
14 now := time.Now()
15
16 // i1,i2,expected
17 tests := [][]interface{}{
18 {now, now, 0},
19 {now.Add(24 * 7 * 2 * time.Hour), now, 1},
20 {now, now.Add(24 * 7 * 2 * time.Hour), -1},
21 }
22
23 for _, test := range tests {
24 actual := TimeComparator(test[0].(time.Time), test[1].(time.Time))
25 expected := test[2]
26 if actual != expected {
27 t.Errorf("Got %v expected %v", actual, expected)
28 }
29 }
30 }