@@ -27,7 +27,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2727package dtrie
2828
2929import (
30- "fmt"
3130 "testing"
3231
3332 "github.com/stretchr/testify/assert"
@@ -40,28 +39,6 @@ func TestDefaultHasher(t *testing.T) {
4039 assert .NotEqual (t , defaultHasher ("foo" ), defaultHasher ("bar" ))
4140}
4241
43- type testEntry struct {
44- hash uint32
45- key int
46- value int
47- }
48-
49- func (e * testEntry ) KeyHash () uint32 {
50- return e .hash
51- }
52-
53- func (e * testEntry ) Key () interface {} {
54- return e .key
55- }
56-
57- func (e * testEntry ) Value () interface {} {
58- return e .value
59- }
60-
61- func (e * testEntry ) String () string {
62- return fmt .Sprint (e .value )
63- }
64-
6542func collisionHash (key interface {}) uint32 {
6643 return uint32 (0xffffffff ) // for testing collisions
6744}
@@ -74,7 +51,7 @@ func TestInsert(t *testing.T) {
7451func insertTest (t * testing.T , hashfunc func (interface {}) uint32 , count int ) * node {
7552 n := emptyNode (0 , 32 )
7653 for i := 0 ; i < count ; i ++ {
77- n = insert (n , & testEntry {hashfunc (i ), i , i })
54+ n = insert (n , & entry {hashfunc (i ), i , i })
7855 }
7956 return n
8057}
@@ -117,7 +94,7 @@ func TestUpdate(t *testing.T) {
11794func updateTest (t * testing.T , hashfunc func (interface {}) uint32 , count int ) {
11895 n := insertTest (t , hashfunc , count )
11996 for i := 0 ; i < count ; i ++ {
120- n = insert (n , & testEntry {hashfunc (i ), i , - i })
97+ n = insert (n , & entry {hashfunc (i ), i , - i })
12198 }
12299}
123100
@@ -161,7 +138,7 @@ func BenchmarkInsert(b *testing.B) {
161138 n := emptyNode (0 , 32 )
162139 b .ResetTimer ()
163140 for i := b .N ; i > 0 ; i -- {
164- n = insert (n , & testEntry {defaultHasher (i ), i , i })
141+ n = insert (n , & entry {defaultHasher (i ), i , i })
165142 }
166143}
167144
@@ -188,6 +165,6 @@ func BenchmarkUpdate(b *testing.B) {
188165 n := insertTest (nil , defaultHasher , b .N )
189166 b .ResetTimer ()
190167 for i := b .N ; i > 0 ; i -- {
191- n = insert (n , & testEntry {defaultHasher (i ), i , - i })
168+ n = insert (n , & entry {defaultHasher (i ), i , - i })
192169 }
193170}
0 commit comments