You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
gods/utils/comparator_test.go

31 lines
634 B
Go

// Copyright (c) 2015, Emir Pasic. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package utils
import (
"testing"
"time"
)
func TestTimeComparator(t *testing.T) {
now := time.Now()
// i1,i2,expected
tests := [][]interface{}{
{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 := TimeComparator(test[0].(time.Time), test[1].(time.Time))
expected := test[2]
if actual != expected {
t.Errorf("Got %v expected %v", actual, expected)
}
}
}