diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-15 03:35:49 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-15 03:35:49 +0000 |
commit | d8bbc7858622b6d9c278469aab701ca0b609cddf (patch) | |
tree | eff41dc61d9f714852212739e6b3738b82a2af87 /js/src/jsapi-tests/testSparseBitmap.cpp | |
parent | Releasing progress-linux version 125.0.3-1~progress7.99u1. (diff) | |
download | firefox-d8bbc7858622b6d9c278469aab701ca0b609cddf.tar.xz firefox-d8bbc7858622b6d9c278469aab701ca0b609cddf.zip |
Merging upstream version 126.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/jsapi-tests/testSparseBitmap.cpp')
-rw-r--r-- | js/src/jsapi-tests/testSparseBitmap.cpp | 47 |
1 files changed, 46 insertions, 1 deletions
diff --git a/js/src/jsapi-tests/testSparseBitmap.cpp b/js/src/jsapi-tests/testSparseBitmap.cpp index bd5e7fee95..936132ab0c 100644 --- a/js/src/jsapi-tests/testSparseBitmap.cpp +++ b/js/src/jsapi-tests/testSparseBitmap.cpp @@ -111,5 +111,50 @@ BEGIN_TEST(testSparseBitmapExternalOR) { return true; } - END_TEST(testSparseBitmapExternalOR) + +BEGIN_TEST(testSparseBitmapExternalAND) { + // Testing ANDing data from an external array. + + const size_t wordCount = 4; + + // Create a bitmap with two bits set per word based on the word index. + SparseBitmap bitmap; + for (size_t i = 0; i < wordCount; i++) { + bitmap.setBit(i * JS_BITS_PER_WORD + i); + bitmap.setBit(i * JS_BITS_PER_WORD + i + 1); + } + + // Update a single word, clearing one of the bits. + uintptr_t source[wordCount]; + CHECK(bitmap.getBit(0)); + CHECK(bitmap.getBit(1)); + source[0] = ~(1 << 1); + bitmap.bitwiseAndRangeWith(0, 1, source); + CHECK(bitmap.getBit(0)); + CHECK(!bitmap.getBit(1)); + + // Update a word at an offset. + CHECK(bitmap.getBit(JS_BITS_PER_WORD + 1)); + CHECK(bitmap.getBit(JS_BITS_PER_WORD + 2)); + source[0] = ~(1 << 2); + bitmap.bitwiseAndRangeWith(1, 1, source); + CHECK(bitmap.getBit(JS_BITS_PER_WORD + 1)); + CHECK(!bitmap.getBit(JS_BITS_PER_WORD + 2)); + + // Update multiple words at an offset. + CHECK(bitmap.getBit(JS_BITS_PER_WORD * 2 + 2)); + CHECK(bitmap.getBit(JS_BITS_PER_WORD * 2 + 3)); + CHECK(bitmap.getBit(JS_BITS_PER_WORD * 3 + 3)); + CHECK(bitmap.getBit(JS_BITS_PER_WORD * 3 + 4)); + source[0] = ~(1 << 3); + source[1] = ~(1 << 4); + bitmap.bitwiseAndRangeWith(2, 2, source); + CHECK(bitmap.getBit(JS_BITS_PER_WORD * 2 + 2)); + CHECK(!bitmap.getBit(JS_BITS_PER_WORD * 2 + 3)); + CHECK(bitmap.getBit(JS_BITS_PER_WORD * 3 + 3)); + CHECK(!bitmap.getBit(JS_BITS_PER_WORD * 3 + 4)); + + return true; +} +END_TEST(testSparseBitmapExternalAND) |