Fix the operator != on ZString.
This commit is contained in:
parent
d38b7f0c55
commit
d1c38dcfc8
@ -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> &ZString::getList() {
|
||||
|
@ -1,2 +1,3 @@
|
||||
#!/bin/bash
|
||||
g++ -o mstring_test mstring_test.cpp -I.. -L.. -lCoreUtils
|
||||
g++ -o zstring_test zstring_test.cpp -I.. -L.. -lCoreUtils
|
||||
g++ -o mstring_test mstring_test.cpp -I.. -L.. -lCoreUtils
|
||||
|
Binary file not shown.
Binary file not shown.
@ -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;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user