forked from jedib0t/go-pretty
-
Notifications
You must be signed in to change notification settings - Fork 0
/
util_test.go
53 lines (47 loc) · 1.76 KB
/
util_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
package table
import (
"fmt"
"testing"
"github.com/stretchr/testify/assert"
)
func ExampleAutoIndexColumnID() {
fmt.Printf("AutoIndexColumnID( 0): \"%s\"\n", AutoIndexColumnID(0))
fmt.Printf("AutoIndexColumnID( 1): \"%s\"\n", AutoIndexColumnID(1))
fmt.Printf("AutoIndexColumnID( 2): \"%s\"\n", AutoIndexColumnID(2))
fmt.Printf("AutoIndexColumnID( 25): \"%s\"\n", AutoIndexColumnID(25))
fmt.Printf("AutoIndexColumnID( 26): \"%s\"\n", AutoIndexColumnID(26))
fmt.Printf("AutoIndexColumnID( 702): \"%s\"\n", AutoIndexColumnID(702))
fmt.Printf("AutoIndexColumnID(18278): \"%s\"\n", AutoIndexColumnID(18278))
// Output: AutoIndexColumnID( 0): "A"
// AutoIndexColumnID( 1): "B"
// AutoIndexColumnID( 2): "C"
// AutoIndexColumnID( 25): "Z"
// AutoIndexColumnID( 26): "AA"
// AutoIndexColumnID( 702): "AAA"
// AutoIndexColumnID(18278): "AAAA"
}
func TestAutoIndexColumnID(t *testing.T) {
assert.Equal(t, "A", AutoIndexColumnID(0))
assert.Equal(t, "Z", AutoIndexColumnID(25))
assert.Equal(t, "AA", AutoIndexColumnID(26))
assert.Equal(t, "ZZ", AutoIndexColumnID(701))
assert.Equal(t, "AAA", AutoIndexColumnID(702))
assert.Equal(t, "ZZZ", AutoIndexColumnID(18277))
assert.Equal(t, "AAAA", AutoIndexColumnID(18278))
}
func TestIsNumber(t *testing.T) {
assert.True(t, isNumber(int(1)))
assert.True(t, isNumber(int8(1)))
assert.True(t, isNumber(int16(1)))
assert.True(t, isNumber(int32(1)))
assert.True(t, isNumber(int64(1)))
assert.True(t, isNumber(uint(1)))
assert.True(t, isNumber(uint8(1)))
assert.True(t, isNumber(uint16(1)))
assert.True(t, isNumber(uint32(1)))
assert.True(t, isNumber(uint64(1)))
assert.True(t, isNumber(float32(1)))
assert.True(t, isNumber(float64(1)))
assert.False(t, isNumber("1"))
assert.False(t, isNumber(nil))
}