Skip to content

Commit

Permalink
Add Vietnamese people names
Browse files Browse the repository at this point in the history
  • Loading branch information
joshhn committed Jan 5, 2024
1 parent a610aed commit b7d2912
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 14 deletions.
26 changes: 13 additions & 13 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

option(BUILD_FAKER_TESTS DEFAULT ON)

if (MSVC)
if(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++20 /permissive- /bigobj")
else ()
else()
set(CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS} -Wall -Wextra -Wpedantic -Wconversion -Wformat -Werror"
)
endif ()
endif()

set(LIBRARY_NAME faker-cxx)

Expand Down Expand Up @@ -113,13 +113,13 @@ target_include_directories(
INTERFACE "${CMAKE_CURRENT_LIST_DIR}/include"
PRIVATE "${CMAKE_CURRENT_LIST_DIR}/include")

if (APPLE OR (WIN32 AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU"))
if(APPLE OR (WIN32 AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU"))
add_subdirectory(externals/fmt)
set(FMT_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/externals/fmt/include")
target_link_libraries(${LIBRARY_NAME} PRIVATE fmt)
endif ()
endif()

if (BUILD_FAKER_TESTS)
if(BUILD_FAKER_TESTS)
add_subdirectory(externals/googletest)

set(GTEST_INCLUDE_DIR
Expand All @@ -138,24 +138,24 @@ if (BUILD_FAKER_TESTS)
add_executable(${LIBRARY_NAME}-UT ${FAKER_UT_SOURCES})

target_link_libraries(${LIBRARY_NAME}-UT PRIVATE gtest_main gmock_main
faker-cxx)
if (APPLE OR (WIN32 AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU"))
faker-cxx)
if(APPLE OR (WIN32 AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU"))
target_include_directories(
${LIBRARY_NAME}-UT
PRIVATE ${FMT_INCLUDE_DIR} ${GTEST_INCLUDE_DIR}
${GMOCK_INCLUDE_DIR} ${CMAKE_CURRENT_LIST_DIR})
${GMOCK_INCLUDE_DIR} ${CMAKE_CURRENT_LIST_DIR})

else ()
else()
target_include_directories(
${LIBRARY_NAME}-UT
PRIVATE ${GTEST_INCLUDE_DIR} ${GMOCK_INCLUDE_DIR}
${CMAKE_CURRENT_LIST_DIR})
endif ()
${CMAKE_CURRENT_LIST_DIR})
endif()

add_test(
NAME ${LIBRARY_NAME}-UT
COMMAND ${LIBRARY_NAME}-UT
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR})

target_code_coverage(${LIBRARY_NAME}-UT ALL)
endif ()
endif()
4 changes: 3 additions & 1 deletion include/faker-cxx/types/Country.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ enum class Country
Moldova,
Lithuania,
Iceland,
Vietnam,
};

const std::vector<Country> countries{
Expand All @@ -68,7 +69,7 @@ const std::vector<Country> countries{
Country::China, Country::Korea, Country::Canada, Country::Mexico, Country::Argentina,
Country::Australia, Country::Serbia, Country::Macedonia, Country::Albania, Country::Latvia,
Country::Ireland, Country::Belarus, Country::Estonia, Country::Iran, Country::Bulgaria,
Country::Moldova, Country::Lithuania, Country::Iceland,
Country::Moldova, Country::Lithuania, Country::Iceland, Country::Vietnam,
};

inline std::string toString(Country country)
Expand Down Expand Up @@ -122,6 +123,7 @@ inline std::string toString(Country country)
{Country::Moldova, "Moldova"},
{Country::Lithuania, "Lithuania"},
{Country::Iceland, "Iceland"},
{Country::Vietnam, "Vietnam"},
};

return countryToStringMapping.at(country);
Expand Down
2 changes: 2 additions & 0 deletions src/modules/person/Person.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
#include "data/norway/NorwegianPeopleNames.h"
#include "data/poland/PolishPeopleNames.h"
#include "data/portugal/PortuguesePeopleNames.h"
#include "data/vietnam/VietnamesePeopleNames.h"
#include "data/romania/RomanianPeopleNames.h"
#include "data/russia/RussianPeopleNames.h"
#include "data/serbia/SerbianPeopleNames.h"
Expand Down Expand Up @@ -95,6 +96,7 @@ const std::map<Country, PeopleNames> countryToPeopleNamesMapping{
{Country::Albania, albanianPeopleNames}, {Country::Iran, persianPeopleNames},
{Country::Bulgaria, bulgarianPeopleNames}, {Country::Moldova, moldovanPeopleNames},
{Country::Lithuania, lithuanianPeopleNames}, {Country::Iceland, icelandicPeopleNames},
{Country::Vietnam, vietnamesePeopleNames},
};

std::string middleNameForCountry(Country country, std::optional<Sex> sex);
Expand Down
3 changes: 3 additions & 0 deletions src/modules/person/PersonTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
#include "data/spain/SpanishPeopleNames.h"
#include "data/sweden/SwedishPeopleNames.h"
#include "data/switzerland/SwissPeopleNames.h"
#include "data/vietnam/VietnamesePeopleNames.h"
#include "data/turkey/TurkishPeopleNames.h"
#include "data/ukraine/UkrainianPeopleNames.h"
#include "data/ZodiacSigns.h"
Expand Down Expand Up @@ -93,6 +94,7 @@ const std::map<Country, PeopleNames> countryToPeopleNamesMapping{
{Country::Albania, albanianPeopleNames}, {Country::Iran, persianPeopleNames},
{Country::Bulgaria, bulgarianPeopleNames}, {Country::Moldova, moldovanPeopleNames},
{Country::Lithuania, lithuanianPeopleNames}, {Country::Iceland, icelandicPeopleNames},
{Country::Vietnam, vietnamesePeopleNames},
};

const std::map<Country, std::string> generatedTestName{
Expand Down Expand Up @@ -120,6 +122,7 @@ const std::map<Country, std::string> generatedTestName{
{Country::Albania, "shouldGenerateAlbanianName"}, {Country::Iran, "shouldGeneratePersianName"},
{Country::Bulgaria, "shouldGenerateBulgarianName"}, {Country::Moldova, "shouldGenerateMoldovanName"},
{Country::Lithuania, "shouldGenerateLithuanianName"}, {Country::Iceland, "shouldGenerateIcelandicName"},
{Country::Vietnam, "shouldGenerateVietnameseName"},
};
}

Expand Down
15 changes: 15 additions & 0 deletions src/modules/person/data/vietnam/VietnameseFirstNames.h

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions src/modules/person/data/vietnam/VietnameseLastNames.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#pragma once

#include <string>
#include <vector>

namespace faker
{
const std::vector<std::string> vietnameseLastNames = {
"Phạm","Nguyễn","Trần","","","Hoàng","Phan","","Tăng","Đặng","Bùi","Đỗ","Hồ","Ngô","Dương","Đào","Đoàn","Vương","Trịnh","Đinh","Lâm","Phùng","Mai","","Trương","", "Huỳnh",
};

}
16 changes: 16 additions & 0 deletions src/modules/person/data/vietnam/VietnamesePeopleNames.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#pragma once

#include "../NameFormats.h"
#include "../PeopleNames.h"
#include "VietnameseFirstNames.h"
#include "VietnameseLastNames.h"

namespace faker
{
const NameFormats vietnamesePersonNameFormats{{"{firstName} {lastName}", 1}};

const PeopleNames vietnamesePeopleNames{{vietnameseMalesFirstNames, {}, vietnameseLastNames, {}, {}},
{vietnameseFemalesFirstNames, {}, vietnameseLastNames, {}, {}},
vietnamesePersonNameFormats};

}

0 comments on commit b7d2912

Please sign in to comment.