@@ -29,7 +29,9 @@ void testNextClearBit() {
2929
3030 Assertions .assertEquals (5000 , bs .nextClearBit (5000 ));
3131
32+ Assertions .assertTrue (bs .isEmpty ());
3233 bs .set (16 );
34+ Assertions .assertFalse (bs .isEmpty ());
3335
3436 Assertions .assertEquals (0 , bs .nextClearBit (0 ));
3537 Assertions .assertEquals (17 , bs .nextClearBit (16 ));
@@ -57,10 +59,12 @@ void testSetRange() {
5759 var bs = new AtomicBitSet (log2SegmentSize , CAPACITY );
5860
5961 Assertions .assertEquals (0 , bs .cardinality (), "BitSet should be empty initially" );
62+ Assertions .assertTrue (bs .isEmpty ());
6063
6164 bs .set (0 , NUM_BITS_TO_SET );
6265
6366 Assertions .assertEquals (NUM_BITS_TO_SET , bs .cardinality (), "BitSet should have " + NUM_BITS_TO_SET + " bits set" );
67+ Assertions .assertFalse (bs .isEmpty ());
6468
6569 for (int i = 0 ; i < NUM_BITS_TO_SET ; i ++) {
6670 Assertions .assertTrue (bs .get (i ), "Bit " + i + " should be set" );
@@ -74,6 +78,7 @@ void testClearRange() {
7478 var bs = new AtomicBitSet (log2SegmentSize , CAPACITY );
7579
7680 Assertions .assertEquals (0 , bs .cardinality (), "BitSet should be empty initially" );
81+ Assertions .assertTrue (bs .isEmpty ());
7782
7883 // Fill it halfway.
7984 bs .set (0 , NUM_BITS_TO_SET );
@@ -105,10 +110,12 @@ void testSmallRange() {
105110 // Just clear everything.
106111 bs .clear ();
107112 Assertions .assertEquals (0 , bs .cardinality (), "BitSet should be empty after clearing" );
113+ Assertions .assertTrue (bs .isEmpty ());
108114
109115 // Should only fill the single long.
110116 bs .set (0 , 64 );
111117 Assertions .assertEquals (64 , bs .cardinality (), "BitSet should have 64 bits set after setting all" );
118+ Assertions .assertFalse (bs .isEmpty ());
112119
113120 bs .clear (fromIndex , toIndex );
114121
@@ -124,16 +131,19 @@ void testBadInputs() {
124131
125132 Assertions .assertEquals (0 , bs .cardinality (), "set with negative should have no effect" );
126133 Assertions .assertEquals (64 , bs .currentCapacity (), "set with negative should have no effect" );
134+ Assertions .assertTrue (bs .isEmpty ());
127135
128136 bs .clear (Integer .MAX_VALUE );
129137
130138 Assertions .assertEquals (0 , bs .cardinality (), "clear with out of bounds index should have no effect" );
131139 Assertions .assertEquals (64 , bs .currentCapacity (), "clear with out of bounds index should have no effect" );
140+ Assertions .assertTrue (bs .isEmpty ());
132141
133142 bs .clear (-5 );
134143
135144 Assertions .assertEquals (0 , bs .cardinality (), "clear with negative index should have no effect" );
136145 Assertions .assertEquals (64 , bs .currentCapacity (), "clear with negative index should have no effect" );
146+ Assertions .assertTrue (bs .isEmpty ());
137147 }
138148
139149 @ Test
@@ -147,13 +157,16 @@ void testQuadraticInputs() {
147157 for (int toIndex = 0 ; toIndex < maxIndex ; toIndex ++) {
148158 bs .clear ();
149159
160+ Assertions .assertTrue (bs .isEmpty ());
150161 Assertions .assertEquals (0 , bs .cardinality ());
151162
152163 bs .set (fromIndex , toIndex );
153164
154165 if (toIndex <= fromIndex ) {
155166 Assertions .assertEquals (0 , bs .cardinality (), "Setting range with toIndex < fromIndex should not set any bits" );
167+ Assertions .assertTrue (bs .isEmpty ());
156168 } else {
169+ Assertions .assertFalse (bs .isEmpty ());
157170 assertRangeSet (bs , fromIndex , toIndex );
158171
159172 Assertions .assertEquals (toIndex - 1 , bs .maxSetBit ());
@@ -163,6 +176,7 @@ void testQuadraticInputs() {
163176
164177 // Now fill it completely and clear the range.
165178 bs .set (0 , maxIndex );
179+ Assertions .assertFalse (bs .isEmpty ());
166180
167181 assertRangeSet (bs , 0 , maxIndex );
168182
0 commit comments