42 lines
791 B
C++
42 lines
791 B
C++
//
|
|
// Created by erki on 15.07.22.
|
|
//
|
|
|
|
#include <catch2/catch.hpp>
|
|
|
|
#include "utility_enum_helpers.hpp"
|
|
|
|
namespace
|
|
{
|
|
|
|
enum class TestEnum : unsigned
|
|
{
|
|
FLAG_0 = 1,
|
|
FLAG_1 = 2,
|
|
FLAG_2 = 4
|
|
};
|
|
|
|
SKULLC_ENUM_DECLARE_BITFLAG_OPERATORS(TestEnum)
|
|
|
|
}// namespace
|
|
|
|
TEST_CASE("OR operator works as expected.", "[utility],[enum_helpers]")
|
|
{
|
|
const TestEnum a = TestEnum::FLAG_0;
|
|
const TestEnum b = TestEnum::FLAG_1;
|
|
|
|
const TestEnum sum = a | b;
|
|
CHECK(unsigned(sum) == 3u);
|
|
}
|
|
|
|
TEST_CASE("AND operator works as expected.", "[utility],[enum_helpers]")
|
|
{
|
|
const TestEnum a = TestEnum::FLAG_0 | TestEnum::FLAG_1;
|
|
|
|
const TestEnum masked_1 = a & TestEnum::FLAG_0;
|
|
CHECK(masked_1 == TestEnum::FLAG_0);
|
|
|
|
const TestEnum masked_2 = a & TestEnum::FLAG_2;
|
|
CHECK(masked_2 != TestEnum::FLAG_2);
|
|
}
|