github.com/shaardie/u-root@v4.0.1-0.20190127173353-f24a1c26aa2e+incompatible/integration/fields_test.go (about) 1 // Copyright 2019 the u-root Authors. All rights reserved 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package integration 6 7 import ( 8 "reflect" 9 "testing" 10 ) 11 12 func TestFields(t *testing.T) { 13 for _, test := range []struct { 14 data string 15 want []string 16 }{ 17 { 18 data: "foo bar baz", 19 want: []string{"foo", "bar", "baz"}, 20 }, 21 { 22 data: "foo\tbar\nbaz", 23 want: []string{"foo", "bar", "baz"}, 24 }, 25 { 26 data: `"foo bar" baz`, 27 want: []string{`"foo bar"`, "baz"}, 28 }, 29 { 30 data: `"foo\tbar" baz`, 31 want: []string{`"foo\tbar"`, "baz"}, 32 }, 33 { 34 data: `foo "bar baz"`, 35 want: []string{"foo", `"bar baz"`}, 36 }, 37 { 38 data: `foo "bar' baz`, 39 want: []string{"foo", `"bar' baz`}, 40 }, 41 { 42 data: `foo bar "baz`, 43 want: []string{"foo", "bar", `"baz`}, 44 }, 45 } { 46 t.Run(test.data, func(t *testing.T) { 47 got := fields(test.data) 48 if !reflect.DeepEqual(got, test.want) { 49 t.Errorf("fields() got %v, want %v", got, test.want) 50 } 51 }) 52 } 53 }