mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-09 09:34:57 +09:00
Tests: Move AK tests to Tests/AK
This commit is contained in:
parent
fd0dbd1ebf
commit
67322b0702
Notes:
sideshowbarker
2024-07-18 18:38:20 +09:00
Author: https://github.com/bgianfo
Commit: 67322b0702
Pull-request: https://github.com/SerenityOS/serenity/pull/6891
64 changed files with 1 additions and 2 deletions
69
Tests/AK/TestEnumBits.cpp
Normal file
69
Tests/AK/TestEnumBits.cpp
Normal file
|
@ -0,0 +1,69 @@
|
|||
/*
|
||||
* Copyright (c) 2021, Brian Gianforcaro <bgianf@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibTest/TestCase.h>
|
||||
|
||||
#include <AK/EnumBits.h>
|
||||
|
||||
enum class VideoIntro : u8 {
|
||||
None = 0x0,
|
||||
Well = 0x1,
|
||||
Hello = 0x2,
|
||||
Friends = 0x4,
|
||||
ExclimationMark = 0x8,
|
||||
CompleteIntro = Well | Hello | Friends | ExclimationMark,
|
||||
};
|
||||
|
||||
AK_ENUM_BITWISE_OPERATORS(VideoIntro);
|
||||
|
||||
TEST_CASE(bitwise_or)
|
||||
{
|
||||
auto intro = VideoIntro::Well | VideoIntro::Hello | VideoIntro::Friends | VideoIntro::ExclimationMark;
|
||||
EXPECT_EQ(intro, VideoIntro::CompleteIntro);
|
||||
}
|
||||
|
||||
TEST_CASE(bitwise_and)
|
||||
{
|
||||
auto intro = VideoIntro::CompleteIntro;
|
||||
EXPECT_EQ(intro & VideoIntro::Hello, VideoIntro::Hello);
|
||||
}
|
||||
|
||||
TEST_CASE(bitwise_xor)
|
||||
{
|
||||
auto intro = VideoIntro::Well | VideoIntro::Hello | VideoIntro::Friends;
|
||||
EXPECT_EQ(intro ^ VideoIntro::CompleteIntro, VideoIntro::ExclimationMark);
|
||||
}
|
||||
|
||||
TEST_CASE(bitwise_not)
|
||||
{
|
||||
auto intro = ~VideoIntro::CompleteIntro;
|
||||
EXPECT_EQ(intro & VideoIntro::CompleteIntro, VideoIntro::None);
|
||||
}
|
||||
|
||||
TEST_CASE(bitwise_or_equal)
|
||||
{
|
||||
auto intro = VideoIntro::Well | VideoIntro::Hello | VideoIntro::Friends;
|
||||
EXPECT_EQ(intro |= VideoIntro::ExclimationMark, VideoIntro::CompleteIntro);
|
||||
}
|
||||
|
||||
TEST_CASE(bitwise_and_equal)
|
||||
{
|
||||
auto intro = VideoIntro::CompleteIntro;
|
||||
EXPECT_EQ(intro &= VideoIntro::Hello, VideoIntro::Hello);
|
||||
}
|
||||
|
||||
TEST_CASE(bitwise_xor_equal)
|
||||
{
|
||||
auto intro = VideoIntro::Well | VideoIntro::Hello | VideoIntro::Friends;
|
||||
EXPECT_EQ(intro ^= VideoIntro::CompleteIntro, VideoIntro::ExclimationMark);
|
||||
}
|
||||
|
||||
TEST_CASE(has_flag)
|
||||
{
|
||||
auto intro = VideoIntro::Hello | VideoIntro::Friends;
|
||||
EXPECT(has_flag(intro, VideoIntro::Friends));
|
||||
EXPECT(!has_flag(intro, VideoIntro::Well));
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue