gitee.com/quant1x/engine@v1.8.4/rules/rule_test.go (about) 1 package rules 2 3 import ( 4 "fmt" 5 "github.com/bits-and-blooms/bitset" 6 "testing" 7 ) 8 9 func TestRule(t *testing.T) { 10 fmt.Printf("Hello from BitSet!\n") 11 var b bitset.BitSet 12 //// play some Go Fish 13 //for i := 0; i < 100; i++ { 14 // card1 := uint(rand.Intn(52)) 15 // card2 := uint(rand.Intn(52)) 16 // b.Set(card1) 17 // if b.Test(card2) { 18 // fmt.Println("Go Fish!") 19 // } 20 // b.Clear(card1) 21 //} 22 23 // Chaining 24 b.Set(10).Set(11).Set(1000) 25 26 for i, e := b.NextSet(0); e; i, e = b.NextSet(i + 1) { 27 fmt.Println("The following bit is set:", i) 28 } 29 if b.Intersection(bitset.New(100).Set(10)).Count() == 1 { 30 fmt.Println("Intersection works.") 31 } else { 32 fmt.Println("Intersection doesn't work???") 33 } 34 text := b.String() 35 fmt.Println(text) 36 }