mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-17 10:23:46 +00:00
Branches: main
Fix bitmap predicates which did not work correctly with empty bitmaps.
Note that `bitmap.to_string' now returns "<0:>" for an empty bitmap instead
of "<0:00>".
library/bitmap.m:
Add `in_range_rexcl' to check an index is in the range [0, num_bits).
Fix bounds checks on empty bitmaps in `^ bits' and `copy_bytes'.
Simplify other bounds checks using `in_range_rexcl'.
Make `byte_index_for_bit' return -1 if its argument is negative,
instead of 0. `byte_index_for_bit(NumBits - 1)' is used to get the
last byte index, so now loops over empty bitmaps will stop immediately
as the initial index must be greater than -1.
Make some code neater.
tests/hard_coded/Mmakefile:
tests/hard_coded/bitmap_empty.exp:
tests/hard_coded/bitmap_empty.m:
Add a test case.
NEWS:
Mention changed behaviour of `bitmap.to_string'.
69 lines
926 B
Plaintext
69 lines
926 B
Plaintext
-- new
|
|
"<0:>"
|
|
-- copy
|
|
"<0:>"
|
|
-- resize
|
|
"<0:>"
|
|
"<4:F0>"
|
|
"<0:>"
|
|
-- shrink_without_copying
|
|
"<0:>"
|
|
-- in_range
|
|
ok
|
|
ok
|
|
ok
|
|
-- byte_in_range
|
|
ok
|
|
ok
|
|
ok
|
|
-- num_bits
|
|
0
|
|
-- det_num_bytes
|
|
0
|
|
-- ^bit
|
|
expected: bitmap_error("bitmap.bit: index 0 is out of bounds [0 - 0).")
|
|
-- ^bits
|
|
0
|
|
-- ^bits:=
|
|
"<0:>"
|
|
-- ^byte
|
|
expected: bitmap_error("bitmap.byte: index 0 is out of bounds [0 - 0).")
|
|
-- ^byte:=
|
|
expected: bitmap_error("bitmap.\'byte :=\': index 0 is out of bounds [0 - 0).")
|
|
-- slice
|
|
slice_ctor("<0:>", 0, 0)
|
|
-- byte_slice
|
|
slice_ctor("<0:>", 0, 0)
|
|
-- flip
|
|
expected: bitmap_error("bitmap.flip: index 0 is out of bounds [0 - 0).")
|
|
-- complement
|
|
"<0:>"
|
|
-- union
|
|
"<0:>"
|
|
-- intersect
|
|
"<0:>"
|
|
-- difference
|
|
"<0:>"
|
|
-- xor
|
|
"<0:>"
|
|
-- append_list
|
|
"<2:C0>"
|
|
-- copy_bits
|
|
"<0:>"
|
|
-- copy_bits_in_bitmap
|
|
"<0:>"
|
|
-- copy_bytes
|
|
"<0:>"
|
|
-- copy_bytes_in_bitmap
|
|
"<0:>"
|
|
-- from_string
|
|
"<0:>"
|
|
-- to_byte_string
|
|
<>
|
|
-- hash
|
|
0
|
|
-- bitmap_equal
|
|
equal
|
|
-- bitmap_compare
|
|
'='
|