-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathproblem057_test.go
40 lines (36 loc) · 959 Bytes
/
problem057_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
package problem057
import (
"reflect"
"strings"
"testing"
)
type argumentSet struct {
fullSentence string
lengthLimit int
result []string
}
func TestSplitLine(t *testing.T) {
testCases := []argumentSet{
{
fullSentence: "the quick brown fox jumps over the lazy dog",
lengthLimit: 10,
result: []string{"the quick", "brown fox", "jumps over", "the lazy", "dog"},
},
{
fullSentence: "the quick brown fox jumps over the lazy dog",
lengthLimit: 1,
result: nil,
},
}
for _, testCase := range testCases {
actual, expected := SplitLine(testCase.fullSentence, testCase.lengthLimit), testCase.result
if actual == nil && expected == nil {
t.Logf("Actual: %s / Expected: %s", "nil", "nil")
} else {
t.Logf("Actual: %s / Expected: %s", strings.Join(actual, ", "), strings.Join(expected, ", "))
}
if (actual == nil && expected == nil) && !reflect.DeepEqual(actual, expected) {
t.Fail()
}
}
}