package main import ( "testing" "time" ) func TestMarshalTime(t *testing.T) { now := time.Now().Truncate(time.Second) b := marshalTime(now) got, ok := unmarshalTime(b) if !ok { t.Fatalf("Failed round trip") } if !got.Equal(now) { t.Errorf("Failed round trip. unmarshalTime(%v) = %v, want %v", b, got, now) } }