-
Notifications
You must be signed in to change notification settings - Fork 2
KF-23 fix USimpleString::matches #35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Kellesi
wants to merge
8
commits into
main
Choose a base branch
from
KF-23-fix-USimpleString-matches
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
f50ddc4
add tests for USimpleString::matches
a5fb3be
make USimpleString::matches irql independent
34a63ae
add more tests, fix USimpleString matches
272626d
remove Test-postfix from file names
9e46517
revert USimpleString::matches
627cec3
remove duplicated test
4b7fc7c
revert cpp names
e212b7e
Merge branch 'main' into KF-23-fix-USimpleString-matches
belyshevdenis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,287 @@ | ||
| #include "pch.h" | ||
| #include <kf/USimpleString.h> | ||
|
|
||
| SCENARIO("USimpleString::matches") | ||
| { | ||
| GIVEN("A pattern with '*' wildcard") | ||
| { | ||
| WHEN("'*' at the beginning") | ||
| { | ||
| kf::USimpleString pattern(L"*.txt"); | ||
| kf::USimpleString matchingStr(L"example.txt"); | ||
| kf::USimpleString matchingStr2(L"other-example123.txt"); | ||
| kf::USimpleString matchingStr3(L"file.doc"); | ||
|
|
||
| THEN("example.txt and other-example123.txt match the pattern") | ||
| { | ||
| REQUIRE(matchingStr.matches(pattern)); | ||
| REQUIRE(matchingStr2.matches(pattern)); | ||
| } | ||
|
|
||
| THEN("file.doc doesn't match the pattern") | ||
| { | ||
| REQUIRE(!matchingStr3.matches(pattern)); | ||
| } | ||
| } | ||
|
|
||
| WHEN("'*' in the middle") | ||
| { | ||
| kf::USimpleString pattern(L"ex*.txt"); | ||
| kf::USimpleString matchingStr(L"example.txt"); | ||
| kf::USimpleString nonMatching(L"other-example123.txt"); | ||
|
|
||
| THEN("example.txt matches the pattern ex*.txt") | ||
| { | ||
| REQUIRE(matchingStr.matches(pattern)); | ||
| } | ||
|
|
||
| THEN("other-example123.txt doesn't match the pattern ex*.txt") | ||
| { | ||
| REQUIRE(!nonMatching.matches(pattern)); | ||
| } | ||
| } | ||
|
|
||
| WHEN("'*' in the end") | ||
| { | ||
| kf::USimpleString pattern(L"example*"); | ||
| kf::USimpleString matchingStr(L"example.txt"); | ||
| kf::USimpleString nonMatching(L"other-example123.txt"); | ||
|
|
||
| THEN("example.txt matches the pattern example*") | ||
| { | ||
| REQUIRE(matchingStr.matches(pattern)); | ||
| } | ||
|
|
||
| THEN("other-example123.txt doesn't match the pattern example*") | ||
| { | ||
| REQUIRE(!nonMatching.matches(pattern)); | ||
| } | ||
| } | ||
|
|
||
| WHEN("'*' at the beginning, in the middle and in the end") | ||
| { | ||
| kf::USimpleString pattern(L"*ex*le*"); | ||
| kf::USimpleString matchingStr(L"example.txt"); | ||
| kf::USimpleString matchingStr2(L"other-example123.txt"); | ||
| kf::USimpleString nonMatching(L"file.csv"); | ||
|
|
||
| THEN("example.txt and other-example123.txt match the pattern *ex*le*") | ||
| { | ||
| REQUIRE(matchingStr.matches(pattern)); | ||
| REQUIRE(matchingStr2.matches(pattern)); | ||
| } | ||
|
|
||
| THEN("file.csv doesn't match the pattern *ex*le*") | ||
| { | ||
| REQUIRE(!nonMatching.matches(pattern)); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| GIVEN("A pattern with '?' wildcard") | ||
| { | ||
| WHEN("'?' at the beginning") | ||
| { | ||
| kf::USimpleString pattern(L"?xample.txt"); | ||
| kf::USimpleString matchingStr(L"example.txt"); | ||
| kf::USimpleString nonMatchingStr(L"eeamppe.txt"); | ||
|
|
||
| THEN("example.txt matches the pattern ?xample.txt") | ||
| { | ||
| REQUIRE(matchingStr.matches(pattern)); | ||
| } | ||
|
|
||
| THEN("eeamppe.txt does not match the pattern ?xample.txt") | ||
| { | ||
| REQUIRE(!nonMatchingStr.matches(pattern)); | ||
| } | ||
| } | ||
|
|
||
| WHEN("'?' in the middle") | ||
| { | ||
| kf::USimpleString pattern(L"exa?ple.txt"); | ||
| kf::USimpleString matchingStr(L"example.txt"); | ||
| kf::USimpleString nonMatchingStr(L"eeamppe.txt"); | ||
|
|
||
| THEN("example.txt matches the pattern exa?ple.txt") | ||
| { | ||
| REQUIRE(matchingStr.matches(pattern)); | ||
| } | ||
|
|
||
| THEN("eeamppe.txt does not match the pattern exa?ple.txt") | ||
| { | ||
| REQUIRE(!nonMatchingStr.matches(pattern)); | ||
| } | ||
| } | ||
|
|
||
| WHEN("'?' in the end") | ||
| { | ||
| kf::USimpleString pattern(L"example.tx?"); | ||
| kf::USimpleString matchingStr(L"example.txt"); | ||
| kf::USimpleString nonMatchingStr(L"eeamppe.txt"); | ||
|
|
||
| THEN("example.txt matches the pattern example.tx?") | ||
| { | ||
| REQUIRE(matchingStr.matches(pattern)); | ||
| } | ||
|
|
||
| THEN("eeamppe.txt does not match the pattern example.tx?") | ||
| { | ||
| REQUIRE(!nonMatchingStr.matches(pattern)); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| GIVEN("A pattern with mixed '*' and '?' wildcards") | ||
| { | ||
| kf::USimpleString pattern (L"?xample*.txt"); | ||
|
|
||
| WHEN("The string matches the pattern") | ||
| { | ||
| kf::USimpleString matchingStr (L"xxample_123.txt"); | ||
|
|
||
| THEN("The string matches the pattern") | ||
| { | ||
| REQUIRE(matchingStr.matches(pattern)); | ||
| } | ||
| } | ||
|
|
||
| WHEN("The string does not match the pattern") | ||
| { | ||
| kf::USimpleString str (L"non-example.exe"); | ||
|
|
||
| THEN("The string does not match") | ||
| { | ||
| REQUIRE(!str.matches(pattern)); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| WHEN("Empty pattern and empty string") | ||
| { | ||
| kf::USimpleString pattern (L""); | ||
| kf::USimpleString str (L""); | ||
|
|
||
| THEN("They match") | ||
| { | ||
| REQUIRE(str.matches(pattern)); | ||
| } | ||
| } | ||
|
|
||
| WHEN("Pattern is '*' and string is empty") | ||
| { | ||
| kf::USimpleString pattern (L"*"); | ||
| kf::USimpleString str (L""); | ||
|
|
||
| THEN("'*' does not match an empty string") | ||
| { | ||
| REQUIRE(!str.matches(pattern)); | ||
| } | ||
| } | ||
|
|
||
| WHEN("Pattern is empty and string is not") | ||
| { | ||
| kf::USimpleString pattern (L""); | ||
| kf::USimpleString str (L"file.txt"); | ||
|
|
||
| THEN("They do not match") | ||
| { | ||
| REQUIRE(!str.matches(pattern)); | ||
| } | ||
| } | ||
|
|
||
| WHEN("The string has different case") | ||
| { | ||
| kf::USimpleString pattern (L"example.txt"); | ||
|
|
||
| kf::USimpleString str1 (L"Example.txt"); | ||
| kf::USimpleString str2 (L"EXAMPLE.TXT"); | ||
| kf::USimpleString str3 (L"eXample.TxT"); | ||
|
|
||
| THEN("They do not match") | ||
| { | ||
| REQUIRE(!str1.matches(pattern)); | ||
| REQUIRE(!str2.matches(pattern)); | ||
| REQUIRE(!str3.matches(pattern)); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| SCENARIO("USimpleString::matchesIgnoreCase") | ||
| { | ||
| GIVEN("A pattern with '*' wildcard") | ||
| { | ||
| kf::USimpleString pattern(L"*.TXT"); | ||
|
|
||
| kf::USimpleString matchingStr (L"EXAMPLE.TXT"); | ||
| kf::USimpleString matchingStr2 (L"Example.txt"); | ||
| kf::USimpleString matchingStr3 (L"example.txt"); | ||
| kf::USimpleString nonMatchingStr (L"NoN-matching.ExE"); | ||
|
|
||
| THEN("EXAMPLE.TXT, Example.txt, example.txt match the pattern *.txt") | ||
| { | ||
| REQUIRE(matchingStr.matchesIgnoreCase(pattern)); | ||
| REQUIRE(matchingStr2.matchesIgnoreCase(pattern)); | ||
| REQUIRE(matchingStr3.matchesIgnoreCase(pattern)); | ||
| } | ||
|
|
||
| THEN("NoN-matching.ExE does not match *.txt") | ||
| { | ||
| REQUIRE(!nonMatchingStr.matchesIgnoreCase(pattern)); | ||
| } | ||
| } | ||
|
|
||
| GIVEN("A pattern with '?' wildcard") | ||
| { | ||
| kf::USimpleString pattern (L"E?AMP?E.TXT"); | ||
|
|
||
| kf::USimpleString matchingStr (L"EXAMPLE.txt"); | ||
| kf::USimpleString matchingStr2 (L"eeamppe.txt"); | ||
| kf::USimpleString matchingStr3 (L"eXampLe.TXT"); | ||
| kf::USimpleString nonMatchingStr (L"Example.EXE"); | ||
|
|
||
| THEN("EXAMPLE.txt, eeamppe.txt, eXampLe.TXT match the pattern e?amp?e.txt") | ||
| { | ||
| REQUIRE(matchingStr.matchesIgnoreCase(pattern)); | ||
| REQUIRE(matchingStr2.matchesIgnoreCase(pattern)); | ||
| REQUIRE(matchingStr3.matchesIgnoreCase(pattern)); | ||
| } | ||
|
|
||
| THEN("Example.EXE does not match e?amp?e.txt") | ||
| { | ||
| REQUIRE(!nonMatchingStr.matchesIgnoreCase(pattern)); | ||
| } | ||
| } | ||
|
|
||
| GIVEN("A pattern with mixed '*' and '?' wildcards") | ||
| { | ||
| kf::USimpleString pattern (L"?XAMPLE*.TXT"); | ||
| kf::USimpleString matchingStr (L"xxample_123.txt"); | ||
| kf::USimpleString matchingStr2 (L"xxAMPle_123.TXT"); | ||
| kf::USimpleString str (L"NoN-Example.exe"); | ||
|
|
||
| THEN("xxample_123.txt, xxAMPle_123.TXT match the pattern ?xample*.txt") | ||
| { | ||
| REQUIRE(matchingStr.matchesIgnoreCase(pattern)); | ||
| REQUIRE(matchingStr2.matchesIgnoreCase(pattern)); | ||
| } | ||
|
|
||
| THEN("NoN-Example.exe does not match the pattern ?xample*.txt") | ||
| { | ||
| REQUIRE(!str.matchesIgnoreCase(pattern)); | ||
| } | ||
| } | ||
|
|
||
| WHEN("Pattern is empty and string is not") | ||
| { | ||
| kf::USimpleString pattern (L""); | ||
| kf::USimpleString str (L"file.txt"); | ||
| kf::USimpleString str2 (L"FILE.TXT"); | ||
|
|
||
| THEN("They do not match") | ||
| { | ||
| REQUIRE(!str.matchesIgnoreCase(pattern)); | ||
| REQUIRE(!str2.matchesIgnoreCase(pattern)); | ||
| } | ||
| } | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.