1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-06-13 00:07:59 +02:00

Convert test to use new library

This commit is contained in:
Tommy Nguyen 2018-08-19 23:39:57 -04:00
parent f1a4a7e1ff
commit 5dd049eb82
No known key found for this signature in database
GPG Key ID: DB7FA8161647D196

View File

@ -82,33 +82,30 @@ func TestTrimTrailingNewline(t *testing.T) {
} }
} }
var testCases = []struct { func TestNormalizeLinefeeds(t *testing.T) {
Input []byte type scenario struct {
Expected []byte byteArray []byte
}{ expected []byte
}
var scenarios = []scenario{
{ {
// \r\n // \r\n
Input: []byte{97, 115, 100, 102, 13, 10}, []byte{97, 115, 100, 102, 13, 10},
Expected: []byte{97, 115, 100, 102}, []byte{97, 115, 100, 102},
}, },
{ {
// \r // \r
Input: []byte{97, 115, 100, 102, 13}, []byte{97, 115, 100, 102, 13},
Expected: []byte{97, 115, 100, 102}, []byte{97, 115, 100, 102},
}, },
{ {
// \n // \n
Input: []byte{97, 115, 100, 102, 10}, []byte{97, 115, 100, 102, 10},
Expected: []byte{97, 115, 100, 102, 10}, []byte{97, 115, 100, 102, 10},
}, },
} }
func TestNormalizeLinefeeds(t *testing.T) { for _, s := range scenarios {
for _, tc := range testCases { assert.EqualValues(t, string(s.expected), NormalizeLinefeeds(string(s.byteArray)))
input := NormalizeLinefeeds(string(tc.Input))
expected := string(tc.Expected)
if input != expected {
t.Error("Expected " + expected + ", got " + input)
}
} }
} }