@@ -394,6 +394,38 @@ func FuzzModification(f *testing.F) {
394394 })
395395}
396396
397+ func FuzzSelect (f * testing.F ) {
398+ // Add seed corpus
399+ f .Add ([]byte {0xFF , 0x00 }, uint (0 ))
400+ f .Add ([]byte {0x0F , 0xF0 }, uint (4 ))
401+ f .Add ([]byte {0xAA , 0x55 }, uint (7 ))
402+
403+ f .Fuzz (func (t * testing.T , data []byte , j uint ) {
404+ if len (data ) == 0 || len (data ) > maxBytes {
405+ return
406+ }
407+
408+ // Convert byte data to bit positions
409+ b := New (0 )
410+ var rawBits []uint
411+ for i , byt := range data {
412+ for bit := 0 ; bit < 8 ; bit ++ {
413+ if byt & (1 << bit ) != 0 {
414+ b .Set (uint (i * 8 + bit ))
415+ rawBits = append (rawBits , uint (i * 8 + bit ))
416+ }
417+ }
418+ }
419+
420+ for bitIdx , bitPos := range rawBits {
421+ actualBitPos := b .Select (uint (bitIdx ))
422+ if bitPos != actualBitPos {
423+ t .Errorf ("Select(%d) failed: expected %d, got %d" , bitIdx , bitPos , actualBitPos )
424+ }
425+ }
426+ })
427+ }
428+
397429// FuzzCopy tests clone and copy operations
398430func FuzzCopy (f * testing.F ) {
399431 // Add seed corpus
@@ -519,7 +551,7 @@ func FuzzSerialization(f *testing.F) {
519551// FuzzRandomOperations performs random sequences of operations
520552func FuzzRandomOperations (f * testing.F ) {
521553 // Add seed corpus
522- f .Add ([]byte {1 , 2 , 3 , 4 , 5 }) // operations: 0=Set, 1=Clear, 2=Flip, 3=Test, 4=Count
554+ f .Add ([]byte {1 , 2 , 3 , 4 , 5 , 6 , 7 }) // operations: 0=Set, 1=Clear, 2=Flip, 3=Test, 4=Count, 5=NextSet, 6=PreviousSet, 7=Select
523555 f .Add ([]byte {1 , 1 , 1 , 4 , 5 })
524556 f .Add ([]byte {2 , 2 , 2 , 4 , 5 })
525557
@@ -566,6 +598,12 @@ func FuzzRandomOperations(f *testing.F) {
566598
567599 case 5 : // NextSet - just ensure it doesn't panic
568600 _ , _ = b .NextSet (pos )
601+
602+ case 6 : // PreviousSet - just ensure it doesn't panic
603+ _ , _ = b .PreviousSet (pos )
604+
605+ case 7 : // Select - just ensure it doesn't panic
606+ _ = b .Select (pos )
569607 }
570608 }
571609
0 commit comments