gitee.com/wgliang/goreporter@v0.0.0-20180902115603-df1b20f7c5d0/linters/copycheck/output/output_test.go (about) 1 package output 2 3 import "testing" 4 5 func TestToWhitespace(t *testing.T) { 6 testCases := []struct { 7 in string 8 expect string 9 }{ 10 {"\t ", "\t "}, 11 {"\tčřď", "\t "}, 12 {" \ta", " \t "}, 13 } 14 15 for _, tc := range testCases { 16 actual := toWhitespace([]byte(tc.in)) 17 if tc.expect != string(actual) { 18 t.Errorf("got '%s', want '%s'", actual, tc.expect) 19 } 20 } 21 } 22 23 func TestDeindent(t *testing.T) { 24 testCases := []struct { 25 in string 26 expect string 27 }{ 28 {"\t$\n\t\t$\n\t$", "$\n\t$\n$"}, 29 {"\t$\r\n\t\t$\r\n\t$", "$\r\n\t$\r\n$"}, 30 {"\t$\n\t\t$\n", "$\n\t$\n"}, 31 {"\t$\n\n\t\t$", "$\n\n\t$"}, 32 } 33 for _, tc := range testCases { 34 actual := deindent([]byte(tc.in)) 35 if tc.expect != string(actual) { 36 t.Errorf("got '%s', want '%s'", actual, tc.expect) 37 } 38 } 39 }