-
Notifications
You must be signed in to change notification settings - Fork 0
/
strings_test.go
98 lines (88 loc) · 2.42 KB
/
strings_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
98
package main
import (
"fmt"
"testing"
)
func TestIsStringNumber(t *testing.T) {
var tests = []struct {
input string
expectedResult bool
}{
{"", false},
{"-10", false},
{"0", true},
{"10", true},
{"100", true},
{"abc", false},
{"1a", false},
{"a1", false},
{"1a1", false},
}
for _, currentTest := range tests {
testname := fmt.Sprintf("%s", currentTest.input)
t.Run(testname, func(t *testing.T) {
result := IsStringNumber(currentTest.input)
if result != currentTest.expectedResult {
t.Errorf("IsStringNumber() : FAIL : input %s got %t, want %t", currentTest.input, result, currentTest.expectedResult)
} else {
t.Logf("IsStringNumber() : PASS : input %s got %t, want %t", currentTest.input, result, currentTest.expectedResult)
}
})
}
}
func TestIsStringHelpArgument(t *testing.T) {
var tests = []struct {
input string
expectedResult bool
}{
{"", false},
{"?", true},
{"/?", true},
{"-?", true},
{"--?", true},
{"-h", true},
{"--h", true},
{"help", true},
{"/help", true},
{"-help", true},
{"--help", true},
{"a", false},
{"12", false},
{"+", false},
{"-a", false},
{"--a", false},
{"/*", false},
{"-9", false},
}
for _, currentTest := range tests {
testname := fmt.Sprintf("%s", currentTest.input)
t.Run(testname, func(t *testing.T) {
result := IsStringHelpArgument(currentTest.input)
if result != currentTest.expectedResult {
t.Errorf("IsStringHelpArgument() : FAIL : input %s got %t, want %t", currentTest.input, result, currentTest.expectedResult)
} else {
t.Logf("IsStringHelpArgument() : PASS : input %s got %t, want %t", currentTest.input, result, currentTest.expectedResult)
}
})
}
}
func TestDisplaySectionType(t *testing.T) {
var tests = []struct {
input SECTION_TYPE
expectedResult string
}{
{OVERWRITE_SECTION, UI_OverwriteSection},
{RANDOM_SPACE, UI_RandomSpace},
}
for _, currentTest := range tests {
testname := fmt.Sprintf("%s", string(currentTest.input))
t.Run(testname, func(t *testing.T) {
result := DisplaySectionType(currentTest.input)
if result != currentTest.expectedResult {
t.Errorf("DisplaySectionType() : FAIL : input %s got %s, want %s", string(currentTest.input), result, currentTest.expectedResult)
} else {
t.Logf("DisplaySectionType() : PASS : input %s got %s, want %s", string(currentTest.input), result, currentTest.expectedResult)
}
})
}
}