Fix CypherMainVisitor tests relying on traversal order

Summary:
The tests `RelationshipPatternNoDetails` and `PatternPartBraces` in
`memgraph__unit__cypher_main_visitor` checked for the names of the anonymous
identifiers and therefore implicitly relied on the order of the traversal of the
tree.

This "bug" surfaced when Memgraph was compiled with GCC (tested on >= 6.3.0).

Reviewers: mtomic, teon.banek, mferencevic

Reviewed By: mtomic

Subscribers: pullbot

Differential Revision: https://phabricator.memgraph.io/D1945
This commit is contained in:
Lovro Lugovic 2019-04-10 10:48:13 +02:00
parent 7cf9138308
commit 6b62145a59

View File

@ -1076,11 +1076,20 @@ TEST_P(CypherMainVisitorTest, RelationshipPatternNoDetails) {
ASSERT_TRUE(edge);
auto *node2 = dynamic_cast<NodeAtom *>(match->patterns_[0]->atoms_[2]);
ASSERT_TRUE(node2);
EXPECT_EQ(edge->direction_, EdgeAtom::Direction::BOTH);
ASSERT_TRUE(node1->identifier_);
ASSERT_TRUE(edge->identifier_);
EXPECT_THAT(edge->identifier_->name_,
CypherMainVisitor::kAnonPrefix + std::to_string(2));
ASSERT_TRUE(node2->identifier_);
EXPECT_THAT(
std::vector<std::string>({node1->identifier_->name_,
edge->identifier_->name_,
node2->identifier_->name_}),
UnorderedElementsAre(CypherMainVisitor::kAnonPrefix + std::to_string(1),
CypherMainVisitor::kAnonPrefix + std::to_string(2),
CypherMainVisitor::kAnonPrefix + std::to_string(3)));
EXPECT_FALSE(node1->identifier_->user_declared_);
EXPECT_FALSE(edge->identifier_->user_declared_);
EXPECT_FALSE(node2->identifier_->user_declared_);
EXPECT_EQ(edge->direction_, EdgeAtom::Direction::BOTH);
}
// PatternPart in braces.
@ -1103,11 +1112,20 @@ TEST_P(CypherMainVisitorTest, PatternPartBraces) {
ASSERT_TRUE(edge);
auto *node2 = dynamic_cast<NodeAtom *>(match->patterns_[0]->atoms_[2]);
ASSERT_TRUE(node2);
EXPECT_EQ(edge->direction_, EdgeAtom::Direction::BOTH);
ASSERT_TRUE(node1->identifier_);
ASSERT_TRUE(edge->identifier_);
EXPECT_THAT(edge->identifier_->name_,
CypherMainVisitor::kAnonPrefix + std::to_string(2));
ASSERT_TRUE(node2->identifier_);
EXPECT_THAT(
std::vector<std::string>({node1->identifier_->name_,
edge->identifier_->name_,
node2->identifier_->name_}),
UnorderedElementsAre(CypherMainVisitor::kAnonPrefix + std::to_string(1),
CypherMainVisitor::kAnonPrefix + std::to_string(2),
CypherMainVisitor::kAnonPrefix + std::to_string(3)));
EXPECT_FALSE(node1->identifier_->user_declared_);
EXPECT_FALSE(edge->identifier_->user_declared_);
EXPECT_FALSE(node2->identifier_->user_declared_);
EXPECT_EQ(edge->direction_, EdgeAtom::Direction::BOTH);
}
TEST_P(CypherMainVisitorTest, RelationshipPatternDetails) {