Skip to content

Commit

Permalink
add computer module
Browse files Browse the repository at this point in the history
  • Loading branch information
alisedighmoghadam committed Dec 1, 2023
1 parent 0a1eb47 commit d3afe39
Show file tree
Hide file tree
Showing 5 changed files with 237 additions and 2 deletions.
6 changes: 4 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ set(FAKER_SOURCES
src/common/WeatherHelper.cpp
src/modules/airline/Airline.cpp
src/modules/image/Image.cpp
src/modules/crypto/Crypto.cpp)
src/modules/crypto/Crypto.cpp
src/modules/computer/Computer.cpp)

set(FAKER_UT_SOURCES
src/modules/animal/AnimalTest.cpp
Expand Down Expand Up @@ -93,7 +94,8 @@ set(FAKER_UT_SOURCES
src/common/WeatherHelperTest.cpp
src/modules/airline/AirlineTest.cpp
src/modules/image/ImageTest.cpp
src/modules/crypto/CryptoTest.cpp)
src/modules/crypto/CryptoTest.cpp
src/modules/computer/ComputerTest.cpp)

add_library(${LIBRARY_NAME} ${FAKER_SOURCES})

Expand Down
25 changes: 25 additions & 0 deletions include/faker-cxx/Computer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#pragma once

#include <string>


namespace faker
{
class Computer
{
public:
static std::string type();
static std::string manufacture();
static std::string model();
static std::string cpuManufacture();
static std::string cpuType();
static std::string cpuModel();
static std::string gpuManufacture();
static std::string gpuType();
static std::string gpuModel();


private:
};

}
51 changes: 51 additions & 0 deletions src/modules/computer/Computer.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#include "faker-cxx/Computer.h"

#include <string>

#include "data/ComputerData.h"
#include "faker-cxx/Helper.h"

std::string faker::Computer::type()
{
return Helper::arrayElement(faker::data::ComputerTypes);
}

std::string faker::Computer::manufacture()
{
return Helper::arrayElement(faker::data::ComputerManufactures);
}

std::string faker::Computer::model()
{
return Helper::arrayElement(faker::data::ComputerModels);
}

std::string faker::Computer::cpuManufacture()
{
return Helper::arrayElement(faker::data::ComputerCPUManufactures);
}

std::string faker::Computer::cpuType()
{
return Helper::arrayElement(faker::data::ComputerCPUTypes);
}

std::string faker::Computer::cpuModel()
{
return Helper::arrayElement(faker::data::ComputerCPUModels);
}

std::string faker::Computer::gpuManufacture()
{
return Helper::arrayElement(faker::data::ComputerGPUManufactures);
}

std::string faker::Computer::gpuType()
{
return Helper::arrayElement(faker::data::ComputerGPUTypes);
}

std::string faker::Computer::gpuModel()
{
return Helper::arrayElement(faker::data::ComputerGPUModels);
}
85 changes: 85 additions & 0 deletions src/modules/computer/ComputerTest.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
#include "faker-cxx/Computer.h"

#include <algorithm>
#include <string>
#include <vector>

#include "gtest/gtest.h"

#include "data/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; }));
}

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; }));
}

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; }));
}

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; }));
}

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)
{ 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)
{ 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)
{ 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)
{ 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)
{ return gpuModel == generatedGPUModel; }));
}
72 changes: 72 additions & 0 deletions src/modules/computer/data/ComputerData.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#pragma once
#include <string>
#include <vector>

namespace faker
{
namespace data
{
const std::vector<std::string> ComputerTypes = {"Desktop", "Laptop", "Mainframe", "Supercomputer"};

const std::vector<std::string> ComputerManufactures = {
"Apple", "Dell", "HP", "Lenovo", "Acer", "Asus", "Microsoft", "Samsung", "Toshiba", "Sony",
"MSI", "Gateway", "Fujitsu", "HCL", "Panasonic", "LG", "IBM", "Compaq", "Alienware", "Razer"};

// todo - it is possible to link the models to brands in the future.
const std::vector<std::string> ComputerModels = {
"MacBook Air", "MacBook Pro", "iMac", "Mac mini", "Inspiron", "XPS", "Alienware",
"Latitude", "Precision", "Spectre", "Envy", "Pavilion", "EliteBook", "ThinkPad",
"Yoga", "Legion", "IdeaPad", "Aspire", "Predator", "TravelMate", "Swift",
"ZenBook", "ROG", "VivoBook", "TUF", "Surface Laptop", "Surface Pro", "Surface Book",
"Galaxy Book", "Notebook", "Odyssey", "Portégé", "Satellite", "VAIO", "GS Series",
"GE Series", "GL Series", "ThinkCentre", "ThinkStation", "Presario", "Area-51", "m15",
"Aurora", "Blade", "Blade Stealth", "NUC"};

const std::vector<std::string> ComputerCPUManufactures = {"Intel", "AMD", "ARM", "IBM", "Apple"};

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> ComputerGPUManufactures = {
"NVIDIA", "AMD", "Intel", "ARM", "Qualcomm",
};

const std::vector<std::string> ComputerGPUTypes = {"Integrated", "Discrete"};

const std::vector<std::string> ComputerGPUModels = {"NVIDIA GeForce RTX 3090",
"NVIDIA GeForce RTX 3080",
"NVIDIA GeForce RTX 3070",
"NVIDIA GeForce GTX 1660 Ti",
"NVIDIA GeForce GTX 1660 Super",
"NVIDIA GeForce GTX 1660",
"NVIDIA GeForce GTX 1650 Super",
"NVIDIA GeForce GTX 1650",
"AMD Radeon RX 6900 XT",
"AMD Radeon RX 6800 XT",
"AMD Radeon RX 6700 XT",
"Intel Xe Graphics",
"ARM Mali-G78 MP14",
"Qualcomm Adreno 660",
"Imagination PowerVR GT7600",
"VIA S3 Graphics Chrome 520",
"Matrox Millennium G200",
"SiS 315",
"3dfx Voodoo3",
"S3 Graphics Savage4",
"XGI Volari V8",
"Trident Blade3D",
"ATI Radeon 9800 Pro"};

// todo - add more component names

}
}

0 comments on commit d3afe39

Please sign in to comment.