Skip to content
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

test: Added to z_function test corner cases for empty text and pattern #2863

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions strings/z_function.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,22 @@ static void test() {
// matching_indexes2 gets the indexes where pattern2 exists in text2
std::vector<uint64_t> matching_indexes2 = find_pat_in_text(pattern2, text2);
assert((matching_indexes2 == std::vector<uint64_t>{}));

// corner case - empty text
std::string text3 = "";
std::string pattern3 = "abc";

// matching_indexes3 gets the indexes where pattern3 exists in text3
std::vector<uint64_t> matching_indexes3 = find_pat_in_text(pattern3, text3);
assert((matching_indexes3 == std::vector<uint64_t>{}));

// corner case - empty pattern
std::string text4 = "redsand";
std::string pattern4 = "";

// matching_indexes4 gets the indexes where pattern4 exists in text4
std::vector<uint64_t> matching_indexes4 = find_pat_in_text(pattern4, text4);
assert((matching_indexes4 == std::vector<uint64_t>{0, 1, 2, 3, 4, 5, 6}));
}

/**
Expand Down
Loading