Commit 3128629c authored by JINMEI Tatuya's avatar JINMEI Tatuya
Browse files

[2107] (unrelated) added operator==() to LabelSequence.

so I can use the LabelSequence objects in EXPECT_EQ().
also fixed a minor error in doxygen comment in equals().
parent e7a479a7
......@@ -200,7 +200,7 @@ public:
/// \brief Compares two label sequences for equality.
///
/// Performs a (optionally case-insensitive) comparison between this
/// Performs a (optionally case-sensitive) comparison between this
/// LabelSequence and another LabelSequence for equality.
///
/// \param other The LabelSequence to compare with
......@@ -209,6 +209,16 @@ public:
/// and contain the same data.
bool equals(const LabelSequence& other, bool case_sensitive = false) const;
/// \brief Compares two label sequences for equality (case ignored).
///
/// This is equivalent to <code>this->equals(other)</code>.
///
/// The operator version is convenient some specific cases such as in
/// unit tests.
bool operator==(const LabelSequence& other) const {
return (equals(other));
}
/// \brief Compares two label sequences.
///
/// Performs a (optionally case-insensitive) comparison between this
......
......@@ -177,6 +177,15 @@ TEST_F(LabelSequenceTest, equals_insensitive) {
EXPECT_TRUE(ls11.equals(ls12));
}
// operator==(). This is mostly trivial wrapper, so it should suffice to
// check some basic cases.
TEST_F(LabelSequenceTest, operatorEqual) {
EXPECT_TRUE(ls1 == ls1); // self equivalence
EXPECT_TRUE(ls1 == LabelSequence(n1)); // equivalent two different objects
EXPECT_FALSE(ls1 == ls2); // non equivalent objects
EXPECT_TRUE(ls1 == ls5); // it's always case insensitive
}
// Compare tests
TEST_F(LabelSequenceTest, compare) {
// "example.org." and "example.org.", case sensitive
......
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