-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconditional_test.go
54 lines (41 loc) · 954 Bytes
/
conditional_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
package conditional_test
import (
"testing"
"github.com/mileusna/conditional"
)
func TestConditional(t *testing.T) {
if conditional.Int(true, 5, 4) != 5 {
t.Fatal("Error Int")
}
if conditional.Int(false, 5, 4) != 4 {
t.Fatal("Error Int")
}
if conditional.String(true, "ok", "not ok") != "ok" {
t.Fatal("Error string")
}
if conditional.String(false, "ok", "not ok") != "not ok" {
t.Fatal("Error string")
}
if conditional.UInt(true, 5, 4) != 5 {
t.Fatal("Error UInt")
}
if conditional.UInt(false, 5, 4) != 4 {
t.Fatal("Error UInt")
}
if conditional.Float64(true, 5.5, 4.5) != 5.5 {
t.Fatal("Error Float64")
}
if conditional.Float64(false, 5.5, 4.5) != 4.5 {
t.Fatal("Error Float64")
}
i := conditional.Interface(true, "hello", 10)
switch i.(type) {
case int:
t.Fatal("Error Interface")
}
n := conditional.Interface(false, "hello", 10)
switch n.(type) {
case string:
t.Fatal("Error Interface")
}
}