forked from phR0ze/n
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchar_test.go
97 lines (82 loc) · 2.22 KB
/
char_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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
package n
import (
"fmt"
"testing"
"github.com/stretchr/testify/assert"
)
// Equal
//--------------------------------------------------------------------------------------------------
func ExampleChar_Equal() {
fmt.Println(NewChar('3').Equal('3'))
// Output: true
}
func TestChar_Equal(t *testing.T) {
// neg
{
// assert.Equal(t, true, NewChar('-3').Equal('3'))
// assert.Equal(t, true, NewChar('3').Equal("3"))
// assert.Equal(t, true, NewChar('3').Equal(3))
// assert.Equal(t, false, NewChar('3').Equal('4'))
// assert.Equal(t, false, NewChar('3').Equal("4"))
// assert.Equal(t, false, NewChar('3').Equal(4))
}
// pos
{
assert.Equal(t, true, NewChar('3').Equal('3'))
assert.Equal(t, true, NewChar('3').Equal("3"))
assert.Equal(t, true, NewChar('3').Equal(3))
assert.Equal(t, false, NewChar('3').Equal('4'))
assert.Equal(t, false, NewChar('3').Equal("4"))
assert.Equal(t, false, NewChar('3').Equal(4))
}
}
// Less
//--------------------------------------------------------------------------------------------------
func ExampleChar_Less() {
fmt.Println(NewChar('3').Less('2'))
// Output: false
}
func TestChar_Less(t *testing.T) {
assert.Equal(t, true, NewChar('3').Less('4'))
assert.Equal(t, true, NewChar('3').Less("4"))
assert.Equal(t, true, NewChar('3').Less(4))
assert.Equal(t, false, NewChar('3').Less('2'))
assert.Equal(t, false, NewChar('3').Less("2"))
assert.Equal(t, false, NewChar('3').Less(2))
}
// String
//--------------------------------------------------------------------------------------------------
func ExampleChar_String() {
char := NewChar('3')
fmt.Println(char)
// Output: 3
}
func TestChar_String(t *testing.T) {
// nil
{
var char *Char
assert.Equal(t, "", char.String())
assert.Equal(t, "", NewChar("").String())
c := Char(0)
assert.Equal(t, "", c.String())
}
// bytes
{
assert.Equal(t, "t", NewChar(byte(0x74)).String())
assert.Equal(t, "t", NewChar([]byte{0x74}).String())
}
// ints
{
assert.Equal(t, "2", NewChar(2).String())
assert.Equal(t, "4", NewChar(int64(4)).String())
assert.Equal(t, 't', NewChar(uint8(0x74)).O())
}
// rune
{
assert.Equal(t, "1", NewChar('1').String())
}
// string
{
assert.Equal(t, "1", NewChar("1").String())
}
}