Skip to content

Commit

Permalink
reformat code (#392)
Browse files Browse the repository at this point in the history
  • Loading branch information
cieslarmichal authored Jan 1, 2024
1 parent e26f98f commit b9cfea4
Show file tree
Hide file tree
Showing 32 changed files with 367 additions and 499 deletions.
3 changes: 2 additions & 1 deletion include/faker-cxx/Date.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ namespace faker
class Date
{
public:
enum class DateFormat {
enum class DateFormat
{
ISO,
Timestamp,
};
Expand Down
34 changes: 18 additions & 16 deletions include/faker-cxx/Science.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,13 @@ class Science
* @returns ChemicalElement
*
* @code
* Science::chemicalElement() // Object of ChemicalElement containing info about a random element in the periodic table.
* Science::chemicalElement() // Object of ChemicalElement containing info about a random element in the periodic
* table.
* @endcode
*
*
*/
static ChemicalElement chemicalElement();

/**
* @brief Returns a unit of measurement for either distance, mass, time, temp, current.
*
Expand All @@ -81,22 +82,23 @@ class Science
* @code
* Science::unit() // Object of Unit containing info about a random unit of measurement.
* @endcode
*
*
*/
static Unit unit();

/**
* @brief Returns a unit of measurement for either distance.
*
* @returns Unit
*
* @code
* Science::distanceUnit() // Object of Unit containing info about a random unit of measurement used to measure distance.
* Science::distanceUnit() // Object of Unit containing info about a random unit of measurement used to measure
* distance.
* @endcode
*
*
*/
static Unit distanceUnit();

/**
* @brief Returns a unit of measurement for either time.
*
Expand All @@ -105,7 +107,7 @@ class Science
* @code
* Science::timeUnit() // Object of Unit containing info about a random unit of measurement used to measure time.
* @endcode
*
*
*/
static Unit timeUnit();

Expand All @@ -117,7 +119,7 @@ class Science
* @code
* Science::massUnit() // Object of Unit containing info about a random unit of measurement used to measure mass.
* @endcode
*
*
*/
static Unit massUnit();

Expand All @@ -129,22 +131,22 @@ class Science
* @code
* Science::tempUnit() // Object of Unit containing info about a random unit of measurement used to measure temp.
* @endcode
*
*
*/
static Unit tempUnit();

/**
* @brief Returns a unit of measurement for either current.
*
* @returns Unit
*
* @code
* Science::currentUnit() // Object of Unit containing info about a random unit of measurement used to measure current.
* Science::currentUnit() // Object of Unit containing info about a random unit of measurement used to measure
* current.
* @endcode
*
*
*/
static Unit currentUnit();

};

}
}
10 changes: 5 additions & 5 deletions include/faker-cxx/Structure.h
Original file line number Diff line number Diff line change
Expand Up @@ -347,22 +347,22 @@ enum class Token

};


class Structure
{
public:
/**
* @brief Get a json string based on input
* @brief Get a json string based on input
*
* @return a josn string based on user selected tokens
* @return a josn string based on user selected tokens
*
* @code
* std::map<std::string, faker::Token> testTokens;
* testTokens.emplace("Airport name", faker::Token::AirlineAirportName);
* testTokens.emplace("Bird name", faker::Token::AnimalBird);
* testTokens.emplace("Actor name", faker::Token::MovieActor);
* testTokens.emplace("Book title", faker::Token::BookTitle);
* Structure::json(testTokens) // {"FoodName":"Cajun Shrimp Pasta","airlineType":"narrowbody","airportName":"Brisbane International Airport"}
* Structure::json(testTokens) // {"FoodName":"Cajun Shrimp
* Pasta","airlineType":"narrowbody","airportName":"Brisbane International Airport"}
* @endcode
*/
static std::string json(const std::map<std::string, faker::Token> items);
Expand All @@ -387,4 +387,4 @@ class Structure
private:
};

}
}
27 changes: 13 additions & 14 deletions include/faker-cxx/types/Language.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,18 @@ enum class Language
inline std::string toString(Language language)
{
static const std::map<Language, std::string> languageToStringMapping{
{Language::English, "English"}, {Language::Polish, "Polish"}, {Language::Italian, "Italian"},
{Language::French, "French"}, {Language::German, "German"}, {Language::Russian, "Russian"},
{Language::Romanian, "Romanian"}, {Language::Hindi, "Hindi"}, {Language::Finnish, "Finnish"},
{Language::Nepali, "Nepali"}, {Language::Spanish, "Spanish"}, {Language::Turkish, "Turkish"},
{Language::Czech, "Czech"}, {Language::Slovak, "Slovak"}, {Language::Ukrainian, "Ukrainian"},
{Language::Danish, "Danish"}, {Language::Swedish, "Swedish"},
{Language::Portuguese, "Portuguese"}, {Language::Norwegian, "Norwegian"}, {Language::Japanese, "Japanese"},
{Language::Hungarian, "Hungarian"}, {Language::Croatian, "Croatian"}, {Language::Greek, "Greek"},
{Language::Slovene, "Slovene"}, {Language::Dutch, "Dutch"}, {Language::Mandarin, "Mandarin"},
{Language::Korean, "Korean"}, {Language::Serbian, "Serbian"}, {Language::Macedonian, "Macedonian"},
{Language::Albanian, "Albanian"}, {Language::Latvian, "Latvian"}, {Language::Irish, "Irish"},
{Language::Belarusian, "Belarusian"}, {Language::Estonian, "Estonian"}
};
{Language::English, "English"}, {Language::Polish, "Polish"}, {Language::Italian, "Italian"},
{Language::French, "French"}, {Language::German, "German"}, {Language::Russian, "Russian"},
{Language::Romanian, "Romanian"}, {Language::Hindi, "Hindi"}, {Language::Finnish, "Finnish"},
{Language::Nepali, "Nepali"}, {Language::Spanish, "Spanish"}, {Language::Turkish, "Turkish"},
{Language::Czech, "Czech"}, {Language::Slovak, "Slovak"}, {Language::Ukrainian, "Ukrainian"},
{Language::Danish, "Danish"}, {Language::Swedish, "Swedish"}, {Language::Portuguese, "Portuguese"},
{Language::Norwegian, "Norwegian"}, {Language::Japanese, "Japanese"}, {Language::Hungarian, "Hungarian"},
{Language::Croatian, "Croatian"}, {Language::Greek, "Greek"}, {Language::Slovene, "Slovene"},
{Language::Dutch, "Dutch"}, {Language::Mandarin, "Mandarin"}, {Language::Korean, "Korean"},
{Language::Serbian, "Serbian"}, {Language::Macedonian, "Macedonian"}, {Language::Albanian, "Albanian"},
{Language::Latvian, "Latvian"}, {Language::Irish, "Irish"}, {Language::Belarusian, "Belarusian"},
{Language::Estonian, "Estonian"}};

return languageToStringMapping.at(language);
}
Expand All @@ -69,4 +68,4 @@ inline std::ostream& operator<<(std::ostream& os, Language language)
return os << toString(language);
}

}
}
4 changes: 1 addition & 3 deletions include/faker-cxx/types/Sex.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ const std::map<Language, std::map<Sex, std::string>> sexTranslations = {
{Language::Latvian, {{Sex::Male, "Vīrietis"}, {Sex::Female, "Sieviete"}}},
{Language::Belarusian, {{Sex::Male, "Мужчына"}, {Sex::Female, "Жанчына"}}},
{Language::Estonian, {{Sex::Male, "Mees"}, {Sex::Female, "Naine"}}},
{Language::Irish, {{Sex::Male, "fireannach"}, {Sex::Female, "baineann"}}}
};
{Language::Irish, {{Sex::Male, "fireannach"}, {Sex::Female, "baineann"}}}};

inline std::string translateSex(Sex sex, Language language = Language::English)
{
Expand All @@ -66,7 +65,6 @@ inline std::string toString(Sex sex, Language language = Language::English)
return translateSex(sex, language);
}


inline std::ostream& operator<<(std::ostream& os, Sex sex)
{
return os << toString(sex);
Expand Down
5 changes: 2 additions & 3 deletions src/common/JsonHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@ std::map<std::string, std::string> JsonHelper::simpleJsonParser(std::string json
std::string key, value, temp;
char ch;


while (stream >> ch && ch != '}')
{
if (ch == '"' )
if (ch == '"')
{

std::getline(stream, key, '"');
Expand All @@ -28,4 +27,4 @@ std::map<std::string, std::string> JsonHelper::simpleJsonParser(std::string json

return result;
}
}
}
4 changes: 2 additions & 2 deletions src/common/JsonHelper.h
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
#pragma once

#include <map>
#include <string>
#include <sstream>
#include <string>

namespace faker
{

class JsonHelper
{
public:
// this function parse simple jason like {"key1":"value1","key2":"value2"}
// this function parse simple jason like {"key1":"value1","key2":"value2"}
static std::map<std::string, std::string> simpleJsonParser(std::string json);
};
}
9 changes: 4 additions & 5 deletions src/common/JsonHelperTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,19 @@ using namespace faker;
class JsonHelperTest : public Test
{
public:

};

TEST_F(JsonHelperTest, simpleJsonParser ) {
TEST_F(JsonHelperTest, simpleJsonParser)
{
const auto result = JsonHelper::simpleJsonParser("{\"Test1\":\"Hello\",\"Test2\":\"World!\"}");

const auto key1 = result.find("Test1")->first;
const auto key2 = result.find("Test2")->first;
const auto value1 = result.find("Test1")->second;
const auto value2 = result.find("Test2")->second;

ASSERT_EQ(key1, "Test1");
ASSERT_EQ(key2, "Test2");
ASSERT_EQ(value1, "Hello");
ASSERT_EQ(value2, "World!");

}
}
21 changes: 11 additions & 10 deletions src/modules/computer/ComputerTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ using namespace ::testing;
using namespace faker;
class ComputerTest : public Test
{

};

TEST_F(ComputerTest, ComputerTypeGeneration) {
TEST_F(ComputerTest, ComputerTypeGeneration)
{
std::string generatedType = Computer::type();
ASSERT_TRUE(std::ranges::any_of(faker::data::ComputerTypes.begin(), faker::data::ComputerTypes.end(),
[generatedType](const std::string& type) { return type == generatedType; }));
Expand All @@ -24,7 +24,8 @@ TEST_F(ComputerTest, ComputerManufactureGeneration)
{
std::string generatedManufacture = Computer::manufacture();
ASSERT_TRUE(std::ranges::any_of(faker::data::ComputerManufactures.begin(), faker::data::ComputerManufactures.end(),
[generatedManufacture](const std::string& manufacture) { return manufacture == generatedManufacture; }));
[generatedManufacture](const std::string& manufacture)
{ return manufacture == generatedManufacture; }));
}

TEST_F(ComputerTest, ComputerModelGeneration)
Expand All @@ -37,24 +38,24 @@ TEST_F(ComputerTest, ComputerModelGeneration)
TEST_F(ComputerTest, ComputerCPUManufactureGeneration)
{
std::string generatedCPUManufacture = Computer::cpuManufacture();
ASSERT_TRUE(std::ranges::any_of(faker::data::ComputerCPUManufactures.begin(), faker::data::ComputerCPUManufactures.end(),
[generatedCPUManufacture](const std::string& cpuManufacture) { return cpuManufacture == generatedCPUManufacture; }));
ASSERT_TRUE(std::ranges::any_of(faker::data::ComputerCPUManufactures.begin(),
faker::data::ComputerCPUManufactures.end(),
[generatedCPUManufacture](const std::string& cpuManufacture)
{ return cpuManufacture == generatedCPUManufacture; }));
}

TEST_F(ComputerTest, ComputerCPUTypeGeneration)
{
std::string generatedCPUType = Computer::cpuType();
ASSERT_TRUE(std::ranges::any_of(faker::data::ComputerCPUTypes.begin(),
faker::data::ComputerCPUTypes.end(),
ASSERT_TRUE(std::ranges::any_of(faker::data::ComputerCPUTypes.begin(), faker::data::ComputerCPUTypes.end(),
[generatedCPUType](const std::string& cpuType)
{ return cpuType == generatedCPUType; }));
}

TEST_F(ComputerTest, ComputerCPUModelGeneration)
{
std::string generatedCPUModel = Computer::cpuModel();
ASSERT_TRUE(std::ranges::any_of(faker::data::ComputerCPUModels.begin(),
faker::data::ComputerCPUModels.end(),
ASSERT_TRUE(std::ranges::any_of(faker::data::ComputerCPUModels.begin(), faker::data::ComputerCPUModels.end(),
[generatedCPUModel](const std::string& cpuModel)
{ return cpuModel == generatedCPUModel; }));
}
Expand Down Expand Up @@ -82,4 +83,4 @@ TEST_F(ComputerTest, ComputerGPUModelGeneration)
ASSERT_TRUE(std::ranges::any_of(faker::data::ComputerGPUModels.begin(), faker::data::ComputerGPUModels.end(),
[generatedGPUModel](const std::string& gpuModel)
{ return gpuModel == generatedGPUModel; }));
}
}
15 changes: 7 additions & 8 deletions src/modules/computer/data/ComputerData.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,12 @@ const std::vector<std::string> ComputerCPUTypes = {
"Dual-Core", "Quad-Core", "Hexa-Core", "Octa-Core", "Deca-Core", "Heterogeneous System Architecture",
"ARM", "x86", "64-bit", "32-bit", "RISC", "CISC"};

const std::vector<std::string>
ComputerCPUModels = {"Core i9-11900K", "Core i7-11700K", "Core i5-11600K", "Core i3-10100", "Xeon E-2278G",
"Pentium Gold G6400", "Ryzen 9 5950X", "Ryzen 7 5800X", "Ryzen 5 5600X", "Ryzen 3 3300X",
"EPYC 7763", "Athlon 3000G", "Apple M1", "Apple M1 Max", "Apple M1 Ultra",
"Apple M2", "Apple M2 Pro", "Apple M2 Max", "Apple M3 Ultra", "Apple M3 Pro",
"Apple M3 Max", "Apple M3 Ultra", "IBM POWER9", "ARM Cortex-A78", "ARM Cortex-A76",
"ARM Cortex-A55"};
const std::vector<std::string> ComputerCPUModels = {
"Core i9-11900K", "Core i7-11700K", "Core i5-11600K", "Core i3-10100", "Xeon E-2278G", "Pentium Gold G6400",
"Ryzen 9 5950X", "Ryzen 7 5800X", "Ryzen 5 5600X", "Ryzen 3 3300X", "EPYC 7763", "Athlon 3000G",
"Apple M1", "Apple M1 Max", "Apple M1 Ultra", "Apple M2", "Apple M2 Pro", "Apple M2 Max",
"Apple M3 Ultra", "Apple M3 Pro", "Apple M3 Max", "Apple M3 Ultra", "IBM POWER9", "ARM Cortex-A78",
"ARM Cortex-A76", "ARM Cortex-A55"};

const std::vector<std::string> ComputerGPUManufactures = {
"NVIDIA", "AMD", "Intel", "ARM", "Qualcomm",
Expand Down Expand Up @@ -69,4 +68,4 @@ const std::vector<std::string> ComputerGPUModels = {"NVIDIA GeForce RTX 3090",
// todo - add more component names

}
}
}
Loading

0 comments on commit b9cfea4

Please sign in to comment.