mirror of
https://github.com/BlackMATov/enum.hpp.git
synced 2025-12-13 06:59:45 +07:00
@@ -1,28 +0,0 @@
|
||||
image:
|
||||
- Visual Studio 2017
|
||||
- Visual Studio 2019
|
||||
|
||||
platform:
|
||||
- x86
|
||||
- x64
|
||||
|
||||
configuration:
|
||||
- Release
|
||||
|
||||
for:
|
||||
|
||||
-
|
||||
matrix:
|
||||
only:
|
||||
- platform: x86
|
||||
configuration: Release
|
||||
build_script:
|
||||
- .ci\build_windows_x86.bat
|
||||
|
||||
-
|
||||
matrix:
|
||||
only:
|
||||
- platform: x64
|
||||
configuration: Release
|
||||
build_script:
|
||||
- .ci\build_windows_x64.bat
|
||||
14
.github/workflows/coverage.yml
vendored
Normal file
14
.github/workflows/coverage.yml
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
name: coverage
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: macos-10.15
|
||||
name: "coverage"
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Install lcov by Homebrew
|
||||
run: brew install lcov
|
||||
- name: Build && Test && Upload
|
||||
run: .ci/build_coverage.sh
|
||||
22
.github/workflows/darwin.yml
vendored
Normal file
22
.github/workflows/darwin.yml
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
name: darwin
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ${{matrix.config.os}}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
config:
|
||||
# https://github.com/actions/virtual-environments/tree/main/images/macos
|
||||
- { os: "macos-10.15", xcode: "10.3" }
|
||||
- { os: "macos-10.15", xcode: "11.7" }
|
||||
- { os: "macos-10.15", xcode: "12.4" }
|
||||
name: "xcode-${{matrix.config.xcode}}"
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Select Xcode
|
||||
run: sudo xcode-select --switch "/Applications/Xcode_${{matrix.config.xcode}}.app"
|
||||
- name: Build && Test
|
||||
run: .ci/build_darwin.sh
|
||||
31
.github/workflows/linux.yml
vendored
Normal file
31
.github/workflows/linux.yml
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
name: linux
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ${{matrix.config.os}}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
config:
|
||||
# https://github.com/actions/virtual-environments/tree/main/images/linux
|
||||
- { os: "ubuntu-18.04", cc: "gcc-7", cxx: "g++-7" }
|
||||
- { os: "ubuntu-18.04", cc: "gcc-8", cxx: "g++-8" }
|
||||
- { os: "ubuntu-18.04", cc: "gcc-9", cxx: "g++-9" }
|
||||
- { os: "ubuntu-18.04", cc: "gcc-10", cxx: "g++-10" }
|
||||
- { os: "ubuntu-18.04", cc: "clang-5.0", cxx: "clang++-5.0" }
|
||||
- { os: "ubuntu-18.04", cc: "clang-6.0", cxx: "clang++-6.0" }
|
||||
- { os: "ubuntu-18.04", cc: "clang-7", cxx: "clang++-7" }
|
||||
- { os: "ubuntu-18.04", cc: "clang-8", cxx: "clang++-8" }
|
||||
- { os: "ubuntu-18.04", cc: "clang-9", cxx: "clang++-9" }
|
||||
- { os: "ubuntu-18.04", cc: "clang-10", cxx: "clang++-10" }
|
||||
name: "${{matrix.config.cxx}}"
|
||||
steps:
|
||||
- name: Setup
|
||||
run: sudo apt-get -y install "${{matrix.config.cc}}" "${{matrix.config.cxx}}"
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
- name: Build && Test
|
||||
run: .ci/build_linux.sh
|
||||
env: { CC: "${{matrix.config.cc}}", CXX: "${{matrix.config.cxx}}" }
|
||||
21
.github/workflows/windows.yml
vendored
Normal file
21
.github/workflows/windows.yml
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
name: windows
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ${{matrix.config.os}}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
config:
|
||||
# https://github.com/actions/virtual-environments/tree/main/images/win
|
||||
- { os: "windows-2016", vs: "Visual Studio 2017", arch: "x86" }
|
||||
- { os: "windows-2016", vs: "Visual Studio 2017", arch: "x64" }
|
||||
- { os: "windows-2019", vs: "Visual Studio 2019", arch: "x86" }
|
||||
- { os: "windows-2019", vs: "Visual Studio 2019", arch: "x64" }
|
||||
name: "${{matrix.config.vs}} ${{matrix.config.arch}}"
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Build && Test
|
||||
run: .ci\build_windows_${{matrix.config.arch}}.bat
|
||||
89
.travis.yml
89
.travis.yml
@@ -1,89 +0,0 @@
|
||||
git:
|
||||
depth: false
|
||||
quiet: true
|
||||
|
||||
language: cpp
|
||||
|
||||
jobs:
|
||||
include:
|
||||
|
||||
#
|
||||
# linux (g++)
|
||||
#
|
||||
|
||||
- os: linux
|
||||
dist: bionic
|
||||
stage: linux
|
||||
name: g++-7
|
||||
addons: { apt: { sources: ["ubuntu-toolchain-r-test"], packages: ["g++-7"] } }
|
||||
env: CC=gcc-7 CXX=g++-7
|
||||
script: .ci/build_linux.sh
|
||||
|
||||
- os: linux
|
||||
dist: bionic
|
||||
stage: linux
|
||||
name: g++-8
|
||||
addons: { apt: { sources: ["ubuntu-toolchain-r-test"], packages: ["g++-8"] } }
|
||||
env: CC=gcc-8 CXX=g++-8
|
||||
script: .ci/build_linux.sh
|
||||
|
||||
#
|
||||
# linux (clang++)
|
||||
#
|
||||
|
||||
- os: linux
|
||||
dist: bionic
|
||||
stage: linux
|
||||
name: clang++-5.0
|
||||
addons: { apt: { sources: ["ubuntu-toolchain-r-test"], packages: ["clang-5.0"] } }
|
||||
env: CC=clang-5.0 CXX=clang++-5.0
|
||||
script: .ci/build_linux.sh
|
||||
|
||||
- os: linux
|
||||
dist: bionic
|
||||
stage: linux
|
||||
name: clang++-6.0
|
||||
addons: { apt: { sources: ["ubuntu-toolchain-r-test"], packages: ["clang-6.0"] } }
|
||||
env: CC=clang-6.0 CXX=clang++-6.0
|
||||
script: .ci/build_linux.sh
|
||||
|
||||
#
|
||||
# darwin
|
||||
#
|
||||
|
||||
- os: osx
|
||||
osx_image: xcode10
|
||||
stage: darwin
|
||||
name: xcode10
|
||||
script: .ci/build_darwin.sh
|
||||
|
||||
- os: osx
|
||||
osx_image: xcode11
|
||||
stage: darwin
|
||||
name: xcode11
|
||||
script: .ci/build_darwin.sh
|
||||
|
||||
#
|
||||
# windows
|
||||
#
|
||||
|
||||
- os: windows
|
||||
stage: windows
|
||||
name: x86
|
||||
script: .ci/build_windows_x86.bat
|
||||
|
||||
- os: windows
|
||||
stage: windows
|
||||
name: x64
|
||||
script: .ci/build_windows_x64.bat
|
||||
|
||||
#
|
||||
# coverage
|
||||
#
|
||||
|
||||
- os: osx
|
||||
osx_image: xcode10
|
||||
stage: coverage
|
||||
name: coverage
|
||||
addons: { homebrew: { packages: ["lcov"], update: true } }
|
||||
script: .ci/build_coverage.sh
|
||||
24
README.md
24
README.md
@@ -2,26 +2,26 @@
|
||||
|
||||
> C++17 compile-time enum reflection library
|
||||
|
||||
[![travis][badge.travis]][travis]
|
||||
[![appveyor][badge.appveyor]][appveyor]
|
||||
[![linux][badge.linux]][linux]
|
||||
[![darwin][badge.darwin]][darwin]
|
||||
[![windows][badge.windows]][windows]
|
||||
[![codecov][badge.codecov]][codecov]
|
||||
[![language][badge.language]][language]
|
||||
[![license][badge.license]][license]
|
||||
[![paypal][badge.paypal]][paypal]
|
||||
|
||||
[badge.travis]: https://img.shields.io/travis/BlackMATov/enum.hpp/main.svg?logo=travis
|
||||
[badge.appveyor]: https://img.shields.io/appveyor/ci/BlackMATov/enum-hpp/main.svg?logo=appveyor
|
||||
[badge.codecov]: https://img.shields.io/codecov/c/github/BlackMATov/enum.hpp/main.svg?logo=codecov
|
||||
[badge.language]: https://img.shields.io/badge/language-C%2B%2B17-yellow.svg
|
||||
[badge.license]: https://img.shields.io/badge/license-MIT-blue.svg
|
||||
[badge.paypal]: https://img.shields.io/badge/donate-PayPal-orange.svg?logo=paypal&colorA=00457C
|
||||
[badge.darwin]: https://img.shields.io/github/workflow/status/BlackMATov/enum.hpp/darwin/main?label=Xcode&logo=xcode
|
||||
[badge.linux]: https://img.shields.io/github/workflow/status/BlackMATov/enum.hpp/linux/main?label=GCC%2FClang&logo=linux
|
||||
[badge.windows]: https://img.shields.io/github/workflow/status/BlackMATov/enum.hpp/windows/main?label=Visual%20Studio&logo=visual-studio
|
||||
[badge.codecov]: https://img.shields.io/codecov/c/github/BlackMATov/enum.hpp/main?logo=codecov
|
||||
[badge.language]: https://img.shields.io/badge/language-C%2B%2B17-yellow
|
||||
[badge.license]: https://img.shields.io/badge/license-MIT-blue
|
||||
|
||||
[travis]: https://travis-ci.org/BlackMATov/enum.hpp
|
||||
[appveyor]: https://ci.appveyor.com/project/BlackMATov/enum-hpp
|
||||
[darwin]: https://github.com/BlackMATov/enum.hpp/actions?query=workflow%3Adarwin
|
||||
[linux]: https://github.com/BlackMATov/enum.hpp/actions?query=workflow%3Alinux
|
||||
[windows]: https://github.com/BlackMATov/enum.hpp/actions?query=workflow%3Awindows
|
||||
[codecov]: https://codecov.io/gh/BlackMATov/enum.hpp
|
||||
[language]: https://en.wikipedia.org/wiki/C%2B%2B17
|
||||
[license]: https://en.wikipedia.org/wiki/MIT_License
|
||||
[paypal]: https://www.paypal.me/matov
|
||||
|
||||
[enum]: https://github.com/BlackMATov/enum.hpp
|
||||
|
||||
|
||||
@@ -23,9 +23,9 @@ target_link_libraries(${PROJECT_NAME} enum.hpp)
|
||||
target_compile_options(${PROJECT_NAME}
|
||||
PRIVATE
|
||||
$<$<CXX_COMPILER_ID:MSVC>:
|
||||
/W4>
|
||||
/WX /W4>
|
||||
PRIVATE
|
||||
$<$<OR:$<CXX_COMPILER_ID:GNU>,$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>>:
|
||||
-Wall -Wextra -Wpedantic>)
|
||||
-Werror -Wall -Wextra -Wpedantic>)
|
||||
|
||||
add_test(${PROJECT_NAME} ${PROJECT_NAME})
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -2,10 +2,13 @@
|
||||
|
||||
#include "doctest.h"
|
||||
|
||||
// https://github.com/onqtam/doctest/issues/126
|
||||
#include <iostream>
|
||||
|
||||
#define STATIC_CHECK(...)\
|
||||
static_assert(__VA_ARGS__, #__VA_ARGS__);\
|
||||
CHECK(__VA_ARGS__);
|
||||
CHECK(__VA_ARGS__)
|
||||
|
||||
#define STATIC_CHECK_FALSE(...)\
|
||||
static_assert(!(__VA_ARGS__), "!(" #__VA_ARGS__ ")");\
|
||||
CHECK(!(__VA_ARGS__));
|
||||
CHECK(!(__VA_ARGS__))
|
||||
|
||||
@@ -32,31 +32,31 @@ TEST_CASE("enum_bitflags") {
|
||||
{
|
||||
constexpr bf::bitflags<access> f;
|
||||
STATIC_CHECK(!f);
|
||||
STATIC_CHECK(f.as_raw() == 0x0);
|
||||
STATIC_CHECK(f.as_raw() == std::uint8_t{0x0});
|
||||
STATIC_CHECK(f.as_enum() == access::none);
|
||||
}
|
||||
{
|
||||
constexpr bf::bitflags f = access::read_write;
|
||||
STATIC_CHECK(!!f);
|
||||
STATIC_CHECK(f.as_raw() == 0x3);
|
||||
STATIC_CHECK(f.as_raw() == std::uint8_t{0x3});
|
||||
STATIC_CHECK(f.as_enum() == access::read_write);
|
||||
}
|
||||
{
|
||||
constexpr bf::bitflags<access> f{0x3};
|
||||
constexpr bf::bitflags<access> f{std::uint8_t{0x3}};
|
||||
STATIC_CHECK(!!f);
|
||||
STATIC_CHECK(f.as_raw() == 0x3);
|
||||
STATIC_CHECK(f.as_raw() == std::uint8_t{0x3});
|
||||
STATIC_CHECK(f.as_enum() == access::read_write);
|
||||
}
|
||||
{
|
||||
constexpr bf::bitflags f = access::read | access::write;
|
||||
constexpr bf::bitflags g = f;
|
||||
STATIC_CHECK(g.as_raw() == 0x3);
|
||||
STATIC_CHECK(g.as_raw() == std::uint8_t{0x3});
|
||||
}
|
||||
{
|
||||
constexpr bf::bitflags f = access::read | access::write;
|
||||
bf::bitflags<access> g;
|
||||
g = f;
|
||||
CHECK(g.as_raw() == 0x3);
|
||||
CHECK(g.as_raw() == std::uint8_t{0x3});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,146 +92,146 @@ TEST_CASE("enum_bitflags") {
|
||||
}
|
||||
|
||||
SUBCASE("logic_operators") {
|
||||
STATIC_CHECK(0x1 < bf::bitflags{access::write});
|
||||
STATIC_CHECK(std::uint8_t{0x1} < bf::bitflags{access::write});
|
||||
STATIC_CHECK(access::read < bf::bitflags{access::write});
|
||||
STATIC_CHECK(bf::bitflags{access::read} < 0x2);
|
||||
STATIC_CHECK(bf::bitflags{access::read} < std::uint8_t{0x2});
|
||||
STATIC_CHECK(bf::bitflags{access::read} < access::write);
|
||||
STATIC_CHECK(bf::bitflags{access::read} < bf::bitflags{access::write});
|
||||
|
||||
STATIC_CHECK_FALSE(0x2 < bf::bitflags{access::read});
|
||||
STATIC_CHECK_FALSE(std::uint8_t{0x2} < bf::bitflags{access::read});
|
||||
STATIC_CHECK_FALSE(access::write < bf::bitflags{access::read});
|
||||
STATIC_CHECK_FALSE(bf::bitflags{access::write} < 0x1);
|
||||
STATIC_CHECK_FALSE(bf::bitflags{access::write} < std::uint8_t{0x1});
|
||||
STATIC_CHECK_FALSE(bf::bitflags{access::write} < access::read);
|
||||
STATIC_CHECK_FALSE(bf::bitflags{access::write} < bf::bitflags{access::read});
|
||||
|
||||
STATIC_CHECK(0x1 <= bf::bitflags{access::write});
|
||||
STATIC_CHECK(std::uint8_t{0x1} <= bf::bitflags{access::write});
|
||||
STATIC_CHECK(access::read <= bf::bitflags{access::write});
|
||||
STATIC_CHECK(bf::bitflags{access::read} <= 0x2);
|
||||
STATIC_CHECK(bf::bitflags{access::read} <= std::uint8_t{0x2});
|
||||
STATIC_CHECK(bf::bitflags{access::read} <= access::write);
|
||||
STATIC_CHECK(bf::bitflags{access::read} <= bf::bitflags{access::write});
|
||||
|
||||
STATIC_CHECK_FALSE(0x2 <= bf::bitflags{access::read});
|
||||
STATIC_CHECK_FALSE(std::uint8_t{0x2} <= bf::bitflags{access::read});
|
||||
STATIC_CHECK_FALSE(access::write <= bf::bitflags{access::read});
|
||||
STATIC_CHECK_FALSE(bf::bitflags{access::write} <= 0x1);
|
||||
STATIC_CHECK_FALSE(bf::bitflags{access::write} <= std::uint8_t{0x1});
|
||||
STATIC_CHECK_FALSE(bf::bitflags{access::write} <= access::read);
|
||||
STATIC_CHECK_FALSE(bf::bitflags{access::write} <= bf::bitflags{access::read});
|
||||
|
||||
STATIC_CHECK(0x2 <= bf::bitflags{access::write});
|
||||
STATIC_CHECK(std::uint8_t{0x2} <= bf::bitflags{access::write});
|
||||
STATIC_CHECK(access::write <= bf::bitflags{access::write});
|
||||
STATIC_CHECK(bf::bitflags{access::write} <= 0x2);
|
||||
STATIC_CHECK(bf::bitflags{access::write} <= std::uint8_t{0x2});
|
||||
STATIC_CHECK(bf::bitflags{access::write} <= access::write);
|
||||
STATIC_CHECK(bf::bitflags{access::write} <= bf::bitflags{access::write});
|
||||
|
||||
//
|
||||
|
||||
STATIC_CHECK_FALSE(0x1 > bf::bitflags{access::write});
|
||||
STATIC_CHECK_FALSE(std::uint8_t{0x1} > bf::bitflags{access::write});
|
||||
STATIC_CHECK_FALSE(access::read > bf::bitflags{access::write});
|
||||
STATIC_CHECK_FALSE(bf::bitflags{access::read} > 0x2);
|
||||
STATIC_CHECK_FALSE(bf::bitflags{access::read} > std::uint8_t{0x2});
|
||||
STATIC_CHECK_FALSE(bf::bitflags{access::read} > access::write);
|
||||
STATIC_CHECK_FALSE(bf::bitflags{access::read} > bf::bitflags{access::write});
|
||||
|
||||
STATIC_CHECK(0x2 > bf::bitflags{access::read});
|
||||
STATIC_CHECK(std::uint8_t{0x2} > bf::bitflags{access::read});
|
||||
STATIC_CHECK(access::write > bf::bitflags{access::read});
|
||||
STATIC_CHECK(bf::bitflags{access::write} > 0x1);
|
||||
STATIC_CHECK(bf::bitflags{access::write} > std::uint8_t{0x1});
|
||||
STATIC_CHECK(bf::bitflags{access::write} > access::read);
|
||||
STATIC_CHECK(bf::bitflags{access::write} > bf::bitflags{access::read});
|
||||
|
||||
STATIC_CHECK_FALSE(0x1 >= bf::bitflags{access::write});
|
||||
STATIC_CHECK_FALSE(std::uint8_t{0x1} >= bf::bitflags{access::write});
|
||||
STATIC_CHECK_FALSE(access::read >= bf::bitflags{access::write});
|
||||
STATIC_CHECK_FALSE(bf::bitflags{access::read} >= 0x2);
|
||||
STATIC_CHECK_FALSE(bf::bitflags{access::read} >= std::uint8_t{0x2});
|
||||
STATIC_CHECK_FALSE(bf::bitflags{access::read} >= access::write);
|
||||
STATIC_CHECK_FALSE(bf::bitflags{access::read} >= bf::bitflags{access::write});
|
||||
|
||||
STATIC_CHECK(0x2 >= bf::bitflags{access::read});
|
||||
STATIC_CHECK(std::uint8_t{0x2} >= bf::bitflags{access::read});
|
||||
STATIC_CHECK(access::write >= bf::bitflags{access::read});
|
||||
STATIC_CHECK(bf::bitflags{access::write} >= 0x1);
|
||||
STATIC_CHECK(bf::bitflags{access::write} >= std::uint8_t{0x1});
|
||||
STATIC_CHECK(bf::bitflags{access::write} >= access::read);
|
||||
STATIC_CHECK(bf::bitflags{access::write} >= bf::bitflags{access::read});
|
||||
|
||||
STATIC_CHECK(0x2 >= bf::bitflags{access::write});
|
||||
STATIC_CHECK(std::uint8_t{0x2} >= bf::bitflags{access::write});
|
||||
STATIC_CHECK(access::write >= bf::bitflags{access::write});
|
||||
STATIC_CHECK(bf::bitflags{access::write} >= 0x2);
|
||||
STATIC_CHECK(bf::bitflags{access::write} >= std::uint8_t{0x2});
|
||||
STATIC_CHECK(bf::bitflags{access::write} >= access::write);
|
||||
STATIC_CHECK(bf::bitflags{access::write} >= bf::bitflags{access::write});
|
||||
|
||||
//
|
||||
|
||||
STATIC_CHECK(0x1 == bf::bitflags{access::read});
|
||||
STATIC_CHECK(std::uint8_t{0x1} == bf::bitflags{access::read});
|
||||
STATIC_CHECK(access::read == bf::bitflags{access::read});
|
||||
STATIC_CHECK(bf::bitflags{access::read} == 0x1);
|
||||
STATIC_CHECK(bf::bitflags{access::read} == std::uint8_t{0x1});
|
||||
STATIC_CHECK(bf::bitflags{access::read} == access::read);
|
||||
STATIC_CHECK(bf::bitflags{access::read} == bf::bitflags{access::read});
|
||||
|
||||
STATIC_CHECK_FALSE(0x1 == bf::bitflags{access::write});
|
||||
STATIC_CHECK_FALSE(std::uint8_t{0x1} == bf::bitflags{access::write});
|
||||
STATIC_CHECK_FALSE(access::read == bf::bitflags{access::write});
|
||||
STATIC_CHECK_FALSE(bf::bitflags{access::read} == 0x2);
|
||||
STATIC_CHECK_FALSE(bf::bitflags{access::read} == std::uint8_t{0x2});
|
||||
STATIC_CHECK_FALSE(bf::bitflags{access::read} == access::write);
|
||||
STATIC_CHECK_FALSE(bf::bitflags{access::read} == bf::bitflags{access::write});
|
||||
|
||||
STATIC_CHECK(0x1 != bf::bitflags{access::write});
|
||||
STATIC_CHECK(std::uint8_t{0x1} != bf::bitflags{access::write});
|
||||
STATIC_CHECK(access::read != bf::bitflags{access::write});
|
||||
STATIC_CHECK(bf::bitflags{access::read} != 0x2);
|
||||
STATIC_CHECK(bf::bitflags{access::read} != std::uint8_t{0x2});
|
||||
STATIC_CHECK(bf::bitflags{access::read} != access::write);
|
||||
STATIC_CHECK(bf::bitflags{access::read} != bf::bitflags{access::write});
|
||||
|
||||
STATIC_CHECK_FALSE(0x1 != bf::bitflags{access::read});
|
||||
STATIC_CHECK_FALSE(std::uint8_t{0x1} != bf::bitflags{access::read});
|
||||
STATIC_CHECK_FALSE(access::read != bf::bitflags{access::read});
|
||||
STATIC_CHECK_FALSE(bf::bitflags{access::read} != 0x1);
|
||||
STATIC_CHECK_FALSE(bf::bitflags{access::read} != std::uint8_t{0x1});
|
||||
STATIC_CHECK_FALSE(bf::bitflags{access::read} != access::read);
|
||||
STATIC_CHECK_FALSE(bf::bitflags{access::read} != bf::bitflags{access::read});
|
||||
}
|
||||
|
||||
SUBCASE("bitflags_operators") {
|
||||
STATIC_CHECK(0xFE == ~bf::bitflags{access::read});
|
||||
STATIC_CHECK(~bf::bitflags{access::read} == 0xFE);
|
||||
STATIC_CHECK(std::uint8_t{0xFE} == ~bf::bitflags{access::read});
|
||||
STATIC_CHECK(~bf::bitflags{access::read} == std::uint8_t{0xFE});
|
||||
STATIC_CHECK(~bf::bitflags{access::read} == bf::bitflags<access>(0xFE));
|
||||
|
||||
STATIC_CHECK((access::write | bf::bitflags{access::read}) == 0x3);
|
||||
STATIC_CHECK((bf::bitflags{access::read} | access::write) == 0x3);
|
||||
STATIC_CHECK((bf::bitflags{access::read} | bf::bitflags{access::write}) == 0x3);
|
||||
STATIC_CHECK((access::write | bf::bitflags{access::read}) == std::uint8_t{0x3});
|
||||
STATIC_CHECK((bf::bitflags{access::read} | access::write) == std::uint8_t{0x3});
|
||||
STATIC_CHECK((bf::bitflags{access::read} | bf::bitflags{access::write}) == std::uint8_t{0x3});
|
||||
|
||||
STATIC_CHECK((access::write & bf::bitflags{access::read_write}) == 0x2);
|
||||
STATIC_CHECK((bf::bitflags{access::read_write} & access::write) == 0x2);
|
||||
STATIC_CHECK((bf::bitflags{access::read_write} & bf::bitflags{access::write}) == 0x2);
|
||||
STATIC_CHECK((access::write & bf::bitflags{access::read_write}) == std::uint8_t{0x2});
|
||||
STATIC_CHECK((bf::bitflags{access::read_write} & access::write) == std::uint8_t{0x2});
|
||||
STATIC_CHECK((bf::bitflags{access::read_write} & bf::bitflags{access::write}) == std::uint8_t{0x2});
|
||||
|
||||
STATIC_CHECK((access::write ^ bf::bitflags{access::read_write}) == 0x1);
|
||||
STATIC_CHECK((bf::bitflags{access::read_write} ^ access::write) == 0x1);
|
||||
STATIC_CHECK((bf::bitflags{access::read_write} ^ bf::bitflags{access::write}) == 0x1);
|
||||
STATIC_CHECK((access::write ^ bf::bitflags{access::read_write}) == std::uint8_t{0x1});
|
||||
STATIC_CHECK((bf::bitflags{access::read_write} ^ access::write) == std::uint8_t{0x1});
|
||||
STATIC_CHECK((bf::bitflags{access::read_write} ^ bf::bitflags{access::write}) == std::uint8_t{0x1});
|
||||
|
||||
{
|
||||
bf::bitflags f{access::read};
|
||||
f |= access::write;
|
||||
CHECK(f == 0x3);
|
||||
CHECK(f == std::uint8_t{0x3});
|
||||
}
|
||||
|
||||
{
|
||||
bf::bitflags f{access::read};
|
||||
f |= bf::bitflags{access::write};
|
||||
CHECK(f == 0x3);
|
||||
CHECK(f == std::uint8_t{0x3});
|
||||
}
|
||||
|
||||
{
|
||||
bf::bitflags f{access::read_write};
|
||||
f &= access::write;
|
||||
CHECK(f == 0x2);
|
||||
CHECK(f == std::uint8_t{0x2});
|
||||
}
|
||||
|
||||
{
|
||||
bf::bitflags f{access::read_write};
|
||||
f &= bf::bitflags{access::write};
|
||||
CHECK(f == 0x2);
|
||||
CHECK(f == std::uint8_t{0x2});
|
||||
}
|
||||
|
||||
{
|
||||
bf::bitflags f{access::read_write};
|
||||
f ^= access::write;
|
||||
CHECK(f == 0x1);
|
||||
CHECK(f == std::uint8_t{0x1});
|
||||
}
|
||||
|
||||
{
|
||||
bf::bitflags f{access::read_write};
|
||||
f ^= bf::bitflags{access::write};
|
||||
CHECK(f == 0x1);
|
||||
CHECK(f == std::uint8_t{0x1});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user