Files
gods/utils/comparator_test.go
Paul Chesnais 14f714261f Generics migration (#237)
* Generics migration

This attempts to migrate this library in the least invasive way by preserving as
much of the original API as possible. It does not change the tests in a
meaningful way nor does it attempt to upgrade any logic that can be simplified
or improved with generics. This is purely an API migration, and still requires a
lot of additional work to be fully ready.

* Fix a few broken tests around serialization

* Add v2 suffix

* Temporarily change mod name for testing

* Rename module to /v2
2024-01-06 16:06:17 -08:00

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)
}
}
}