-
-
Notifications
You must be signed in to change notification settings - Fork 163
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
80c9ae6
commit 6d23538
Showing
6 changed files
with
95 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,52 @@ | ||
#include "faker-cxx/Computer.h" | ||
|
||
#include <string> | ||
|
||
#include "data/ComputerData.h" | ||
#include "ComputerData.h" | ||
#include "faker-cxx/Helper.h" | ||
|
||
namespace faker | ||
{ | ||
std::string Computer::type() | ||
std::string_view Computer::type() | ||
{ | ||
return Helper::arrayElement(data::ComputerTypes); | ||
return Helper::arrayElement(computerTypes); | ||
} | ||
|
||
std::string Computer::manufacture() | ||
std::string_view Computer::manufacture() | ||
{ | ||
return Helper::arrayElement(data::ComputerManufactures); | ||
return Helper::arrayElement(computerManufacturers); | ||
} | ||
|
||
std::string Computer::model() | ||
std::string_view Computer::model() | ||
{ | ||
return Helper::arrayElement(data::ComputerModels); | ||
return Helper::arrayElement(computerModels); | ||
} | ||
|
||
std::string Computer::cpuManufacture() | ||
std::string_view Computer::cpuManufacture() | ||
{ | ||
return Helper::arrayElement(data::ComputerCPUManufactures); | ||
return Helper::arrayElement(cpuManufacturers); | ||
} | ||
|
||
std::string Computer::cpuType() | ||
std::string_view Computer::cpuType() | ||
{ | ||
return Helper::arrayElement(data::ComputerCPUTypes); | ||
return Helper::arrayElement(cpuTypes); | ||
} | ||
|
||
std::string Computer::cpuModel() | ||
std::string_view Computer::cpuModel() | ||
{ | ||
return Helper::arrayElement(data::ComputerCPUModels); | ||
return Helper::arrayElement(cpuModels); | ||
} | ||
|
||
std::string Computer::gpuManufacture() | ||
std::string_view Computer::gpuManufacture() | ||
{ | ||
return Helper::arrayElement(data::ComputerGPUManufactures); | ||
return Helper::arrayElement(gpuManufacturers); | ||
} | ||
|
||
std::string Computer::gpuType() | ||
std::string_view Computer::gpuType() | ||
{ | ||
return Helper::arrayElement(data::ComputerGPUTypes); | ||
return Helper::arrayElement(gpuTypes); | ||
} | ||
|
||
std::string Computer::gpuModel() | ||
std::string_view Computer::gpuModel() | ||
{ | ||
return Helper::arrayElement(data::ComputerGPUModels); | ||
return Helper::arrayElement(gpuModels); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#pragma once | ||
|
||
#include <array> | ||
#include <string_view> | ||
|
||
namespace faker | ||
{ | ||
extern const std::array<std::string_view, 4> computerTypes; | ||
extern const std::array<std::string_view, 20> computerManufacturers; | ||
extern const std::array<std::string_view, 45> computerModels; | ||
extern const std::array<std::string_view, 5> cpuManufacturers; | ||
extern const std::array<std::string_view, 12> cpuTypes; | ||
extern const std::array<std::string_view, 26> cpuModels; | ||
extern const std::array<std::string_view, 5> gpuManufacturers; | ||
extern const std::array<std::string_view, 2> gpuTypes; | ||
extern const std::array<std::string_view, 23> gpuModels; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,87 +1,93 @@ | ||
#include "faker-cxx/Computer.h" | ||
|
||
#include <algorithm> | ||
#include <string> | ||
#include <vector> | ||
|
||
#include "gtest/gtest.h" | ||
|
||
#include "computer/data/ComputerData.h" | ||
#include "computer/ComputerData.h" | ||
|
||
using namespace ::testing; | ||
using namespace faker; | ||
|
||
class ComputerTest : public Test | ||
{ | ||
}; | ||
|
||
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; })); | ||
const auto generatedType = Computer::type(); | ||
ASSERT_TRUE(std::ranges::any_of(computerTypes.begin(), computerTypes.end(), | ||
[generatedType](const std::string_view& type) { return type == generatedType; })); | ||
} | ||
|
||
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) | ||
const auto generatedManufacture = Computer::manufacture(); | ||
|
||
ASSERT_TRUE(std::ranges::any_of(computerManufacturers.begin(), computerManufacturers.end(), | ||
[generatedManufacture](const std::string_view& manufacture) | ||
{ return manufacture == generatedManufacture; })); | ||
} | ||
|
||
TEST_F(ComputerTest, ComputerModelGeneration) | ||
{ | ||
std::string generatedModel = Computer::model(); | ||
ASSERT_TRUE(std::ranges::any_of(faker::data::ComputerModels.begin(), faker::data::ComputerModels.end(), | ||
[generatedModel](const std::string& model) { return model == generatedModel; })); | ||
const auto generatedModel = Computer::model(); | ||
|
||
ASSERT_TRUE(std::ranges::any_of(computerModels.begin(), computerModels.end(), | ||
[generatedModel](const std::string_view& model) | ||
{ return model == generatedModel; })); | ||
} | ||
|
||
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) | ||
const auto generatedCPUManufacture = Computer::cpuManufacture(); | ||
|
||
ASSERT_TRUE(std::ranges::any_of(cpuManufacturers.begin(), cpuManufacturers.end(), | ||
[generatedCPUManufacture](const std::string_view& 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(), | ||
[generatedCPUType](const std::string& cpuType) | ||
const auto generatedCPUType = Computer::cpuType(); | ||
|
||
ASSERT_TRUE(std::ranges::any_of(cpuTypes.begin(), cpuTypes.end(), | ||
[generatedCPUType](const std::string_view& 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(), | ||
[generatedCPUModel](const std::string& cpuModel) | ||
const auto generatedCPUModel = Computer::cpuModel(); | ||
|
||
ASSERT_TRUE(std::ranges::any_of(cpuModels.begin(), cpuModels.end(), | ||
[generatedCPUModel](const std::string_view& cpuModel) | ||
{ return cpuModel == generatedCPUModel; })); | ||
} | ||
|
||
TEST_F(ComputerTest, ComputerGPUManufactureGeneration) | ||
{ | ||
std::string generatedGPUManufacture = Computer::gpuManufacture(); | ||
ASSERT_TRUE(std::ranges::any_of(faker::data::ComputerGPUManufactures.begin(), | ||
faker::data::ComputerGPUManufactures.end(), | ||
[generatedGPUManufacture](const std::string& gpuManufacture) | ||
const auto generatedGPUManufacture = Computer::gpuManufacture(); | ||
|
||
ASSERT_TRUE(std::ranges::any_of(gpuManufacturers.begin(), gpuManufacturers.end(), | ||
[generatedGPUManufacture](const std::string_view& gpuManufacture) | ||
{ return gpuManufacture == generatedGPUManufacture; })); | ||
} | ||
|
||
TEST_F(ComputerTest, ComputerGPUTypeGeneration) | ||
{ | ||
std::string generatedGPUType = Computer::gpuType(); | ||
ASSERT_TRUE(std::ranges::any_of(faker::data::ComputerGPUTypes.begin(), faker::data::ComputerGPUTypes.end(), | ||
[generatedGPUType](const std::string& gpuType) | ||
const auto generatedGPUType = Computer::gpuType(); | ||
|
||
ASSERT_TRUE(std::ranges::any_of(gpuTypes.begin(), gpuTypes.end(), | ||
[generatedGPUType](const std::string_view& gpuType) | ||
{ return gpuType == generatedGPUType; })); | ||
} | ||
|
||
TEST_F(ComputerTest, ComputerGPUModelGeneration) | ||
{ | ||
std::string generatedGPUModel = Computer::gpuModel(); | ||
ASSERT_TRUE(std::ranges::any_of(faker::data::ComputerGPUModels.begin(), faker::data::ComputerGPUModels.end(), | ||
[generatedGPUModel](const std::string& gpuModel) | ||
const auto generatedGPUModel = Computer::gpuModel(); | ||
|
||
ASSERT_TRUE(std::ranges::any_of(gpuModels.begin(), gpuModels.end(), | ||
[generatedGPUModel](const std::string_view& gpuModel) | ||
{ return gpuModel == generatedGPUModel; })); | ||
} |