mirror of
https://github.com/prometheus/prometheus.git
synced 2024-11-14 01:24:04 -08:00
26 lines
482 B
Go
26 lines
482 B
Go
|
package indexable
|
||
|
|
||
|
import (
|
||
|
"math/rand"
|
||
|
"testing"
|
||
|
"testing/quick"
|
||
|
"time"
|
||
|
)
|
||
|
|
||
|
func TestTimeEndToEnd(t *testing.T) {
|
||
|
tester := func(x int) bool {
|
||
|
random := rand.New(rand.NewSource(int64(x)))
|
||
|
buffer := make([]byte, 8)
|
||
|
incoming := time.Unix(random.Int63(), 0)
|
||
|
|
||
|
EncodeTimeInto(buffer, incoming)
|
||
|
outgoing := DecodeTime(buffer)
|
||
|
|
||
|
return incoming.Equal(outgoing) && incoming.Unix() == outgoing.Unix()
|
||
|
}
|
||
|
|
||
|
if err := quick.Check(tester, nil); err != nil {
|
||
|
t.Error(err)
|
||
|
}
|
||
|
}
|