diff --git a/ZString.cpp b/ZString.cpp index 9b7f7d3..dc21d06 100644 --- a/ZString.cpp +++ b/ZString.cpp @@ -69,12 +69,16 @@ namespace coreutils { } bool ZString::operator!=(const ZString &valuex) const { - return (strncmp(data, valuex.data, valuex.length <= length ? valuex.length : length) != 0); +// if(length != valuex.getLength()) +// return false; + return (strncmp(data, valuex.data, length) != 0); } bool ZString::operator!=(const char *valuex) const { size_t len = strlen(valuex); - return (strncmp(data, valuex, len <= length ? len : length) != 0); + if(length != len) + return true; + return (strncmp(data, valuex, length) != 0); } std::vector &ZString::getList() { diff --git a/testing/compile b/testing/compile index d4d2dd7..a17f5cf 100755 --- a/testing/compile +++ b/testing/compile @@ -1,2 +1,3 @@ #!/bin/bash -g++ -o mstring_test mstring_test.cpp -I.. -L.. -lCoreUtils \ No newline at end of file +g++ -o zstring_test zstring_test.cpp -I.. -L.. -lCoreUtils +g++ -o mstring_test mstring_test.cpp -I.. -L.. -lCoreUtils diff --git a/testing/mstring_test b/testing/mstring_test index 393b408..c42765e 100755 Binary files a/testing/mstring_test and b/testing/mstring_test differ diff --git a/testing/zstring_test b/testing/zstring_test index 67b85d5..d84faa0 100755 Binary files a/testing/zstring_test and b/testing/zstring_test differ diff --git a/testing/zstring_test.cpp b/testing/zstring_test.cpp index 7edfe43..5cacf58 100644 --- a/testing/zstring_test.cpp +++ b/testing/zstring_test.cpp @@ -3,6 +3,13 @@ int main(int argc, char **argv) { + // Test comparison operations. + + coreutils::ZString test1(""); + std::cout << (test1 != "."); + + // Test split operations. + coreutils::ZString test("11111:22222:33333:44444"); std::cout << "test pre-split: [" << test << "]." << std::endl;