From 75df8d0282c16ea73dfc87f702de14eef3b84ffe Mon Sep 17 00:00:00 2001 From: Brad Arant Date: Tue, 24 Sep 2024 14:19:25 -0700 Subject: [PATCH] Made find() return -1 if not found. --- ZString.cpp | 3 +-- testing/zstring_test.cpp | 5 +++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/ZString.cpp b/ZString.cpp index 219d726..9f45f5b 100644 --- a/ZString.cpp +++ b/ZString.cpp @@ -412,8 +412,7 @@ namespace coreutils { ++temp2; if(cursor > (data + length)) { cursor = temp; - count = 0; - break; + return -1; } } cursor = temp2; diff --git a/testing/zstring_test.cpp b/testing/zstring_test.cpp index d9135a2..974af57 100644 --- a/testing/zstring_test.cpp +++ b/testing/zstring_test.cpp @@ -94,5 +94,10 @@ int main(int argc, char **argv) { coreutils::ZString test17(" hello there "); std::cout << "[" << test17.trim() << "]" << std::endl; + + coreutils::ZString test18("this.test"); + std::cout << "[" << test18.find(".") << "] " << test18.parsed() << ":" << test18.unparsed() << std::endl; + test18.reset(); + std::cout << "[" << test18.find("x") << "] " << test18.parsed() << ":" << test18.unparsed() << std::endl; }