gitee.com/quant1x/engine@v1.8.4/labs/bitmap_test.go (about)

     1  package labs
     2  
     3  import (
     4  	"fmt"
     5  	"testing"
     6  )
     7  
     8  func TestBitmap(t *testing.T) {
     9  	array := [...]uint64{0, 6, 3, 7, 2, 8, 1, 4}
    10  
    11  	var maxNum uint64 = 9
    12  	bm := NewBitmap(maxNum)
    13  
    14  	for _, v := range array {
    15  		bm.Set(v)
    16  	}
    17  	bm.Set(5)
    18  	bm.Set(17)
    19  	fmt.Println(bm.IsFully())
    20  	fmt.Println(bm.IsEmpty())
    21  	fmt.Println("bitmap 中存在的数字:")
    22  	fmt.Println(bm.GetData())
    23  	fmt.Println("bitmap 中的二进制串")
    24  	fmt.Println(bm.String())
    25  	fmt.Println("bitmap 中的数字个数:", bm.Count())
    26  	fmt.Println("bitmap size:", bm.Size())
    27  	fmt.Println("Test(0):", bm.Test(0))
    28  	bm.Reset(5)
    29  	fmt.Println(bm.String())
    30  	fmt.Println("Test(5):", bm.Test(5))
    31  	fmt.Println(bm.GetData())
    32  }