Skip to content

Commit

Permalink
test: finance module testcase added (#830)
Browse files Browse the repository at this point in the history
* test case added to finance module for code coverage

Signed-off-by: Guru Mehar Rachaputi <[email protected]>
  • Loading branch information
00thirdeye00 authored Jul 24, 2024
1 parent 55760ef commit b427d69
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/faker-cxx/finance.h
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ namespace faker::finance

enum class CreditCardType
{
DefaultCard,
AmericanExpress,
Discover,
MasterCard,
Expand Down
2 changes: 2 additions & 0 deletions src/modules/finance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ std::string creditCardNumber(std::optional<CreditCardType> creditCardType)
static_cast<std::string>(helper::arrayElement(masterCardCreditCardFormats)));
case CreditCardType::Visa:
return helper::replaceCreditCardSymbols(static_cast<std::string>(helper::arrayElement(visaCreditCardFormats)));
default:
;
}

return "";
Expand Down
6 changes: 6 additions & 0 deletions tests/modules/finance_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,12 @@ TEST_F(FinanceTest, shouldGenerateCreditCardNumber)
ASSERT_TRUE(common::luhnCheck(generatedCreditCardNumber));
}

TEST_F(FinanceTest, shouldGenerateEmptyCreditCardNumber)
{
const auto emptyString = "";
ASSERT_TRUE(emptyString == creditCardNumber(CreditCardType::DefaultCard));
}

TEST_F(FinanceTest, shouldGenerateAmericanExpressCreditCardNumber)
{
const auto generatedCreditCardNumber = creditCardNumber(CreditCardType::AmericanExpress);
Expand Down

0 comments on commit b427d69

Please sign in to comment.