-
Notifications
You must be signed in to change notification settings - Fork 1
/
integers_test.go
74 lines (60 loc) · 1.64 KB
/
integers_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
package typenv_test
import (
"os"
"testing"
"diegomarangoni.dev/typenv"
)
func TestInt8(t *testing.T) {
var expected, got int8
got = typenv.Int8("TEST_INT8")
if got != expected {
t.Errorf("Int8 failed, expected `%v` but got `%v`.", expected, got)
}
expected = 127
got = typenv.Int8("TEST_INT8", 127)
if got != expected {
t.Errorf("Int8 failed, expected `%v` but got `%v`.", expected, got)
}
os.Setenv("TEST_INT8", "-128")
expected = -128
got = typenv.Int8("TEST_INT8", 99)
if got != expected {
t.Errorf("Int8 failed, expected `%v` but got `%v`.", expected, got)
}
}
func TestInt32(t *testing.T) {
var expected, got int32
got = typenv.Int32("TEST_INT32")
if got != expected {
t.Errorf("Int32 failed, expected `%v` but got `%v`.", expected, got)
}
expected = 2147483647
got = typenv.Int32("TEST_INT32", 2147483647)
if got != expected {
t.Errorf("Int32 failed, expected `%v` but got `%v`.", expected, got)
}
os.Setenv("TEST_INT32", "-2147483648")
expected = -2147483648
got = typenv.Int32("TEST_INT32", 99)
if got != expected {
t.Errorf("Int32 failed, expected `%v` but got `%v`.", expected, got)
}
}
func TestInt(t *testing.T) {
var expected, got int
got = typenv.Int("TEST_INT")
if got != expected {
t.Errorf("Int failed, expected `%v` but got `%v`.", expected, got)
}
expected = 2147483647
got = typenv.Int("TEST_INT", 2147483647)
if got != expected {
t.Errorf("Int failed, expected `%v` but got `%v`.", expected, got)
}
os.Setenv("TEST_INT", "-2147483648")
expected = -2147483648
got = typenv.Int("TEST_INT", 99)
if got != expected {
t.Errorf("Int failed, expected `%v` but got `%v`.", expected, got)
}
}