mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-06-15 00:15:32 +02:00
Factor out into NormalizeLinefeeds; add tests
This commit is contained in:
34
pkg/utils/utils_test.go
Normal file
34
pkg/utils/utils_test.go
Normal file
@ -0,0 +1,34 @@
|
||||
package utils
|
||||
|
||||
import "testing"
|
||||
|
||||
var testCases = []struct {
|
||||
Input []byte
|
||||
Expected []byte
|
||||
}{
|
||||
{
|
||||
// \r\n
|
||||
Input: []byte{97, 115, 100, 102, 13, 10},
|
||||
Expected: []byte{97, 115, 100, 102, 10},
|
||||
},
|
||||
{
|
||||
// \r
|
||||
Input: []byte{97, 115, 100, 102, 13},
|
||||
Expected: []byte{97, 115, 100, 102, 10},
|
||||
},
|
||||
{
|
||||
// \n
|
||||
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")
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user