-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils_test.go
81 lines (66 loc) · 1.41 KB
/
utils_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
package slog
import "testing"
func TestUint2Bytes(t *testing.T) {
bs := string(uint2Bytes(0, 2))
if bs != "00" {
t.Errorf("result is " + bs)
}
bs = string(uint2Bytes(59, 2))
if bs != "59" {
t.Errorf("result is " + bs)
}
bs = string(uint2Bytes(1970, 4))
if bs != "1970" {
t.Errorf("result is " + bs)
}
bs = string(uint2Bytes(2038, 4))
if bs != "2038" {
t.Errorf("result is " + bs)
}
}
func TestUint2Bytes2(t *testing.T) {
bs := string(uint2Bytes2(0))
if bs != "00" {
t.Errorf("result is " + bs)
}
bs = string(uint2Bytes2(59))
if bs != "59" {
t.Errorf("result is " + bs)
}
}
func TestUint2Bytes4(t *testing.T) {
bs := string(uint2Bytes4(1970))
if bs != "1970" {
t.Errorf("result is " + bs)
}
bs = string(uint2Bytes4(2038))
if bs != "2038" {
t.Errorf("result is " + bs)
}
}
func TestFastUint2DynamicBytes(t *testing.T) {
bs := string(fastUint2DynamicBytes(0))
if bs != "0" {
t.Errorf("result is " + bs)
}
bs = string(fastUint2DynamicBytes(59))
if bs != "59" {
t.Errorf("result is " + bs)
}
bs = string(fastUint2DynamicBytes(1000))
if bs != "1000" {
t.Errorf("result is " + bs)
}
bs = string(fastUint2DynamicBytes(1970))
if bs != "1970" {
t.Errorf("result is " + bs)
}
bs = string(fastUint2DynamicBytes(2038))
if bs != "2038" {
t.Errorf("result is " + bs)
}
bs = string(fastUint2DynamicBytes(2<<31 - 1))
if bs != "4294967295" {
t.Errorf("result is " + bs)
}
}