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

NormalizeLinefeeds removes rather than converts Window/Mac style lf's

This commit is contained in:
Tommy Nguyen
2018-08-19 08:48:03 -04:00
parent d2bdac29aa
commit 766197de9d
3 changed files with 15 additions and 13 deletions

View File

@ -3,32 +3,32 @@ package utils
import "testing"
var testCases = []struct {
Input []byte
Input []byte
Expected []byte
}{
{
// \r\n
Input: []byte{97, 115, 100, 102, 13, 10},
Expected: []byte{97, 115, 100, 102, 10},
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, 10},
Input: []byte{97, 115, 100, 102, 13},
Expected: []byte{97, 115, 100, 102},
},
{
// \n
Input: []byte{97, 115, 100, 102, 10},
Input: []byte{97, 115, 100, 102, 10},
Expected: []byte{97, 115, 100, 102, 10},
},
}
func TestNormalizeLinefeeds(t *testing.T) {
for _, tc := range testCases {
if NormalizeLinefeeds(string(tc.Input)) != string(tc.Expected) {
t.Error("Error")
input := NormalizeLinefeeds(string(tc.Input))
expected := string(tc.Expected)
if input != expected {
t.Error("Expected " + expected + ", got " + input)
}
}
}