18a1362adSmaya/* 28a1362adSmaya * Copyright © 2019 Red Hat 38a1362adSmaya * 48a1362adSmaya * Permission is hereby granted, free of charge, to any person obtaining a 58a1362adSmaya * copy of this software and associated documentation files (the "Software"), 68a1362adSmaya * to deal in the Software without restriction, including without limitation 78a1362adSmaya * the rights to use, copy, modify, merge, publish, distribute, sublicense, 88a1362adSmaya * and/or sell copies of the Software, and to permit persons to whom the 98a1362adSmaya * Software is furnished to do so, subject to the following conditions: 108a1362adSmaya * 118a1362adSmaya * The above copyright notice and this permission notice (including the next 128a1362adSmaya * paragraph) shall be included in all copies or substantial portions of the 138a1362adSmaya * Software. 148a1362adSmaya * 158a1362adSmaya * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 168a1362adSmaya * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 178a1362adSmaya * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 188a1362adSmaya * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 198a1362adSmaya * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 208a1362adSmaya * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 218a1362adSmaya * IN THE SOFTWARE. 228a1362adSmaya */ 238a1362adSmaya 248a1362adSmaya#include <gtest/gtest.h> 258a1362adSmaya#include "util/bitset.h" 268a1362adSmaya 278a1362adSmayaTEST(bitset, sizes) 288a1362adSmaya{ 298a1362adSmaya EXPECT_EQ(sizeof(BITSET_WORD), 4); 308a1362adSmaya 318a1362adSmaya BITSET_DECLARE(mask32, 32); 328a1362adSmaya BITSET_DECLARE(mask64, 64); 338a1362adSmaya BITSET_DECLARE(mask128, 128); 348a1362adSmaya 358a1362adSmaya EXPECT_EQ(sizeof(mask32), 4); 368a1362adSmaya EXPECT_EQ(sizeof(mask64), 8); 378a1362adSmaya EXPECT_EQ(sizeof(mask128), 16); 388a1362adSmaya} 398a1362adSmaya 407ec681f3SmrgTEST(bitset, test_set_clear) 418a1362adSmaya{ 428a1362adSmaya BITSET_DECLARE(mask128, 128); 438a1362adSmaya BITSET_ZERO(mask128); 448a1362adSmaya 458a1362adSmaya for (int i = 0; i < 128; i++) { 468a1362adSmaya EXPECT_EQ(BITSET_TEST(mask128, i), false); 478a1362adSmaya BITSET_SET(mask128, i); 488a1362adSmaya EXPECT_EQ(BITSET_TEST(mask128, i), true); 498a1362adSmaya BITSET_CLEAR(mask128, i); 508a1362adSmaya EXPECT_EQ(BITSET_TEST(mask128, i), false); 518a1362adSmaya } 528a1362adSmaya} 538a1362adSmaya 547ec681f3SmrgTEST(bitset, test_set_ones) 558a1362adSmaya{ 568a1362adSmaya BITSET_DECLARE(mask128, 128); 578a1362adSmaya BITSET_ONES(mask128); 588a1362adSmaya 598a1362adSmaya EXPECT_EQ(BITSET_FFS(mask128), 1); 608a1362adSmaya 618a1362adSmaya for (int i = 0; i < 128; i++) { 628a1362adSmaya EXPECT_EQ(BITSET_TEST(mask128, i), true); 638a1362adSmaya BITSET_CLEAR(mask128, i); 648a1362adSmaya EXPECT_EQ(BITSET_TEST(mask128, i), false); 658a1362adSmaya BITSET_SET(mask128, i); 668a1362adSmaya EXPECT_EQ(BITSET_TEST(mask128, i), true); 678a1362adSmaya } 688a1362adSmaya} 698a1362adSmaya 707ec681f3SmrgTEST(bitset, test_basic_range) 718a1362adSmaya{ 728a1362adSmaya BITSET_DECLARE(mask128, 128); 738a1362adSmaya BITSET_ZERO(mask128); 748a1362adSmaya 758a1362adSmaya const int max_set = 15; 767ec681f3Smrg BITSET_SET_RANGE_INSIDE_WORD(mask128, 0, max_set); 778a1362adSmaya EXPECT_EQ(BITSET_TEST_RANGE(mask128, 0, max_set), true); 788a1362adSmaya EXPECT_EQ(BITSET_TEST_RANGE(mask128, max_set + 1, max_set + 15), false); 798a1362adSmaya for (int i = 0; i < 128; i++) { 808a1362adSmaya if (i <= max_set) 818a1362adSmaya EXPECT_EQ(BITSET_TEST(mask128, i), true); 828a1362adSmaya else 838a1362adSmaya EXPECT_EQ(BITSET_TEST(mask128, i), false); 848a1362adSmaya } 858a1362adSmaya BITSET_CLEAR_RANGE(mask128, 0, max_set); 868a1362adSmaya EXPECT_EQ(BITSET_TEST_RANGE(mask128, 0, max_set), false); 878a1362adSmaya for (int i = 0; i < 128; i++) { 888a1362adSmaya EXPECT_EQ(BITSET_TEST(mask128, i), false); 898a1362adSmaya } 908a1362adSmaya} 918a1362adSmaya 927ec681f3SmrgTEST(bitset, test_bitset_ffs) 938a1362adSmaya{ 948a1362adSmaya BITSET_DECLARE(mask128, 128); 958a1362adSmaya BITSET_ZERO(mask128); 968a1362adSmaya 978a1362adSmaya EXPECT_EQ(BITSET_FFS(mask128), 0); 988a1362adSmaya 998a1362adSmaya BITSET_SET(mask128, 14); 1008a1362adSmaya EXPECT_EQ(BITSET_FFS(mask128), 15); 1018a1362adSmaya 1028a1362adSmaya BITSET_SET(mask128, 28); 1038a1362adSmaya EXPECT_EQ(BITSET_FFS(mask128), 15); 1048a1362adSmaya 1058a1362adSmaya BITSET_CLEAR(mask128, 14); 1068a1362adSmaya EXPECT_EQ(BITSET_FFS(mask128), 29); 1078a1362adSmaya 1087ec681f3Smrg BITSET_SET_RANGE_INSIDE_WORD(mask128, 14, 18); 1098a1362adSmaya EXPECT_EQ(BITSET_FFS(mask128), 15); 1108a1362adSmaya} 1118a1362adSmaya 1127ec681f3SmrgTEST(bitset, test_range_bits) 1138a1362adSmaya{ 1148a1362adSmaya BITSET_DECLARE(mask128, 128); 1158a1362adSmaya BITSET_ZERO(mask128); 1168a1362adSmaya 1177ec681f3Smrg BITSET_SET_RANGE_INSIDE_WORD(mask128, 0, 31); 1187ec681f3Smrg BITSET_SET_RANGE_INSIDE_WORD(mask128, 32, 63); 1197ec681f3Smrg BITSET_SET_RANGE_INSIDE_WORD(mask128, 64, 95); 1207ec681f3Smrg BITSET_SET_RANGE_INSIDE_WORD(mask128, 96, 127); 1218a1362adSmaya 1228a1362adSmaya EXPECT_EQ(BITSET_TEST_RANGE(mask128, 0, 31), true); 1238a1362adSmaya EXPECT_EQ(BITSET_TEST_RANGE(mask128, 32, 63), true); 1248a1362adSmaya EXPECT_EQ(BITSET_TEST_RANGE(mask128, 64, 95), true); 1258a1362adSmaya EXPECT_EQ(BITSET_TEST_RANGE(mask128, 96, 127), true); 1268a1362adSmaya for (int i = 0; i < 128; i++) { 1278a1362adSmaya EXPECT_EQ(BITSET_TEST(mask128, i), true); 1288a1362adSmaya } 1298a1362adSmaya} 1307ec681f3Smrg 1317ec681f3SmrgTEST(bitset, test_and) 1327ec681f3Smrg{ 1337ec681f3Smrg BITSET_DECLARE(r, 128); 1347ec681f3Smrg BITSET_DECLARE(a, 128); 1357ec681f3Smrg BITSET_DECLARE(b, 128); 1367ec681f3Smrg BITSET_ZERO(r); 1377ec681f3Smrg BITSET_ZERO(a); 1387ec681f3Smrg BITSET_ZERO(b); 1397ec681f3Smrg 1407ec681f3Smrg BITSET_AND(r, a, b); 1417ec681f3Smrg EXPECT_EQ(BITSET_TEST_RANGE(r, 0, 31), false); 1427ec681f3Smrg EXPECT_EQ(BITSET_TEST_RANGE(r, 32, 63), false); 1437ec681f3Smrg EXPECT_EQ(BITSET_TEST_RANGE(r, 64, 95), false); 1447ec681f3Smrg EXPECT_EQ(BITSET_TEST_RANGE(r, 96, 127), false); 1457ec681f3Smrg 1467ec681f3Smrg 1477ec681f3Smrg BITSET_SET_RANGE_INSIDE_WORD(a, 32, 63); 1487ec681f3Smrg BITSET_SET_RANGE_INSIDE_WORD(b, 96, 127); 1497ec681f3Smrg BITSET_AND(r, a, b); 1507ec681f3Smrg 1517ec681f3Smrg EXPECT_EQ(BITSET_TEST_RANGE(r, 0, 31), false); 1527ec681f3Smrg EXPECT_EQ(BITSET_TEST_RANGE(r, 32, 63), false); 1537ec681f3Smrg EXPECT_EQ(BITSET_TEST_RANGE(r, 64, 95), false); 1547ec681f3Smrg EXPECT_EQ(BITSET_TEST_RANGE(r, 96, 127), false); 1557ec681f3Smrg 1567ec681f3Smrg 1577ec681f3Smrg BITSET_SET(a, 80); 1587ec681f3Smrg BITSET_SET(b, 80); 1597ec681f3Smrg BITSET_AND(r, a, b); 1607ec681f3Smrg 1617ec681f3Smrg EXPECT_EQ(BITSET_TEST(r, 80), true); 1627ec681f3Smrg 1637ec681f3Smrg EXPECT_EQ(BITSET_TEST_RANGE(r, 0, 31), false); 1647ec681f3Smrg EXPECT_EQ(BITSET_TEST_RANGE(r, 32, 63), false); 1657ec681f3Smrg EXPECT_EQ(BITSET_TEST_RANGE(r, 64, 95), true); 1667ec681f3Smrg EXPECT_EQ(BITSET_TEST_RANGE(r, 96, 127), false); 1677ec681f3Smrg} 1687ec681f3Smrg 1697ec681f3SmrgTEST(bitset, test_or) 1707ec681f3Smrg{ 1717ec681f3Smrg BITSET_DECLARE(r, 128); 1727ec681f3Smrg BITSET_DECLARE(a, 128); 1737ec681f3Smrg BITSET_DECLARE(b, 128); 1747ec681f3Smrg BITSET_ZERO(r); 1757ec681f3Smrg BITSET_ZERO(a); 1767ec681f3Smrg BITSET_ZERO(b); 1777ec681f3Smrg 1787ec681f3Smrg BITSET_OR(r, a, b); 1797ec681f3Smrg EXPECT_EQ(BITSET_TEST_RANGE(r, 0, 31), false); 1807ec681f3Smrg EXPECT_EQ(BITSET_TEST_RANGE(r, 32, 63), false); 1817ec681f3Smrg EXPECT_EQ(BITSET_TEST_RANGE(r, 64, 95), false); 1827ec681f3Smrg EXPECT_EQ(BITSET_TEST_RANGE(r, 96, 127), false); 1837ec681f3Smrg 1847ec681f3Smrg 1857ec681f3Smrg BITSET_SET_RANGE_INSIDE_WORD(a, 32, 63); 1867ec681f3Smrg BITSET_SET_RANGE_INSIDE_WORD(b, 96, 127); 1877ec681f3Smrg BITSET_OR(r, a, b); 1887ec681f3Smrg 1897ec681f3Smrg EXPECT_EQ(BITSET_TEST_RANGE(r, 0, 31), false); 1907ec681f3Smrg EXPECT_EQ(BITSET_TEST_RANGE(r, 32, 63), true); 1917ec681f3Smrg EXPECT_EQ(BITSET_TEST_RANGE(r, 64, 95), false); 1927ec681f3Smrg EXPECT_EQ(BITSET_TEST_RANGE(r, 96, 127), true); 1937ec681f3Smrg 1947ec681f3Smrg 1957ec681f3Smrg BITSET_SET(a, 80); 1967ec681f3Smrg BITSET_OR(r, a, b); 1977ec681f3Smrg EXPECT_EQ(BITSET_TEST(r, 80), true); 1987ec681f3Smrg 1997ec681f3Smrg BITSET_SET(b, 81); 2007ec681f3Smrg BITSET_OR(r, a, b); 2017ec681f3Smrg EXPECT_EQ(BITSET_TEST(r, 81), true); 2027ec681f3Smrg 2037ec681f3Smrg EXPECT_EQ(BITSET_TEST_RANGE(r, 0, 31), false); 2047ec681f3Smrg EXPECT_EQ(BITSET_TEST_RANGE(r, 32, 63), true); 2057ec681f3Smrg EXPECT_EQ(BITSET_TEST_RANGE(r, 64, 95), true); 2067ec681f3Smrg EXPECT_EQ(BITSET_TEST_RANGE(r, 96, 127), true); 2077ec681f3Smrg} 2087ec681f3Smrg 2097ec681f3SmrgTEST(bitset, test_not) 2107ec681f3Smrg{ 2117ec681f3Smrg BITSET_DECLARE(r, 128); 2127ec681f3Smrg BITSET_ZERO(r); 2137ec681f3Smrg 2147ec681f3Smrg EXPECT_EQ(BITSET_TEST_RANGE(r, 0, 31), false); 2157ec681f3Smrg EXPECT_EQ(BITSET_TEST_RANGE(r, 32, 63), false); 2167ec681f3Smrg EXPECT_EQ(BITSET_TEST_RANGE(r, 64, 95), false); 2177ec681f3Smrg EXPECT_EQ(BITSET_TEST_RANGE(r, 96, 127), false); 2187ec681f3Smrg 2197ec681f3Smrg BITSET_NOT(r); 2207ec681f3Smrg EXPECT_EQ(BITSET_TEST_RANGE(r, 0, 31), true); 2217ec681f3Smrg EXPECT_EQ(BITSET_TEST_RANGE(r, 32, 63), true); 2227ec681f3Smrg EXPECT_EQ(BITSET_TEST_RANGE(r, 64, 95), true); 2237ec681f3Smrg EXPECT_EQ(BITSET_TEST_RANGE(r, 96, 127), true); 2247ec681f3Smrg 2257ec681f3Smrg BITSET_CLEAR_RANGE(r, 32, 63); 2267ec681f3Smrg BITSET_NOT(r); 2277ec681f3Smrg EXPECT_EQ(BITSET_TEST_RANGE(r, 0, 31), false); 2287ec681f3Smrg EXPECT_EQ(BITSET_TEST_RANGE(r, 32, 63), true); 2297ec681f3Smrg EXPECT_EQ(BITSET_TEST_RANGE(r, 64, 95), false); 2307ec681f3Smrg EXPECT_EQ(BITSET_TEST_RANGE(r, 96, 127), false); 2317ec681f3Smrg} 2327ec681f3Smrg 2337ec681f3SmrgTEST(bitset, test_shr_zero) 2347ec681f3Smrg{ 2357ec681f3Smrg BITSET_DECLARE(r, 128); 2367ec681f3Smrg 2377ec681f3Smrg BITSET_ZERO(r); 2387ec681f3Smrg BITSET_SET(r, 127); 2397ec681f3Smrg 2407ec681f3Smrg BITSET_SHR(r, 0); 2417ec681f3Smrg 2427ec681f3Smrg EXPECT_EQ(BITSET_TEST(r, 127), true); 2437ec681f3Smrg EXPECT_EQ(BITSET_TEST_RANGE(r, 0, 31), false); 2447ec681f3Smrg EXPECT_EQ(BITSET_TEST_RANGE(r, 32, 63), false); 2457ec681f3Smrg EXPECT_EQ(BITSET_TEST_RANGE(r, 64, 95), false); 2467ec681f3Smrg EXPECT_EQ(BITSET_TEST_RANGE(r, 96, 127), true); 2477ec681f3Smrg} 2487ec681f3Smrg 2497ec681f3SmrgTEST(bitset, test_shl_zero) 2507ec681f3Smrg{ 2517ec681f3Smrg BITSET_DECLARE(r, 128); 2527ec681f3Smrg 2537ec681f3Smrg BITSET_ZERO(r); 2547ec681f3Smrg BITSET_SET(r, 0); 2557ec681f3Smrg 2567ec681f3Smrg BITSET_SHL(r, 0); 2577ec681f3Smrg 2587ec681f3Smrg EXPECT_EQ(BITSET_TEST(r, 0), true); 2597ec681f3Smrg EXPECT_EQ(BITSET_TEST_RANGE(r, 0, 31), true); 2607ec681f3Smrg EXPECT_EQ(BITSET_TEST_RANGE(r, 32, 63), false); 2617ec681f3Smrg EXPECT_EQ(BITSET_TEST_RANGE(r, 64, 95), false); 2627ec681f3Smrg EXPECT_EQ(BITSET_TEST_RANGE(r, 96, 127), false); 2637ec681f3Smrg} 2647ec681f3Smrg 2657ec681f3SmrgTEST(bitset, test_shr_walking_bit) 2667ec681f3Smrg{ 2677ec681f3Smrg BITSET_DECLARE(r, 128); 2687ec681f3Smrg 2697ec681f3Smrg BITSET_ZERO(r); 2707ec681f3Smrg BITSET_SET(r, 127); 2717ec681f3Smrg 2727ec681f3Smrg for (int i = 127; i >= 0; i--) { 2737ec681f3Smrg EXPECT_EQ(BITSET_TEST(r, i), true); 2747ec681f3Smrg BITSET_SHR(r, 1); 2757ec681f3Smrg } 2767ec681f3Smrg 2777ec681f3Smrg EXPECT_EQ(BITSET_TEST_RANGE(r, 0, 31), false); 2787ec681f3Smrg EXPECT_EQ(BITSET_TEST_RANGE(r, 32, 63), false); 2797ec681f3Smrg EXPECT_EQ(BITSET_TEST_RANGE(r, 64, 95), false); 2807ec681f3Smrg EXPECT_EQ(BITSET_TEST_RANGE(r, 96, 127), false); 2817ec681f3Smrg} 2827ec681f3Smrg 2837ec681f3SmrgTEST(bitset, test_shl_walking_bit) 2847ec681f3Smrg{ 2857ec681f3Smrg BITSET_DECLARE(r, 128); 2867ec681f3Smrg 2877ec681f3Smrg BITSET_ZERO(r); 2887ec681f3Smrg BITSET_SET(r, 0); 2897ec681f3Smrg 2907ec681f3Smrg for (unsigned int i = 0; i < 128; i++) { 2917ec681f3Smrg EXPECT_EQ(BITSET_TEST(r, i), true); 2927ec681f3Smrg BITSET_SHL(r, 1); 2937ec681f3Smrg } 2947ec681f3Smrg 2957ec681f3Smrg EXPECT_EQ(BITSET_TEST_RANGE(r, 0, 31), false); 2967ec681f3Smrg EXPECT_EQ(BITSET_TEST_RANGE(r, 32, 63), false); 2977ec681f3Smrg EXPECT_EQ(BITSET_TEST_RANGE(r, 64, 95), false); 2987ec681f3Smrg EXPECT_EQ(BITSET_TEST_RANGE(r, 96, 127), false); 2997ec681f3Smrg} 3007ec681f3Smrg 3017ec681f3SmrgTEST(bitset, test_shr_multiple_words) 3027ec681f3Smrg{ 3037ec681f3Smrg BITSET_DECLARE(r, 128); 3047ec681f3Smrg 3057ec681f3Smrg BITSET_ZERO(r); 3067ec681f3Smrg BITSET_SET(r, 127); 3077ec681f3Smrg BITSET_SHR(r, 50); 3087ec681f3Smrg 3097ec681f3Smrg EXPECT_EQ(BITSET_TEST(r, 127), false); 3107ec681f3Smrg EXPECT_EQ(BITSET_TEST(r, 77), true); 3117ec681f3Smrg 3127ec681f3Smrg 3137ec681f3Smrg BITSET_ZERO(r); 3147ec681f3Smrg BITSET_SET(r, 127); 3157ec681f3Smrg BITSET_SHR(r, 80); 3167ec681f3Smrg 3177ec681f3Smrg EXPECT_EQ(BITSET_TEST(r, 127), false); 3187ec681f3Smrg EXPECT_EQ(BITSET_TEST(r, 47), true); 3197ec681f3Smrg 3207ec681f3Smrg 3217ec681f3Smrg BITSET_ZERO(r); 3227ec681f3Smrg BITSET_SET(r, 127); 3237ec681f3Smrg BITSET_SHR(r, 126); 3247ec681f3Smrg 3257ec681f3Smrg EXPECT_EQ(BITSET_TEST(r, 127), false); 3267ec681f3Smrg EXPECT_EQ(BITSET_TEST(r, 1), true); 3277ec681f3Smrg} 3287ec681f3Smrg 3297ec681f3SmrgTEST(bitset, test_shl_multiple_words) 3307ec681f3Smrg{ 3317ec681f3Smrg BITSET_DECLARE(r, 128); 3327ec681f3Smrg 3337ec681f3Smrg BITSET_ZERO(r); 3347ec681f3Smrg BITSET_SET(r, 0); 3357ec681f3Smrg BITSET_SHL(r, 50); 3367ec681f3Smrg 3377ec681f3Smrg EXPECT_EQ(BITSET_TEST(r, 0), false); 3387ec681f3Smrg EXPECT_EQ(BITSET_TEST(r, 50), true); 3397ec681f3Smrg 3407ec681f3Smrg 3417ec681f3Smrg BITSET_ZERO(r); 3427ec681f3Smrg BITSET_SET(r, 0); 3437ec681f3Smrg BITSET_SHL(r, 80); 3447ec681f3Smrg 3457ec681f3Smrg EXPECT_EQ(BITSET_TEST(r, 0), false); 3467ec681f3Smrg EXPECT_EQ(BITSET_TEST(r, 80), true); 3477ec681f3Smrg 3487ec681f3Smrg 3497ec681f3Smrg BITSET_ZERO(r); 3507ec681f3Smrg BITSET_SET(r, 0); 3517ec681f3Smrg BITSET_SHL(r, 126); 3527ec681f3Smrg 3537ec681f3Smrg EXPECT_EQ(BITSET_TEST(r, 0), false); 3547ec681f3Smrg EXPECT_EQ(BITSET_TEST(r, 126), true); 3557ec681f3Smrg} 3567ec681f3Smrg 3577ec681f3SmrgTEST(bitset, test_shr_two_words) 3587ec681f3Smrg{ 3597ec681f3Smrg BITSET_DECLARE(r, 64); 3607ec681f3Smrg 3617ec681f3Smrg BITSET_ZERO(r); 3627ec681f3Smrg BITSET_SET(r, 63); 3637ec681f3Smrg BITSET_SHR(r, 50); 3647ec681f3Smrg 3657ec681f3Smrg EXPECT_EQ(BITSET_TEST(r, 63), false); 3667ec681f3Smrg EXPECT_EQ(BITSET_TEST(r, 13), true); 3677ec681f3Smrg EXPECT_EQ(BITSET_TEST_RANGE(r, 0, 31), true); 3687ec681f3Smrg EXPECT_EQ(BITSET_TEST_RANGE(r, 32, 63), false); 3697ec681f3Smrg} 3707ec681f3Smrg 3717ec681f3SmrgTEST(bitset, test_shl_two_words) 3727ec681f3Smrg{ 3737ec681f3Smrg BITSET_DECLARE(r, 64); 3747ec681f3Smrg 3757ec681f3Smrg BITSET_ZERO(r); 3767ec681f3Smrg BITSET_SET(r, 0); 3777ec681f3Smrg BITSET_SHL(r, 50); 3787ec681f3Smrg 3797ec681f3Smrg EXPECT_EQ(BITSET_TEST(r, 0), false); 3807ec681f3Smrg EXPECT_EQ(BITSET_TEST(r, 50), true); 3817ec681f3Smrg EXPECT_EQ(BITSET_TEST_RANGE(r, 0, 31), false); 3827ec681f3Smrg EXPECT_EQ(BITSET_TEST_RANGE(r, 32, 63), true); 3837ec681f3Smrg} 3847ec681f3Smrg 3857ec681f3SmrgTEST(bitset, test_setrange_across_word_boundary) 3867ec681f3Smrg{ 3877ec681f3Smrg BITSET_DECLARE(r, 128); 3887ec681f3Smrg BITSET_ZERO(r); 3897ec681f3Smrg 3907ec681f3Smrg BITSET_SET_RANGE(r, 62, 65); 3917ec681f3Smrg 3927ec681f3Smrg EXPECT_EQ(BITSET_TEST_RANGE(r, 0, 31), false); 3937ec681f3Smrg EXPECT_EQ(BITSET_TEST_RANGE(r, 32, 63), true); 3947ec681f3Smrg EXPECT_EQ(BITSET_TEST_RANGE(r, 64, 95), true); 3957ec681f3Smrg EXPECT_EQ(BITSET_TEST_RANGE(r, 96, 127), false); 3967ec681f3Smrg 3977ec681f3Smrg EXPECT_EQ(BITSET_TEST(r, 61), false); 3987ec681f3Smrg 3997ec681f3Smrg for (int i = 62; i <= 65; i++) 4007ec681f3Smrg EXPECT_EQ(BITSET_TEST(r, i), true); 4017ec681f3Smrg 4027ec681f3Smrg EXPECT_EQ(BITSET_TEST(r, 66), false); 4037ec681f3Smrg} 404