+2020-11-29 Akim Demaille <akim@lrde.epita.fr>
+
+ bitset: tests: check BITSET_FOR_EACH_REVERSE
+ * tests/test-bitset.c (compare, check_zero, check_one_bit, check_ones):
+ Check BITSET_FOR_EACH_REVERSE.
+
2020-11-29 Bruno Haible <bruno@clisp.org>
spawn-pipe tests: Fix test failure with MSVC.
}
}
+ /* FOR_EACH_REVERSE. */
+ {
+ bitset_iterator iter;
+ bitset_bindex j;
+ bitset_bindex first = bitset_first (bdst);
+ bitset_bindex last = bitset_last (bdst);
+ bool seen_first = false;
+ bool seen_last = false;
+ BITSET_FOR_EACH_REVERSE (iter, bdst, j, 0)
+ {
+ ASSERT (first <= j && j <= last);
+ ASSERT (bitset_test (bdst, j));
+ if (j == first)
+ seen_first = true;
+ if (j == last)
+ seen_last = true;
+ }
+ if (first == BITSET_BINDEX_MAX)
+ {
+ ASSERT (!seen_first);
+ ASSERT (!seen_last);
+ }
+ else
+ {
+ ASSERT (seen_first);
+ ASSERT (seen_last);
+ }
+ }
+
+
/* resize.
ARRAY bitsets cannot be resized. */
bitset_bindex i;
BITSET_FOR_EACH (iter, bs, i, 0)
ASSERT (0);
+ BITSET_FOR_EACH_REVERSE (iter, bs, i, 0)
+ ASSERT (0);
}
}
bitset_bindex i;
BITSET_FOR_EACH (iter, bs, i, 0)
ASSERT (i == bitno);
+
+ BITSET_FOR_EACH_REVERSE (iter, bs, i, 0)
+ ASSERT (i == bitno);
}
}
bitset_bindex count = 0;
BITSET_FOR_EACH (iter, bs, i, 0)
ASSERT (i == count++);
+ ASSERT (count == size);
+ BITSET_FOR_EACH_REVERSE (iter, bs, i, 0)
+ ASSERT (i == --count);
+ ASSERT (count == 0);
}
}