Commit d5efab49 authored by Tatsuhiro Tsujikawa's avatar Tatsuhiro Tsujikawa

src: Add inequality operator for StringRef

parent 919e9eee
......@@ -342,6 +342,22 @@ inline bool operator==(const char *lhs, const StringRef &rhs) {
return rhs == lhs;
}
inline bool operator!=(const StringRef &lhs, const std::string &rhs) {
return !(lhs == rhs);
}
inline bool operator!=(const std::string &lhs, const StringRef &rhs) {
return !(rhs == lhs);
}
inline bool operator!=(const StringRef &lhs, const char *rhs) {
return !(lhs == rhs);
}
inline bool operator!=(const char *lhs, const StringRef &rhs) {
return !(rhs == lhs);
}
inline int run_app(std::function<int(int, char **)> app, int argc,
char **argv) {
try {
......
......@@ -87,6 +87,14 @@ void test_template_immutable_string(void) {
CU_ASSERT("bravo" == from_lit);
CU_ASSERT(5 == from_lit.size());
// equality
ImmutableString eq("delta");
CU_ASSERT("delta1" != eq);
CU_ASSERT("delt" != eq);
CU_ASSERT(eq != "delta1");
CU_ASSERT(eq != "delt");
}
void test_template_string_ref(void) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment