Fixed erroneous operator== on ZString.
This commit is contained in:
parent
34e2ca0566
commit
d0239074a4
16
ZString.cpp
16
ZString.cpp
@ -104,22 +104,12 @@ namespace coreutils {
|
||||
return (strncmp(data, valuex.data, valuex.length <= length ? valuex.length : length) > 0);
|
||||
}
|
||||
|
||||
bool ZString::operator==(const ZString &valuex) {
|
||||
if((valuex.getLength() == 0) && (length != 0))
|
||||
return false;
|
||||
bool ZString::operator==(const ZString valuex) {
|
||||
if(valuex.getLength() != length)
|
||||
return false;
|
||||
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 {
|
||||
// if(length != valuex.getLength())
|
||||
// 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);
|
||||
bool operator==(const ZString valuex);
|
||||
bool operator!=(const ZString &valuex) const;
|
||||
bool operator!=(const char *valuex) const;
|
||||
|
||||
|
@ -105,5 +105,7 @@ int main(int argc, char **argv) {
|
||||
|
||||
std::cout << "Null assignment" << std::endl;
|
||||
coreutils::ZString test20(NULL);
|
||||
std::cout << "[" << test20 << "]" << std::endl;
|
||||
std::cout << "Comparisons with null value: " << (test20 == "true") << std::endl;
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user