1 // Copyright 2016 The Go 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.
9 func TestStringSet(t *testing.T) {
10 testCases := [][]string{
14 {"", "a", "bb", "ccc"},
15 {" ", "aaa", "bb", "c"},
17 test := func(tc int, b *Builder) {
19 if set.Len() != len(testCases[tc]) {
20 t.Errorf("%d:Len() = %d; want %d", tc, set.Len(), len(testCases[tc]))
22 for i, s := range testCases[tc] {
23 if x := b.Index(s); x != i {
24 t.Errorf("%d:Index(%q) = %d; want %d", tc, s, x, i)
26 if p := Search(&set, s); p != i {
27 t.Errorf("%d:Search(%q) = %d; want %d", tc, s, p, i)
30 t.Errorf("%d:Elem(%d) = %s; want %s", tc, i, set.Elem(i), s)
33 if p := Search(&set, "apple"); p != -1 {
34 t.Errorf(`%d:Search("apple") = %d; want -1`, tc, p)
37 for i, tc := range testCases {
39 for _, s := range tc {
45 for i, tc := range testCases {
48 for _, s := range tc {