From b427d698ad5580e7d286cc68b2b764a9397e0803 Mon Sep 17 00:00:00 2001 From: Guru Mehar Rachaputi Date: Wed, 24 Jul 2024 09:12:07 +0200 Subject: [PATCH] test: finance module testcase added (#830) * test case added to finance module for code coverage Signed-off-by: Guru Mehar Rachaputi --- include/faker-cxx/finance.h | 1 + src/modules/finance.cpp | 2 ++ tests/modules/finance_test.cpp | 6 ++++++ 3 files changed, 9 insertions(+) diff --git a/include/faker-cxx/finance.h b/include/faker-cxx/finance.h index d84aa900e..cf77f6232 100644 --- a/include/faker-cxx/finance.h +++ b/include/faker-cxx/finance.h @@ -207,6 +207,7 @@ namespace faker::finance enum class CreditCardType { + DefaultCard, AmericanExpress, Discover, MasterCard, diff --git a/src/modules/finance.cpp b/src/modules/finance.cpp index e96a5e90d..44f274a78 100644 --- a/src/modules/finance.cpp +++ b/src/modules/finance.cpp @@ -128,6 +128,8 @@ std::string creditCardNumber(std::optional creditCardType) static_cast(helper::arrayElement(masterCardCreditCardFormats))); case CreditCardType::Visa: return helper::replaceCreditCardSymbols(static_cast(helper::arrayElement(visaCreditCardFormats))); + default: + ; } return ""; diff --git a/tests/modules/finance_test.cpp b/tests/modules/finance_test.cpp index 6522bd117..e65bc7379 100644 --- a/tests/modules/finance_test.cpp +++ b/tests/modules/finance_test.cpp @@ -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);