Skip to content

Commit 239e79b

Browse files
committed
Fix: Failing test cases
1 parent 36d6ba7 commit 239e79b

File tree

3 files changed

+18
-9
lines changed

3 files changed

+18
-9
lines changed

include/stringzilla/stringzilla.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2193,8 +2193,8 @@ SZ_INTERNAL sz_cptr_t _sz_find_with_prefix(sz_cptr_t h, sz_size_t h_length, sz_c
21932193
if (!found) return SZ_NULL_CHAR;
21942194

21952195
// Verify the remaining part of the needle
2196-
sz_size_t remaining = h_length - (found - h) - prefix_length;
2197-
if (remaining < suffix_length) return SZ_NULL_CHAR;
2196+
sz_size_t remaining = h_length - (found - h);
2197+
if (remaining < n_length) return SZ_NULL_CHAR;
21982198
if (sz_equal(found + prefix_length, n + prefix_length, suffix_length)) return found;
21992199

22002200
// Adjust the position.

rust/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,7 +1102,7 @@ where
11021102
/// let haystack = b"abababa";
11031103
/// let needle = b"aba";
11041104
/// let matches: Vec<&[u8]> = haystack.sz_matches(needle).collect();
1105-
/// assert_eq!(matches, vec![b"aba", b"aba"]);
1105+
/// assert_eq!(matches, vec![b"aba", b"aba", b"aba"]);
11061106
/// ```
11071107
fn sz_matches(&'a self, needle: &'a N) -> RangeMatches<'a>;
11081108

@@ -1120,7 +1120,7 @@ where
11201120
/// let haystack = b"abababa";
11211121
/// let needle = b"aba";
11221122
/// let matches: Vec<&[u8]> = haystack.sz_rmatches(needle).collect();
1123-
/// assert_eq!(matches, vec![b"aba", b"aba"]);
1123+
/// assert_eq!(matches, vec![b"aba", b"aba", b"aba"]);
11241124
/// ```
11251125
fn sz_rmatches(&'a self, needle: &'a N) -> RangeRMatches<'a>;
11261126

scripts/test.cpp

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -964,11 +964,20 @@ static void test_search() {
964964
assert(rfinds.size() == 3);
965965
assert(rfinds[0] == "c");
966966

967-
auto splits = ".a..c."_sz.split(sz::char_set(".")).template to<std::vector<std::string>>();
968-
assert(splits.size() == 5);
969-
assert(splits[0] == "");
970-
assert(splits[1] == "a");
971-
assert(splits[4] == "");
967+
{
968+
auto splits = ".a..c."_sz.split(sz::char_set(".")).template to<std::vector<std::string>>();
969+
assert(splits.size() == 5);
970+
assert(splits[0] == "");
971+
assert(splits[1] == "a");
972+
assert(splits[4] == "");
973+
}
974+
975+
{
976+
auto splits = "line1\nline2\nline3"_sz.split("line3").template to<std::vector<std::string>>();
977+
assert(splits.size() == 2);
978+
assert(splits[0] == "line1\nline2\n");
979+
assert(splits[1] == "");
980+
}
972981

973982
assert(""_sz.split(".").size() == 1);
974983
assert(""_sz.rsplit(".").size() == 1);

0 commit comments

Comments
 (0)