-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtable_getter_test.go
96 lines (89 loc) · 2.13 KB
/
table_getter_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
package herschel
import (
"testing"
)
func TestTable_GetStringValue(t *testing.T) {
table := NewTable(1, 4)
table.PutValue(0, 0, "Hello")
table.PutValue(0, 1, "World")
table.PutValue(0, 2, 123)
type args struct {
row int
col int
}
tests := []struct {
name string
args args
want string
}{
{"StringAtFirstCell", args{0, 0}, "Hello"},
{"StringAtSecondCell", args{0, 1}, "World"},
{"CellWithIntValue", args{0, 2}, ""},
{"EmptyCell", args{0, 3}, ""},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := table.GetStringValue(tt.args.row, tt.args.col); got != tt.want {
t.Errorf("Table.GetStringValue() = %v, want %v", got, tt.want)
}
})
}
}
func TestTable_GetIntValue(t *testing.T) {
table := NewTable(1, 5)
table.PutValue(0, 0, 123)
table.PutValue(0, 1, 456)
table.PutValue(0, 2, "Hello")
table.PutValue(0, 4, "12345")
type args struct {
row int
col int
}
tests := []struct {
name string
args args
want int
}{
{"IntAtFirstCell", args{0, 0}, 123},
{"IntAtSecondCell", args{0, 1}, 456},
{"CellWithStringValue", args{0, 2}, 0},
{"EmptyCell", args{0, 3}, 0},
{"ParsableStringValue", args{0, 4}, 12345},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := table.GetIntValue(tt.args.row, tt.args.col); got != tt.want {
t.Errorf("Table.GetIntValue() = %v, want %v", got, tt.want)
}
})
}
}
func TestTable_GetInt64Value(t *testing.T) {
table := NewTable(1, 5)
table.PutValue(0, 0, int64(9223372036854775806))
table.PutValue(0, 1, 456)
table.PutValue(0, 2, "Hello")
table.PutValue(0, 4, "12345")
type args struct {
row int
col int
}
tests := []struct {
name string
args args
want int64
}{
{"Int64AtFirstCell", args{0, 0}, 9223372036854775806},
{"IntAtSecondCell", args{0, 1}, 456},
{"CellWithStringValue", args{0, 2}, 0},
{"EmptyCell", args{0, 3}, 0},
{"ParsableStringValue", args{0, 4}, 12345},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := table.GetInt64Value(tt.args.row, tt.args.col); got != tt.want {
t.Errorf("Table.GetInt64Value() = %v, want %v", got, tt.want)
}
})
}
}