summaryrefslogtreecommitdiffstats
path: root/pkg/utils/utils_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/utils/utils_test.go')
-rw-r--r--pkg/utils/utils_test.go30
1 files changed, 30 insertions, 0 deletions
diff --git a/pkg/utils/utils_test.go b/pkg/utils/utils_test.go
index 58e78cce9..ffc753fd4 100644
--- a/pkg/utils/utils_test.go
+++ b/pkg/utils/utils_test.go
@@ -81,3 +81,33 @@ func TestTrimTrailingNewline(t *testing.T) {
assert.EqualValues(t, s.expected, TrimTrailingNewline(s.str))
}
}
+
+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)
+ }
+}