1 // Copyright 2012 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.
11 type lookupStrings struct {
14 n int // bytes consumed from input
17 type LookupTest struct {
18 lookup []lookupStrings
23 var lookupTests = []LookupTest{
109 func lookup(c *contractTrieSet, nnode int, s []uint8) (i, n int) {
110 scan := c.scanner(0, nnode, s)
115 func TestLookupContraction(t *testing.T) {
116 for i, tt := range lookupTests {
117 cts := contractTrieSet(tt.tries)
118 for j, lu := range tt.lookup {
120 for _, s := range []string{str, str + "X"} {
121 const msg = `%d:%d: %s of "%s" %v; want %v`
122 offset, n := lookup(&cts, tt.n, []byte(s))
123 if offset != lu.offset {
124 t.Errorf(msg, i, j, "offset", s, offset, lu.offset)
127 t.Errorf(msg, i, j, "bytes consumed", s, n, len(str))