mirror of
https://github.com/fltk/fltk.git
synced 2026-05-29 04:26:27 +08:00
Add Fl_String not-equal test
This commit is contained in:
@@ -135,6 +135,7 @@ public:
|
|||||||
FL_EXPORT Fl_String operator+(const Fl_String& lhs, const Fl_String& rhs);
|
FL_EXPORT Fl_String operator+(const Fl_String& lhs, const Fl_String& rhs);
|
||||||
FL_EXPORT Fl_String operator+(const Fl_String& lhs, const char* rhs);
|
FL_EXPORT Fl_String operator+(const Fl_String& lhs, const char* rhs);
|
||||||
FL_EXPORT bool operator==(const Fl_String & lhs, const Fl_String & rhs);
|
FL_EXPORT bool operator==(const Fl_String & lhs, const Fl_String & rhs);
|
||||||
|
FL_EXPORT bool operator!=(const Fl_String & lhs, const Fl_String & rhs);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\}
|
\}
|
||||||
|
|||||||
@@ -645,6 +645,19 @@ bool operator==(const Fl_String &lhs, const Fl_String &rhs) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Compare two strings for inequality.
|
||||||
|
\param[in] lhs first string
|
||||||
|
\param[in] rhs second string
|
||||||
|
\return true if strings differ in size or content
|
||||||
|
*/
|
||||||
|
bool operator!=(const Fl_String &lhs, const Fl_String &rhs) {
|
||||||
|
if (lhs.size() != rhs.size()) return true;
|
||||||
|
int sz = lhs.size(); // same size for both
|
||||||
|
if (memcmp(lhs.data(), rhs.data(), sz) != 0) return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\}
|
\}
|
||||||
\endcond
|
\endcond
|
||||||
|
|||||||
@@ -193,6 +193,8 @@ TEST(Fl_String, Non-Member Functions) {
|
|||||||
EXPECT_STREQ(result.c_str(), "x");
|
EXPECT_STREQ(result.c_str(), "x");
|
||||||
EXPECT_TRUE(!(a == b));
|
EXPECT_TRUE(!(a == b));
|
||||||
EXPECT_TRUE(a == a);
|
EXPECT_TRUE(a == a);
|
||||||
|
EXPECT_FALSE((a != a)); // neq -erco
|
||||||
|
EXPECT_TRUE((a != b)); // neq -erco
|
||||||
EXPECT_TRUE(empty == empty);
|
EXPECT_TRUE(empty == empty);
|
||||||
EXPECT_TRUE(a+b == "ab");
|
EXPECT_TRUE(a+b == "ab");
|
||||||
EXPECT_TRUE(a+"b" == "a" + b);
|
EXPECT_TRUE(a+"b" == "a" + b);
|
||||||
|
|||||||
Reference in New Issue
Block a user