From 2ed75832ba10d4d68375f53fcf3e07e055ea6b75 Mon Sep 17 00:00:00 2001 From: bandl <1658002533@qq.com> Date: Thu, 4 Nov 2021 16:32:17 +0800 Subject: [PATCH] test(structure-val): add perf test --- pkg/structure/value_test.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/pkg/structure/value_test.go b/pkg/structure/value_test.go index f0142d4..9ee011e 100644 --- a/pkg/structure/value_test.go +++ b/pkg/structure/value_test.go @@ -1,6 +1,7 @@ package structure import ( + "fmt" "strconv" "testing" @@ -126,4 +127,20 @@ func TestValue_SetByte(t *testing.T) { v, err = value.GetByte(10001) require.NoError(t, err) require.Equal(t, v, true) + require.Equal(t, value.GetSize(), (10001/8)+1+16) +} + +func TestValue_SetByteWei(t *testing.T) { + k := make([]byte, 100) + offset := 700 + k[offset/8] = 0b00000001 + k[offset/8] |= 0b1 << (offset % 8) + + fmt.Printf("%b\n", k[offset/8]) + + fmt.Printf("%v", (k[offset/8]&(0b1<<(offset%8))) != 0) + + k[offset/8] ^= 0b1 << (offset % 8) + + fmt.Printf("%v", (k[offset/8]&(0b1<<(offset%8))) != 0) }