1 //===----------------------------------------------------------------------===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 // test bitset<N>& set(size_t pos, bool val = true); 10 11 #include <bitset> 12 #include <cassert> 13 #include <cstddef> 14 #include <vector> 15 16 #include "../bitset_test_cases.h" 17 #include "test_macros.h" 18 19 template <std::size_t N> test_set_one()20void test_set_one() { 21 std::vector<std::bitset<N> > const cases = get_test_cases<N>(); 22 for (std::size_t c = 0; c != cases.size(); ++c) { 23 std::bitset<N> v = cases[c]; 24 if (v.size() > 0) { 25 std::size_t middle = v.size() / 2; 26 v.set(middle); 27 assert(v[middle] == true); 28 v.set(middle, false); 29 assert(v[middle] == false); 30 } 31 } 32 } 33 main(int,char **)34int main(int, char**) { 35 test_set_one<0>(); 36 test_set_one<1>(); 37 test_set_one<31>(); 38 test_set_one<32>(); 39 test_set_one<33>(); 40 test_set_one<63>(); 41 test_set_one<64>(); 42 test_set_one<65>(); 43 test_set_one<1000>(); 44 45 return 0; 46 } 47