Skip to content

Commit

Permalink
mike-lischke#132 Refactor test a little
Browse files Browse the repository at this point in the history
Signed-off-by: vityaman <vityaman.dev@yandex.ru>
  • Loading branch information
vityaman authored and mike-lischke committed Jul 31, 2024
1 parent 32a793c commit 5e06d07
Showing 1 changed file with 25 additions and 24 deletions.
49 changes: 25 additions & 24 deletions ports/cpp/test/cpp14/Cpp14Test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,23 @@ TEST(CPP14Parser, SimpleExample) { // NOLINT: complexity
CPP14Parser::RulePrimaryexpression,
};

const auto classnameStack = [&] {
auto stack = idexpressionStack;
stack.pop_back();
stack.emplace_back(CPP14Parser::RuleSimpletypespecifier);
stack.emplace_back(CPP14Parser::RuleNestednamespecifier);
stack.emplace_back(CPP14Parser::RuleTypename);
return stack;
}();

const auto namespacenameStack = [&] {
auto stack = idexpressionStack;
stack.pop_back();
stack.emplace_back(CPP14Parser::RuleSimpletypespecifier);
stack.emplace_back(CPP14Parser::RuleNestednamespecifier);
return stack;
}();

EXPECT_THAT(
Keys(candidates.rules),
UnorderedElementsAre(
Expand All @@ -210,30 +227,14 @@ TEST(CPP14Parser, SimpleExample) { // NOLINT: complexity
ElementsAreArray(idexpressionStack)
);

EXPECT_THAT(candidates.rules[CPP14Parser::RuleClassname].ruleList, ElementsAreArray([&] {
auto stack = idexpressionStack;
stack.pop_back();
for (auto rule : {
CPP14Parser::RuleSimpletypespecifier,
CPP14Parser::RuleNestednamespecifier,
CPP14Parser::RuleTypename,
}) {
stack.emplace_back(rule);
}
return stack;
}()));

EXPECT_THAT(candidates.rules[CPP14Parser::RuleNamespacename].ruleList, ElementsAreArray([&] {
auto stack = idexpressionStack;
stack.pop_back();
for (auto rule : {
CPP14Parser::RuleSimpletypespecifier,
CPP14Parser::RuleNestednamespecifier,
}) {
stack.emplace_back(rule);
}
return stack;
}()));
EXPECT_THAT(
candidates.rules[CPP14Parser::RuleClassname].ruleList, ElementsAreArray(classnameStack)
);

EXPECT_THAT(
candidates.rules[CPP14Parser::RuleNamespacename].ruleList,
ElementsAreArray(namespacenameStack)
);
}
{
// 2) Within the method body.
Expand Down

0 comments on commit 5e06d07

Please sign in to comment.