summaryrefslogtreecommitdiffstats
path: root/pkg/utils/utils_test.go
diff options
context:
space:
mode:
authorTommy Nguyen <remyabel@gmail.com>2018-08-19 23:39:57 -0400
committerTommy Nguyen <remyabel@gmail.com>2018-08-19 23:39:57 -0400
commit5dd049eb821f25573ba63b70dc7c08587444f5f8 (patch)
tree6952ee63f524bae3507bc0ef14a9a20b3b9358d2 /pkg/utils/utils_test.go
parentf1a4a7e1ff6499adf512ecd1b623f77a61ad8d5f (diff)
Convert test to use new library
Diffstat (limited to 'pkg/utils/utils_test.go')
-rw-r--r--pkg/utils/utils_test.go51
1 files changed, 24 insertions, 27 deletions
diff --git a/pkg/utils/utils_test.go b/pkg/utils/utils_test.go
index 047ed9fb9..2d5a25fcd 100644
--- a/pkg/utils/utils_test.go
+++ b/pkg/utils/utils_test.go
@@ -82,33 +82,30 @@ func TestTrimTrailingNewline(t *testing.T) {
}
}
-var testCases = []struct {
- Input []byte
- Expected []byte
-}{
- {
- // \r\n
- Input: []byte{97, 115, 100, 102, 13, 10},
- Expected: []byte{97, 115, 100, 102},
- },
- {
- // \r
- Input: []byte{97, 115, 100, 102, 13},
- Expected: []byte{97, 115, 100, 102},
- },
- {
- // \n
- Input: []byte{97, 115, 100, 102, 10},
- Expected: []byte{97, 115, 100, 102, 10},
- },
-}
-
func TestNormalizeLinefeeds(t *testing.T) {
- for _, tc := range testCases {
- input := NormalizeLinefeeds(string(tc.Input))
- expected := string(tc.Expected)
- if input != expected {
- t.Error("Expected " + expected + ", got " + input)
- }
+ type scenario struct {
+ byteArray []byte
+ expected []byte
+ }
+ var scenarios = []scenario{
+ {
+ // \r\n
+ []byte{97, 115, 100, 102, 13, 10},
+ []byte{97, 115, 100, 102},
+ },
+ {
+ // \r
+ []byte{97, 115, 100, 102, 13},
+ []byte{97, 115, 100, 102},
+ },
+ {
+ // \n
+ []byte{97, 115, 100, 102, 10},
+ []byte{97, 115, 100, 102, 10},
+ },
+ }
+
+ for _, s := range scenarios {
+ assert.EqualValues(t, string(s.expected), NormalizeLinefeeds(string(s.byteArray)))
}
}