Strip carriage-returns from textfile input

This commit is contained in:
Calle Pettersson
2018-05-15 20:52:11 +02:00
parent a0333ee256
commit 2951a9ef80
2 changed files with 47 additions and 1 deletions

View File

@@ -0,0 +1,20 @@
package collector
import (
"testing"
"strings"
"io/ioutil"
)
func TestCRFilter(t *testing.T) {
sr := strings.NewReader("line 1\r\nline 2")
cr := carriageReturnFilteringReader{ r: sr }
b, err := ioutil.ReadAll(cr)
if err != nil {
t.Error(err)
}
if string(b) != "line 1\nline 2" {
t.Errorf("Unexpected output %q", b)
}
}