29 #include <gtest/gtest.h>
45 object_match_3.
add(object_match_1);
46 object_match_3.
add(object_match_2);
51 EXPECT_EQ(2, expressions.size());
52 EXPECT_EQ(2, expressions[0].size());
53 EXPECT_EQ(1, expressions[1].size());
55 EXPECT_EQ(expressions[0][0],
"token1");
56 EXPECT_EQ(expressions[0][1],
"token2");
57 EXPECT_EQ(expressions[1][0],
"token3");
60 TEST(MatchTest, SetExpression)
68 EXPECT_EQ(1, expressions.size());
69 EXPECT_EQ(4, expressions[0].size());
71 EXPECT_EQ(
"A", expressions[0][0]);
72 EXPECT_EQ(
"B", expressions[0][1]);
73 EXPECT_EQ(
"C", expressions[0][2]);
74 EXPECT_EQ(
"D", expressions[0][3]);
77 TEST(MatchTest, SetExpressionVector)
82 to_add.push_back(
"A.B.C.D");
83 to_add.push_back(
"E.F.G");
90 EXPECT_EQ(2, expressions.size());
91 EXPECT_EQ(4, expressions[0].size());
92 EXPECT_EQ(3, expressions[1].size());
94 EXPECT_EQ(
"A", expressions[0][0]);
95 EXPECT_EQ(
"B", expressions[0][1]);
96 EXPECT_EQ(
"C", expressions[0][2]);
97 EXPECT_EQ(
"D", expressions[0][3]);
98 EXPECT_EQ(
"E", expressions[1][0]);
99 EXPECT_EQ(
"F", expressions[1][1]);
100 EXPECT_EQ(
"G", expressions[1][2]);
105 ObjectMatch object_match(
"this.is.a.perfect.match");
106 EXPECT_TRUE(object_match.
match(
"this.is.a.perfect.match"));
109 TEST(MatchTest, SimpleMismatch)
111 ObjectMatch object_match(
"this.is.a.perfect.match");
112 EXPECT_FALSE(object_match.
match(
"this.is.a.perfect.--"));
115 TEST(MatchTest, MultipleExpressionsMatch)
119 expressions.push_back(
"A.B.C.D");
120 expressions.push_back(
"E.F.G");
123 EXPECT_TRUE(object_match.
match(
"A.B.C.D"));
124 EXPECT_TRUE(object_match.
match(
"E.F.G"));
127 TEST(MatchTest, MultipleExpressionsMismatch)
131 expressions.push_back(
"A.B.C.D");
132 expressions.push_back(
"E.F.G");
135 EXPECT_FALSE(object_match.
match(
"B.C.D"));
136 EXPECT_FALSE(object_match.
match(
"D.E.F.G"));
146 EXPECT_TRUE(object_match.
match(
"this.is.a.match"));
147 EXPECT_TRUE(object_match.
match(
"this.is.a.perfect.match"));
148 EXPECT_TRUE(object_match.
match(
"this.is.a.great.match"));
151 TEST(MatchTest, WildCardMismatch)
155 EXPECT_FALSE(object_match.
match(
"this.is.a.bla.bla.match"));
156 EXPECT_FALSE(object_match.
match(
"this.is.a.great.match--"));
159 TEST(MatchTest, TokensEmptyNoMatch)
162 EXPECT_FALSE(object_match.
match(
"token1"));