32 lines
496 B
Go
32 lines
496 B
Go
package epoch
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
const secs = 1616025600
|
|
|
|
func TestEpoch(t *testing.T) {
|
|
e := Epoch(secs)
|
|
u := time.Unix(secs, 0)
|
|
if e.Time() != u {
|
|
t.Log("epoch did not match time with matching seconds")
|
|
t.FailNow()
|
|
}
|
|
}
|
|
|
|
func TestEpochZero(t *testing.T) {
|
|
if !Zero.Time().IsZero() {
|
|
t.Log("epoch did not match zero-time")
|
|
t.FailNow()
|
|
}
|
|
|
|
var z time.Time
|
|
e := Time(z)
|
|
if !e.Time().Equal(Zero.Time()) {
|
|
t.Log("zero-time did not match zero-epoch")
|
|
t.FailNow()
|
|
}
|
|
}
|