Skip to content

Commit

Permalink
test: hacker module testcase added (cieslarmichal#828)
Browse files Browse the repository at this point in the history
* test case added for hacker module for codecoverage

Signed-off-by: Guru Mehar Rachaputi <[email protected]>
  • Loading branch information
00thirdeye00 authored Jul 22, 2024
1 parent a7410f3 commit 92c0404
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
12 changes: 6 additions & 6 deletions src/modules/hacker_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@ const auto nouns = std::to_array<std::string_view>({

const auto phrases = std::to_array<std::string_view>({
"If we {verb} the {noun}, we can get to the {abbreviation} {noun} through the {adjective} "
"{abbreviation} {noun}!",
"We need to {verb} the {adjective} {abbreviation} {noun}!",
"Try to {verb} the {abbreviation} {noun}, maybe it will {verb} the {adjective} {noun}!",
"{abbreviation} {ingverb} {noun}!",
"We need to {verb} the {adjective} {abbreviation} {ingverb} {noun}!",
"Try to {verb} the {abbreviation} {noun}, {ingverb} maybe it will {verb} the {adjective} {noun}!",
"You can't {verb} the {noun} without {ingverb} the {adjective} {abbreviation} {noun}!",
"Use the {adjective} {abbreviation} {noun}, then you can {verb} the {adjective} {noun}!",
"Use the {adjective} {abbreviation} {noun}, then you can {verb} the {adjective} {ingverb} {noun}!",
"The {abbreviation} {noun} is down, {verb} the {adjective} {noun} so we can {verb} the "
"{abbreviation} {noun}!",
"{abbreviation} {ingverb} {noun}!",
"{ingverb} the {noun} won't do anything, we need to {verb} the {adjective} {abbreviation} "
"{noun}!",
"I'll {verb} the {adjective} {abbreviation} {noun}, that should {noun} the {abbreviation} "
"I'll {verb} the {adjective} {abbreviation} {noun}, that should {noun} {ingverb} the {abbreviation} "
"{noun}!",
});

Expand Down
15 changes: 12 additions & 3 deletions tests/modules/hacker_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ TEST_F(HackerTest, shouldGenerateIngverb)
TEST_F(HackerTest, shouldGeneratePhrase)
{
const auto generatedPhrase = phrase();
bool hasAdjective, hasNoun, hasVerb, hasAbbreviation;
hasAdjective = hasNoun = hasVerb = hasAbbreviation = false;
bool hasAdjective, hasNoun, hasVerb, hasAbbreviation, hasIngverb;
hasAdjective = hasNoun = hasVerb = hasAbbreviation = hasIngverb = false;

for (const std::string_view& adj : adjectives)
{
Expand Down Expand Up @@ -99,5 +99,14 @@ TEST_F(HackerTest, shouldGeneratePhrase)
}
}

ASSERT_TRUE((hasAdjective && hasNoun && hasVerb && hasAbbreviation));
for (const std::string_view& ingverb : ingverbs)
{
if (generatedPhrase.find(ingverb) != std::string::npos)
{
hasIngverb = true;
break;
}
}

ASSERT_TRUE((hasAdjective && hasNoun && hasVerb && hasAbbreviation && hasIngverb));
}

0 comments on commit 92c0404

Please sign in to comment.