mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-30 07:40:06 +01:00
31 lines
678 B
Go
31 lines
678 B
Go
|
package fasttime
|
||
|
|
||
|
import (
|
||
|
"testing"
|
||
|
"time"
|
||
|
)
|
||
|
|
||
|
func TestUnixTimestamp(t *testing.T) {
|
||
|
tsExpected := uint64(time.Now().Unix())
|
||
|
ts := UnixTimestamp()
|
||
|
if ts-tsExpected > 1 {
|
||
|
t.Fatalf("unexpected UnixTimestamp; got %d; want %d", ts, tsExpected)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func TestUnixDate(t *testing.T) {
|
||
|
dateExpected := uint64(time.Now().Unix() / (24 * 3600))
|
||
|
date := UnixDate()
|
||
|
if date-dateExpected > 1 {
|
||
|
t.Fatalf("unexpected UnixDate; got %d; want %d", date, dateExpected)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func TestUnixHour(t *testing.T) {
|
||
|
hourExpected := uint64(time.Now().Unix() / 3600)
|
||
|
hour := UnixHour()
|
||
|
if hour-hourExpected > 1 {
|
||
|
t.Fatalf("unexpected UnixHour; got %d; want %d", hour, hourExpected)
|
||
|
}
|
||
|
}
|