Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: change medicine class to namespace #733

Merged
merged 1 commit into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 31 additions & 36 deletions include/faker-cxx/Medicine.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,39 @@

#include <string_view>

namespace faker
namespace faker::medicine
{
class Medicine
{

public:
/**
* @brief Returns a random medical condition.
*
* @returns Medical condition.
*
* @code
* Medicine::condition() // "AIDS"
* @endcode
*/
static std::string_view condition();
/**
* @brief Returns a random medical condition.
*
* @returns Medical condition.
*
* @code
* medicine::condition() // "AIDS"
* @endcode
*/
std::string_view condition();

/**
* @brief Returns a random medical test
*
* @returns Medical test.
*
* @code
* Medicine::medicalTest() // "pulmonary auscultation"
* @endcode
*/
static std::string_view medicalTest();
/**
* @brief Returns a random medical test
*
* @returns Medical test.
*
* @code
* medicine::medicalTest() // "pulmonary auscultation"
* @endcode
*/
std::string_view medicalTest();

/**
* @brief Returns a random Medical specialty
*
* @returns Medical specialty.
*
* @code
* Medicine::specialty() // "Cardiology"
* @endcode
*/
/**
* @brief Returns a random Medical specialty
*
* @returns Medical specialty.
*
* @code
* medicine::specialty() // "Cardiology"
* @endcode
*/

static std::string_view specialty();
};
std::string_view specialty();
}
14 changes: 7 additions & 7 deletions src/modules/medicine/Medicine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@
#include "faker-cxx/Helper.h"
#include "MedicineData.h"

namespace faker
namespace faker::medicine
{
std::string_view Medicine::condition()
std::string_view condition()
{
return Helper::arrayElement(medicine::medicalConditions);
return Helper::arrayElement(medicalConditions);
}

std::string_view Medicine::medicalTest()
std::string_view medicalTest()
{
return Helper::arrayElement(medicine::medicalTests);
return Helper::arrayElement(medicalTests);
}

std::string_view Medicine::specialty()
std::string_view specialty()
{
return Helper::arrayElement(medicine::specialties);
return Helper::arrayElement(specialties);
}

}
7 changes: 3 additions & 4 deletions src/modules/medicine/MedicineData.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const auto medicalConditions = std::to_array<std::string_view>({
"Thalassemia Major",
"Tuberculosis",
"Ulcerative Colitis",
"Ulcers, Stomach or Intestinal"
"Ulcers, Stomach or Intestinal",
});

const auto medicalTests = std::to_array<std::string_view>({
Expand Down Expand Up @@ -102,7 +102,7 @@ const auto medicalTests = std::to_array<std::string_view>({
"skin biopsy",
"thoracentesis",
"urodynamic testing",
"vaginal examination"
"vaginal examination",
});

const auto specialties = std::to_array<std::string_view>({
Expand Down Expand Up @@ -160,7 +160,6 @@ const auto specialties = std::to_array<std::string_view>({
"Tropical medicine",
"Urology",
"Vascular surgery",
"Venereology"
"Venereology",
});

}
14 changes: 7 additions & 7 deletions tests/modules/medicine/MedicineTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include "medicine/MedicineData.h"

using namespace ::testing;
using namespace faker;
using namespace faker::medicine;

class MedicineTest : public Test
{
Expand All @@ -17,25 +17,25 @@ class MedicineTest : public Test

TEST_F(MedicineTest, shouldGenerateMedicalCondition)
{
const auto generatedMedicalCondition = Medicine::condition();
const auto generatedMedicalCondition = condition();

ASSERT_TRUE(std::ranges::any_of(medicine::medicalConditions,
ASSERT_TRUE(std::ranges::any_of(medicalConditions,
[generatedMedicalCondition](const std::string_view& medicalCondition)
{ return medicalCondition == generatedMedicalCondition; }));
}

TEST_F(MedicineTest, shouldGenerateMedicalTest)
{
const auto generatedMedicalTest = Medicine::medicalTest();
const auto generatedMedicalTest = medicalTest();

ASSERT_TRUE(std::ranges::any_of(medicine::medicalTests, [generatedMedicalTest](const std::string_view& medicalTest)
ASSERT_TRUE(std::ranges::any_of(medicalTests, [generatedMedicalTest](const std::string_view& medicalTest)
{ return medicalTest == generatedMedicalTest; }));
}

TEST_F(MedicineTest, shouldGenerateSpecialty)
{
const auto generatedSpecialty = Medicine::specialty();
const auto generatedSpecialty = specialty();

ASSERT_TRUE(std::ranges::any_of(medicine::specialties, [generatedSpecialty](const std::string_view& specialty)
ASSERT_TRUE(std::ranges::any_of(specialties, [generatedSpecialty](const std::string_view& specialty)
{ return specialty == generatedSpecialty; }));
}
Loading