Fixed erroneous operator== on ZString.
This commit is contained in:
1 parent
34e2ca0566
commit
d0239074a4
3 files changed
+6
-14
No files matched your search
+3
-13
@@ -104,22 +104,12 @@ namespace coreutils {
|
|||||||
return (strncmp(data, valuex.data, valuex.length <= length ? valuex.length : length) > 0);
|
return (strncmp(data, valuex.data, valuex.length <= length ? valuex.length : length) > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ZString::operator==(const ZString &valuex) {
|
bool ZString::operator==(const ZString valuex) {
|
||||||
if((valuex.getLength() == 0) && (length != 0))
|
if(valuex.getLength() != length)
|
||||||
return false;
|
return false;
|
||||||
return (strncmp(data, valuex.data, valuex.length <= length ? valuex.length : length) == 0);
|
return (strncmp(data, valuex.data, valuex.length <= length ? valuex.length : length) == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// bool ZString::operator==(std::string value) {
|
|
||||||
// if(value.length() != length)
|
|
||||||
// return false;
|
|
||||||
// return (strncmp(data, value.c_str(), length) == 0);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// bool ZString::operator==(const char *valuex) const {
|
|
||||||
// return (strncmp(data, valuex, length) == 0);
|
|
||||||
// }
|
|
||||||
|
|
||||||
bool ZString::operator!=(const ZString &valuex) const {
|
bool ZString::operator!=(const ZString &valuex) const {
|
||||||
// if(length != valuex.getLength())
|
// if(length != valuex.getLength())
|
||||||
// return false;
|
// return false;
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ namespace coreutils {
|
|||||||
bool operator>(const ZString &valuex) const;
|
bool operator>(const ZString &valuex) const;
|
||||||
bool operator<=(const ZString &valuex) const;
|
bool operator<=(const ZString &valuex) const;
|
||||||
bool operator>=(const ZString &valuex) const;
|
bool operator>=(const ZString &valuex) const;
|
||||||
bool operator==(const ZString &valuex);
|
bool operator==(const ZString valuex);
|
||||||
bool operator!=(const ZString &valuex) const;
|
bool operator!=(const ZString &valuex) const;
|
||||||
bool operator!=(const char *valuex) const;
|
bool operator!=(const char *valuex) const;
|
||||||
|
|
||||||
|
|||||||
@@ -105,5 +105,7 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
std::cout << "Null assignment" << std::endl;
|
std::cout << "Null assignment" << std::endl;
|
||||||
coreutils::ZString test20(NULL);
|
coreutils::ZString test20(NULL);
|
||||||
|
std::cout << "[" << test20 << "]" << std::endl;
|
||||||
|
std::cout << "Comparisons with null value: " << (test20 == "true") << std::endl;
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user