| 1 |
// Copyright (C) 2020-2025 Free Software Foundation, Inc. |
| 2 |
// |
| 3 |
// This file is part of the GNU ISO C++ Library. This library is free |
| 4 |
// software; you can redistribute it and/or modify it under the |
| 5 |
// terms of the GNU General Public License as published by the |
| 6 |
// Free Software Foundation; either version 3, or (at your option) |
| 7 |
// any later version. |
| 8 |
// |
| 9 |
// This library is distributed in the hope that it will be useful, |
| 10 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 |
// GNU General Public License for more details. |
| 13 |
// |
| 14 |
// You should have received a copy of the GNU General Public License along |
| 15 |
// with this library; see the file COPYING3. If not see |
| 16 |
// <http://www.gnu.org/licenses/>. |
| 17 |
|
| 18 |
// expensive: * [1-9] * * |
| 19 |
#include "bits/main.h" |
| 20 |
|
| 21 |
template <typename V> |
| 22 |
void |
| 23 |
test() |
| 24 |
{ |
| 25 |
using M = typename V::mask_type; |
| 26 |
{ // compares |
| 27 |
M x(true), y(false); |
| 28 |
VERIFY(all_of(x == x)); |
| 29 |
VERIFY(all_of(x != y)); |
| 30 |
VERIFY(all_of(y != x)); |
| 31 |
VERIFY(!all_of(x != x)); |
| 32 |
VERIFY(!all_of(x == y)); |
| 33 |
VERIFY(!all_of(y == x)); |
| 34 |
} |
| 35 |
{ // subscripting |
| 36 |
M x(true); |
| 37 |
for (std::size_t i = 0; i < M::size(); ++i) |
| 38 |
{ |
| 39 |
COMPARE(x[i], true) << "\nx: " << x << ", i: " << i; |
| 40 |
x[i] = !x[i]; |
| 41 |
} |
| 42 |
COMPARE(x, M{false}); |
| 43 |
for (std::size_t i = 0; i < M::size(); ++i) |
| 44 |
{ |
| 45 |
COMPARE(x[i], false) << "\nx: " << x << ", i: " << i; |
| 46 |
x[i] = !x[i]; |
| 47 |
} |
| 48 |
COMPARE(x, M{true}); |
| 49 |
} |
| 50 |
{ // negation |
| 51 |
M x(false); |
| 52 |
M y = !x; |
| 53 |
COMPARE(y, M{true}); |
| 54 |
COMPARE(!y, x); |
| 55 |
} |
| 56 |
} |
| 57 |
|