github.com/database64128/shadowsocks-go@v1.10.2-0.20240315062903-143a773533f1/bytestrings/bytestrings_test.go (about) 1 package bytestrings 2 3 import "testing" 4 5 const multiline = "\n1\r\n2\n\n3\r\n\r\n4" 6 7 func TestNextNonEmptyLine(t *testing.T) { 8 line, text := NextNonEmptyLine(multiline) 9 if line != "1" { 10 t.Fatalf("Expected line '1', got '%s'", line) 11 } 12 if text != multiline[4:] { 13 t.Fatalf("Expected text '%s', got '%s'", multiline[4:], text) 14 } 15 16 line, text = NextNonEmptyLine(text) 17 if line != "2" { 18 t.Fatalf("Expected line '2', got '%s'", line) 19 } 20 if text != multiline[6:] { 21 t.Fatalf("Expected text '%s', got '%s'", multiline[6:], text) 22 } 23 24 line, text = NextNonEmptyLine(text) 25 if line != "3" { 26 t.Fatalf("Expected line '3', got '%s'", line) 27 } 28 if text != multiline[10:] { 29 t.Fatalf("Expected text '%s', got '%s'", multiline[10:], text) 30 } 31 32 line, text = NextNonEmptyLine(text) 33 if line != "4" { 34 t.Fatalf("Expected line '4', got '%s'", line) 35 } 36 if text != multiline[13:] { 37 t.Fatalf("Expected text '%s', got '%s'", multiline[13:], text) 38 } 39 }