test(structure-val): add perf test

This commit is contained in:
bandl 2021-11-04 16:32:17 +08:00
parent 0f1142d434
commit 2ed75832ba
1 changed files with 17 additions and 0 deletions

View File

@ -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)
}