Skip to content

Commit

Permalink
Fix the possible loss of precision when the key is Uint64 or Int64
Browse files Browse the repository at this point in the history
  • Loading branch information
jdhxyy committed Mar 18, 2021
1 parent fff3edf commit 696c652
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions skiplist_test.go
Expand Up @@ -388,3 +388,31 @@ func assertSanity(a *assert.A, list *SkipList) {
}
}
}

func TestUint64(t *testing.T) {
a := assert.New(t)
list := New(Uint64)
a.Assert(list.Len() == 0)

elem1 := list.Set(uint64(0xF141000000000404), "uint64-404")
a.Assert(elem1 != nil)
elem2 := list.Set(uint64(0xF141000000000405), "uint64-405")
a.Assert(elem2 != nil)

a.Assert(list.Get(uint64(0xF141000000000404)).Value == "uint64-404")
a.Assert(list.Get(uint64(0xF141000000000405)).Value == "uint64-405")
}

func TestInt64(t *testing.T) {
a := assert.New(t)
list := New(Int64)
a.Assert(list.Len() == 0)

elem1 := list.Set(int64(0x2141000000000404), "int64-404")
a.Assert(elem1 != nil)
elem2 := list.Set(int64(0x2141000000000405), "int64-405")
a.Assert(elem2 != nil)

a.Assert(list.Get(int64(0x2141000000000404)).Value == "int64-404")
a.Assert(list.Get(int64(0x2141000000000405)).Value == "int64-405")
}

0 comments on commit 696c652

Please sign in to comment.