29 #include <gtest/gtest.h>
43 object_match_3.
add(object_match_1);
44 object_match_3.
add(object_match_2);
49 EXPECT_EQ(2, expressions.size());
50 EXPECT_EQ(2, expressions[0].size());
51 EXPECT_EQ(1, expressions[1].size());
53 EXPECT_EQ(expressions[0][0],
"token1");
54 EXPECT_EQ(expressions[0][1],
"token2");
55 EXPECT_EQ(expressions[1][0],
"token3");
58 TEST(MatchTest, SetExpression)
66 EXPECT_EQ(1, expressions.size());
67 EXPECT_EQ(4, expressions[0].size());
69 EXPECT_EQ(
"A", expressions[0][0]);
70 EXPECT_EQ(
"B", expressions[0][1]);
71 EXPECT_EQ(
"C", expressions[0][2]);
72 EXPECT_EQ(
"D", expressions[0][3]);
75 TEST(MatchTest, SetExpressionVector)
80 to_add.push_back(
"A.B.C.D");
81 to_add.push_back(
"E.F.G");
88 EXPECT_EQ(2, expressions.size());
89 EXPECT_EQ(4, expressions[0].size());
90 EXPECT_EQ(3, expressions[1].size());
92 EXPECT_EQ(
"A", expressions[0][0]);
93 EXPECT_EQ(
"B", expressions[0][1]);
94 EXPECT_EQ(
"C", expressions[0][2]);
95 EXPECT_EQ(
"D", expressions[0][3]);
96 EXPECT_EQ(
"E", expressions[1][0]);
97 EXPECT_EQ(
"F", expressions[1][1]);
98 EXPECT_EQ(
"G", expressions[1][2]);
103 ObjectMatch object_match(
"this.is.a.perfect.match");
104 EXPECT_TRUE(object_match.
match(
"this.is.a.perfect.match"));
107 TEST(MatchTest, SimpleMismatch)
109 ObjectMatch object_match(
"this.is.a.perfect.match");
110 EXPECT_FALSE(object_match.
match(
"this.is.a.perfect.--"));
113 TEST(MatchTest, MultipleExpressionsMatch)
117 expressions.push_back(
"A.B.C.D");
118 expressions.push_back(
"E.F.G");
121 EXPECT_TRUE(object_match.
match(
"A.B.C.D"));
122 EXPECT_TRUE(object_match.
match(
"E.F.G"));
125 TEST(MatchTest, MultipleExpressionsMismatch)
129 expressions.push_back(
"A.B.C.D");
130 expressions.push_back(
"E.F.G");
133 EXPECT_FALSE(object_match.
match(
"B.C.D"));
134 EXPECT_FALSE(object_match.
match(
"D.E.F.G"));
144 EXPECT_TRUE(object_match.
match(
"this.is.a.match"));
145 EXPECT_TRUE(object_match.
match(
"this.is.a.perfect.match"));
146 EXPECT_TRUE(object_match.
match(
"this.is.a.great.match"));
149 TEST(MatchTest, WildCardMismatch)
153 EXPECT_FALSE(object_match.
match(
"this.is.a.bla.bla.match"));
154 EXPECT_FALSE(object_match.
match(
"this.is.a.great.match--"));
157 TEST(MatchTest, TokensEmptyNoMatch)
160 EXPECT_FALSE(object_match.
match(
"token1"));