1
0
mirror of https://github.com/fumiama/unibase2n.git synced 2026-06-13 05:30:24 +08:00

finish dec128blk1

This commit is contained in:
源文雨
2022-10-01 15:30:15 +08:00
parent 08228b7a61
commit aff58aa75e
5 changed files with 113 additions and 3 deletions

View File

@@ -11,6 +11,7 @@ func TestUint128be(t *testing.T) {
zero := readuint128be(make([]byte, 16))
one := readuint128be([]byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1})
num := readuint128be(buf[:])
assert.Equal(t, zero.sub(one), num)
num.addeq(one)
assert.Equal(t, num, zero)
num.addeq(readuint128be([]byte{0x12, 0x34, 0x56, 0x78, 0x90, 0xab, 0xcd, 0xef, 0x12, 0x34, 0x56, 0x78, 0x90, 0xab, 0xcd, 0xef}))
@@ -22,7 +23,9 @@ func TestUint128be(t *testing.T) {
num.shreq(32)
assert.Equal(t, num, uint128be{0x0000000000000012, 0x34567890abcdef12})
assert.Equal(t, num.String(), "0x1234567890abcdef12")
num.shreq(1)
num.shleq(8)
assert.Equal(t, num, uint128be{0x00000000000001234, 0x567890abcdef1200})
num.shreq(9)
// 因为 num.a 低 1 位为 0 所以可以成功
assert.Equal(t, num, uint128be{0x0000000000000012 >> 1, 0x34567890abcdef12 >> 1})
num.shreq(7)