OLD | NEW |
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 bytes_test | 5 package bytes_test |
6 | 6 |
7 import ( | 7 import ( |
8 . "bytes" | 8 . "bytes" |
9 "math/rand" | 9 "math/rand" |
10 "reflect" | 10 "reflect" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 {[]byte(""), []byte(""), 0}, | 54 {[]byte(""), []byte(""), 0}, |
55 {[]byte("a"), []byte(""), 1}, | 55 {[]byte("a"), []byte(""), 1}, |
56 {[]byte(""), []byte("a"), -1}, | 56 {[]byte(""), []byte("a"), -1}, |
57 {[]byte("abc"), []byte("abc"), 0}, | 57 {[]byte("abc"), []byte("abc"), 0}, |
58 {[]byte("ab"), []byte("abc"), -1}, | 58 {[]byte("ab"), []byte("abc"), -1}, |
59 {[]byte("abc"), []byte("ab"), 1}, | 59 {[]byte("abc"), []byte("ab"), 1}, |
60 {[]byte("x"), []byte("ab"), 1}, | 60 {[]byte("x"), []byte("ab"), 1}, |
61 {[]byte("ab"), []byte("x"), -1}, | 61 {[]byte("ab"), []byte("x"), -1}, |
62 {[]byte("x"), []byte("a"), 1}, | 62 {[]byte("x"), []byte("a"), 1}, |
63 {[]byte("b"), []byte("x"), -1}, | 63 {[]byte("b"), []byte("x"), -1}, |
| 64 {[]byte("abcdefgh"), []byte("abcdefgh"), 0}, |
| 65 {[]byte("abcdefghi"), []byte("abcdefghi"), 0}, |
| 66 {[]byte("abcdefghi"), []byte("abcdefghj"), -1}, |
64 // nil tests | 67 // nil tests |
65 {nil, nil, 0}, | 68 {nil, nil, 0}, |
66 {[]byte(""), nil, 0}, | 69 {[]byte(""), nil, 0}, |
67 {nil, []byte(""), 0}, | 70 {nil, []byte(""), 0}, |
68 {[]byte("a"), nil, 1}, | 71 {[]byte("a"), nil, 1}, |
69 {nil, []byte("a"), -1}, | 72 {nil, []byte("a"), -1}, |
70 } | 73 } |
71 | 74 |
72 func TestCompare(t *testing.T) { | 75 func TestCompare(t *testing.T) { |
73 for _, tt := range compareTests { | 76 for _, tt := range compareTests { |
(...skipping 999 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1073 FieldsFunc(fieldsInput, unicode.IsSpace) | 1076 FieldsFunc(fieldsInput, unicode.IsSpace) |
1074 } | 1077 } |
1075 } | 1078 } |
1076 | 1079 |
1077 func BenchmarkTrimSpace(b *testing.B) { | 1080 func BenchmarkTrimSpace(b *testing.B) { |
1078 s := []byte(" Some text. \n") | 1081 s := []byte(" Some text. \n") |
1079 for i := 0; i < b.N; i++ { | 1082 for i := 0; i < b.N; i++ { |
1080 TrimSpace(s) | 1083 TrimSpace(s) |
1081 } | 1084 } |
1082 } | 1085 } |
OLD | NEW |