-
Notifications
You must be signed in to change notification settings - Fork 0
/
q_constant_test.go
70 lines (67 loc) · 1.23 KB
/
q_constant_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
package dal
import (
"github.com/stretchr/testify/assert"
"testing"
)
func TestConstant_Equal(t *testing.T) {
tests := []struct {
name string
constant Constant
input Constant
want bool
}{
{
name: "both_empty",
constant: Constant{},
input: Constant{},
want: true,
},
{
name: "string_equal",
constant: Constant{Value: "s1"},
input: Constant{Value: "s1"},
want: true,
},
{
name: "string_not_equal",
constant: Constant{Value: "s1"},
input: Constant{Value: "s2"},
want: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
actual := tt.constant.Equal(tt.input)
assert.Equal(t, tt.want, actual)
})
}
}
func TestConstant_String(t *testing.T) {
tests := []struct {
name string
constant Constant
want string
}{
{
name: "empty",
constant: Constant{},
want: "null",
},
{
name: "string",
constant: Constant{Value: "s1"},
want: "'s1'",
},
{
name: "int",
constant: Constant{Value: 123},
want: "123",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
actual := tt.constant.String()
assert.Equal(t, tt.want, actual)
})
}
}