diff options
author | Ali Mohammad Pur <ali.mpfard@gmail.com> | 2023-02-15 10:27:57 +0330 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2023-02-15 10:14:26 +0100 |
commit | 1e022295c49489bf108e6e19fa3c843f7c9f3d2b (patch) | |
tree | e49130a8403f4d11baaf2013ffa5979775a553cf | |
parent | 5dce916a5043e8064f0467983572a9fabb9f096d (diff) | |
download | serenity-1e022295c49489bf108e6e19fa3c843f7c9f3d2b.zip |
Tests: Use .is_flag_set() instead of bitwise & in Regex flag tests
The default flag might not be zero, so don't assume masking off flags
will yield zero.
-rw-r--r-- | Tests/LibRegex/Regex.cpp | 70 |
1 files changed, 35 insertions, 35 deletions
diff --git a/Tests/LibRegex/Regex.cpp b/Tests/LibRegex/Regex.cpp index 81307986ea..d35d6e722b 100644 --- a/Tests/LibRegex/Regex.cpp +++ b/Tests/LibRegex/Regex.cpp @@ -36,33 +36,33 @@ TEST_CASE(regex_options_ecmascript) ECMAScriptOptions eo; eo |= ECMAScriptFlags::Global; - EXPECT(eo & ECMAScriptFlags::Global); - EXPECT(!(eo & ECMAScriptFlags::Insensitive)); + EXPECT(eo.has_flag_set(ECMAScriptFlags::Global)); + EXPECT(!eo.has_flag_set(ECMAScriptFlags::Insensitive)); eo = match_test_api_options(ECMAScriptFlags::Global | ECMAScriptFlags::Insensitive | ECMAScriptFlags::Sticky); - EXPECT(eo & ECMAScriptFlags::Global); - EXPECT(eo & ECMAScriptFlags::Insensitive); - EXPECT(eo & ECMAScriptFlags::Sticky); - EXPECT(!(eo & ECMAScriptFlags::Unicode)); - EXPECT(!(eo & ECMAScriptFlags::Multiline)); - EXPECT(!(eo & ECMAScriptFlags::SingleLine)); + EXPECT(eo.has_flag_set(ECMAScriptFlags::Global)); + EXPECT(eo.has_flag_set(ECMAScriptFlags::Insensitive)); + EXPECT(eo.has_flag_set(ECMAScriptFlags::Sticky)); + EXPECT(!eo.has_flag_set(ECMAScriptFlags::Unicode)); + EXPECT(!eo.has_flag_set(ECMAScriptFlags::Multiline)); + EXPECT(!eo.has_flag_set(ECMAScriptFlags::SingleLine)); eo &= ECMAScriptFlags::Insensitive; - EXPECT(!(eo & ECMAScriptFlags::Global)); - EXPECT(eo & ECMAScriptFlags::Insensitive); - EXPECT(!(eo & ECMAScriptFlags::Multiline)); + EXPECT(!eo.has_flag_set(ECMAScriptFlags::Global)); + EXPECT(eo.has_flag_set(ECMAScriptFlags::Insensitive)); + EXPECT(!eo.has_flag_set(ECMAScriptFlags::Multiline)); eo &= ECMAScriptFlags::Sticky; - EXPECT(!(eo & ECMAScriptFlags::Global)); - EXPECT(!(eo & ECMAScriptFlags::Insensitive)); - EXPECT(!(eo & ECMAScriptFlags::Multiline)); - EXPECT(!(eo & ECMAScriptFlags::Sticky)); + EXPECT(!eo.has_flag_set(ECMAScriptFlags::Global)); + EXPECT(!eo.has_flag_set(ECMAScriptFlags::Insensitive)); + EXPECT(!eo.has_flag_set(ECMAScriptFlags::Multiline)); + EXPECT(!eo.has_flag_set(ECMAScriptFlags::Sticky)); eo = ~ECMAScriptFlags::Insensitive; - EXPECT(eo & ECMAScriptFlags::Global); - EXPECT(!(eo & ECMAScriptFlags::Insensitive)); - EXPECT(eo & ECMAScriptFlags::Multiline); - EXPECT(eo & ECMAScriptFlags::Sticky); + EXPECT(eo.has_flag_set(ECMAScriptFlags::Global)); + EXPECT(!eo.has_flag_set(ECMAScriptFlags::Insensitive)); + EXPECT(eo.has_flag_set(ECMAScriptFlags::Multiline)); + EXPECT(eo.has_flag_set(ECMAScriptFlags::Sticky)); } TEST_CASE(regex_options_posix) @@ -70,30 +70,30 @@ TEST_CASE(regex_options_posix) PosixOptions eo; eo |= PosixFlags::Global; - EXPECT(eo & PosixFlags::Global); - EXPECT(!(eo & PosixFlags::Insensitive)); + EXPECT(eo.has_flag_set(PosixFlags::Global)); + EXPECT(!eo.has_flag_set(PosixFlags::Insensitive)); eo = match_test_api_options(PosixFlags::Global | PosixFlags::Insensitive | PosixFlags::MatchNotBeginOfLine); - EXPECT(eo & PosixFlags::Global); - EXPECT(eo & PosixFlags::Insensitive); - EXPECT(eo & PosixFlags::MatchNotBeginOfLine); - EXPECT(!(eo & PosixFlags::Unicode)); - EXPECT(!(eo & PosixFlags::Multiline)); + EXPECT(eo.has_flag_set(PosixFlags::Global)); + EXPECT(eo.has_flag_set(PosixFlags::Insensitive)); + EXPECT(eo.has_flag_set(PosixFlags::MatchNotBeginOfLine)); + EXPECT(!eo.has_flag_set(PosixFlags::Unicode)); + EXPECT(!eo.has_flag_set(PosixFlags::Multiline)); eo &= PosixFlags::Insensitive; - EXPECT(!(eo & PosixFlags::Global)); - EXPECT(eo & PosixFlags::Insensitive); - EXPECT(!(eo & PosixFlags::Multiline)); + EXPECT(!eo.has_flag_set(PosixFlags::Global)); + EXPECT(eo.has_flag_set(PosixFlags::Insensitive)); + EXPECT(!eo.has_flag_set(PosixFlags::Multiline)); eo &= PosixFlags::MatchNotBeginOfLine; - EXPECT(!(eo & PosixFlags::Global)); - EXPECT(!(eo & PosixFlags::Insensitive)); - EXPECT(!(eo & PosixFlags::Multiline)); + EXPECT(!eo.has_flag_set(PosixFlags::Global)); + EXPECT(!eo.has_flag_set(PosixFlags::Insensitive)); + EXPECT(!eo.has_flag_set(PosixFlags::Multiline)); eo = ~PosixFlags::Insensitive; - EXPECT(eo & PosixFlags::Global); - EXPECT(!(eo & PosixFlags::Insensitive)); - EXPECT(eo & PosixFlags::Multiline); + EXPECT(eo.has_flag_set(PosixFlags::Global)); + EXPECT(!eo.has_flag_set(PosixFlags::Insensitive)); + EXPECT(eo.has_flag_set(PosixFlags::Multiline)); } TEST_CASE(regex_lexer) |