github.com/tinygo-org/tinygo@v0.31.3-0.20240404173401-90b0bf646c27/builder/cc_test.go (about) 1 package builder 2 3 import ( 4 "reflect" 5 "testing" 6 ) 7 8 func TestSplitDepFile(t *testing.T) { 9 for i, tc := range []struct { 10 in string 11 out []string 12 }{ 13 {`deps: foo bar`, []string{"foo", "bar"}}, 14 {`deps: foo "bar"`, []string{"foo", "bar"}}, 15 {`deps: "foo" bar`, []string{"foo", "bar"}}, 16 {`deps: "foo bar"`, []string{"foo bar"}}, 17 {`deps: "foo bar" `, []string{"foo bar"}}, 18 {"deps: foo\nbar", []string{"foo"}}, 19 {"deps: foo \\\nbar", []string{"foo", "bar"}}, 20 {"deps: foo\\bar \\\nbaz", []string{"foo\\bar", "baz"}}, 21 {"deps: foo\\bar \\\r\n baz", []string{"foo\\bar", "baz"}}, // Windows uses CRLF line endings 22 } { 23 out, err := parseDepFile(tc.in) 24 if err != nil { 25 t.Errorf("test #%d failed: %v", i, err) 26 continue 27 } 28 if !reflect.DeepEqual(out, tc.out) { 29 t.Errorf("test #%d failed: expected %#v but got %#v", i, tc.out, out) 30 continue 31 } 32 } 33 }