(t *testing.T)
| 24 | ) |
| 25 | |
| 26 | func TestBitOperations(t *testing.T) { |
| 27 | ba := newBitArray(10) |
| 28 | |
| 29 | err := ba.SetBit(5) |
| 30 | if err != nil { |
| 31 | t.Fatal(err) |
| 32 | } |
| 33 | |
| 34 | result, err := ba.GetBit(5) |
| 35 | if err != nil { |
| 36 | t.Fatal(err) |
| 37 | } |
| 38 | if !result { |
| 39 | t.Errorf(`Expected true at position: %d`, 5) |
| 40 | } |
| 41 | |
| 42 | result, err = ba.GetBit(3) |
| 43 | if err != nil { |
| 44 | t.Fatal(err) |
| 45 | } |
| 46 | |
| 47 | if result { |
| 48 | t.Errorf(`Expected false at position %d`, 3) |
| 49 | } |
| 50 | |
| 51 | err = ba.ClearBit(5) |
| 52 | if err != nil { |
| 53 | t.Fatal(err) |
| 54 | } |
| 55 | |
| 56 | result, err = ba.GetBit(5) |
| 57 | if err != nil { |
| 58 | t.Fatal(err) |
| 59 | } |
| 60 | |
| 61 | if result { |
| 62 | t.Errorf(`Expected false at position: %d`, 5) |
| 63 | } |
| 64 | |
| 65 | ba = newBitArray(24) |
| 66 | err = ba.SetBit(16) |
| 67 | if err != nil { |
| 68 | t.Fatal(err) |
| 69 | } |
| 70 | |
| 71 | result, err = ba.GetBit(16) |
| 72 | if err != nil { |
| 73 | t.Fatal(err) |
| 74 | } |
| 75 | |
| 76 | if !result { |
| 77 | t.Errorf(`Expected true at position: %d`, 16) |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | func TestDuplicateOperation(t *testing.T) { |
| 82 | ba := newBitArray(10) |
nothing calls this directly
no test coverage detected
searching dependent graphs…