LEFT | RIGHT |
1 // Copyright 2009 The Go Authors. All rights reserved. | 1 // Copyright 2009 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 package strings_test | 5 package strings_test |
6 | 6 |
7 import ( | 7 import ( |
8 . "strings"; | 8 . "strings"; |
9 "testing"; | 9 "testing"; |
10 "unicode"; | 10 "unicode"; |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 } | 179 } |
180 } | 180 } |
181 } | 181 } |
182 | 182 |
183 type FieldsTest struct { | 183 type FieldsTest struct { |
184 s string; | 184 s string; |
185 a []string; | 185 a []string; |
186 } | 186 } |
187 | 187 |
188 var fieldstests = []FieldsTest{ | 188 var fieldstests = []FieldsTest{ |
189 FieldsTest{"1 2 3 4", []string{"1", "2", "3", "4"}}, | |
190 FieldsTest{"1 2 3 4", []string{"1", "2", "3", "4"}}, | |
191 FieldsTest{"", []string{}}, | 189 FieldsTest{"", []string{}}, |
192 FieldsTest{" ", []string{}}, | 190 FieldsTest{" ", []string{}}, |
193 FieldsTest{" \t ", []string{}}, | 191 FieldsTest{" \t ", []string{}}, |
194 FieldsTest{" abc ", []string{"abc"}}, | 192 FieldsTest{" abc ", []string{"abc"}}, |
| 193 FieldsTest{"1 2 3 4", []string{"1", "2", "3", "4"}}, |
| 194 FieldsTest{"1 2 3 4", []string{"1", "2", "3", "4"}}, |
195 FieldsTest{"1\t\t2\t\t3\t4", []string{"1", "2", "3", "4"}}, | 195 FieldsTest{"1\t\t2\t\t3\t4", []string{"1", "2", "3", "4"}}, |
196 FieldsTest{"1\u20002\u20013\u20024", []string{"1", "2", "3", "4"}}, | 196 FieldsTest{"1\u20002\u20013\u20024", []string{"1", "2", "3", "4"}}, |
197 FieldsTest{"\u2000\u2001\u2002", []string{}}, | 197 FieldsTest{"\u2000\u2001\u2002", []string{}}, |
198 FieldsTest{"\n™\t™\n", []string{"™", "™"}}, | 198 FieldsTest{"\n™\t™\n", []string{"™", "™"}}, |
199 FieldsTest{faces, []string{faces}}, | 199 FieldsTest{faces, []string{faces}}, |
200 } | 200 } |
201 | 201 |
202 func TestFields(t *testing.T) { | 202 func TestFields(t *testing.T) { |
203 for _, tt := range fieldstests { | 203 for _, tt := range fieldstests { |
204 a := Fields(tt.s); | 204 a := Fields(tt.s); |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
451 } | 451 } |
452 if !tt.lossy { | 452 if !tt.lossy { |
453 // can only test reassembly if we didn't lose informatio
n | 453 // can only test reassembly if we didn't lose informatio
n |
454 s := string(a); | 454 s := string(a); |
455 if s != tt.in { | 455 if s != tt.in { |
456 t.Errorf("string(Runes(%q)) = %x; want %x", tt.i
n, s, tt.in) | 456 t.Errorf("string(Runes(%q)) = %x; want %x", tt.i
n, s, tt.in) |
457 } | 457 } |
458 } | 458 } |
459 } | 459 } |
460 } | 460 } |
LEFT | RIGHT |