Source file
src/time/linkname_test.go
1
2
3
4
5 package time_test
6
7 import (
8 "testing"
9 "time"
10 _ "unsafe"
11 )
12
13
14 func timeAbs(time.Time) uint64
15
16
17 func absClock(uint64) (hour, min, sec int)
18
19
20 func absDate(uint64, bool) (year int, month time.Month, day int, yday int)
21
22 func TestLinkname(t *testing.T) {
23 tm := time.Date(2006, time.January, 2, 15, 4, 5, 6, time.UTC)
24 abs := timeAbs(tm)
25
26
27 const wantAbs = 9223372029851535845
28 if abs != wantAbs {
29 t.Fatalf("timeAbs(2006-01-02 15:04:05 UTC) = %d, want %d", abs, uint64(wantAbs))
30 }
31
32 year, month, day, yday := absDate(abs, true)
33 if year != 2006 || month != time.January || day != 2 || yday != 1 {
34 t.Errorf("absDate() = %v, %v, %v, %v, want 2006, January, 2, 1", year, month, day, yday)
35 }
36
37 hour, min, sec := absClock(abs)
38 if hour != 15 || min != 4 || sec != 5 {
39 t.Errorf("absClock() = %v, %v, %v, 15, 4, 5", hour, min, sec)
40 }
41 }
42
View as plain text