diff --git a/src/hoi4_world/countries/hoi4_country_converter_tests_tech.cpp b/src/hoi4_world/countries/hoi4_country_converter_tests_tech.cpp index 3406b74d..9086bc48 100644 --- a/src/hoi4_world/countries/hoi4_country_converter_tests_tech.cpp +++ b/src/hoi4_world/countries/hoi4_country_converter_tests_tech.cpp @@ -1,4 +1,4 @@ -// Contains tech and research tests for hoi4::Country +// Contains tech and research tests for Country #include "external/commonItems/external/googletest/googlemock/include/gmock/gmock-matchers.h" #include "external/commonItems/external/googletest/googletest/include/gtest/gtest.h" #include "hoi4_country_converter.h" @@ -7,23 +7,27 @@ #include "src/mappers/country/country_mapper.h" #include "src/vic3_world/world/vic3_world.h" -TEST(Hoi4worldCountriesCountryConverter, StartingResearchSlots_Decentralized) + + +namespace hoi4 +{ + +TEST(Hoi4worldCountriesCountryConverter, DecentralizedCountriesHaveTwoResearchSlots) { - vic3::World source_world( + const vic3::World source_world( {.country_rankings = vic3::CountryRankings(std::set{4}, std::set{3, 2}, {{2, 10}, {3, 10}, {4, 10}})}); - vic3::Country c1({.number = 1, .country_type = "decentralized"}); + const vic3::Country c1({.number = 1, .country_type = "decentralized"}); const mappers::CountryMapper country_mapper({{1, "TAG"}}); - std::map dummy_characters; + std::map dummy_characters; std::map dummy_culture_queues; mappers::TemplateMap templates; - hoi4::States states{{}, {}}; const auto country_one = ConvertCountry(source_world, c1, commonItems::LocalizationDatabase{{}, {}}, country_mapper, - states, + {}, mappers::IdeologyMapper({}, {}), mappers::UnitMapper(templates), {}, @@ -42,23 +46,24 @@ TEST(Hoi4worldCountriesCountryConverter, StartingResearchSlots_Decentralized) EXPECT_EQ(country_one.value().GetStartingResearchSlots(), 2); } -TEST(Hoi4worldCountriesCountryConverter, StartingResearchSlots_default) + + +TEST(Hoi4worldCountriesCountryConverter, CountriesHaveThreeResearchSlotsByDefault) { - vic3::World source_world( + const vic3::World source_world( {.country_rankings = vic3::CountryRankings(std::set{4}, std::set{3, 2}, {{2, 10}, {3, 10}, {4, 10}})}); - vic3::Country c2({.number = 2, .country_type = "colonial"}); + const vic3::Country c2({.number = 2, .country_type = "colonial"}); const mappers::CountryMapper country_mapper({{2, "Z02"}}); - std::map dummy_characters; + std::map dummy_characters; std::map dummy_culture_queues; mappers::TemplateMap templates; - hoi4::States states{{}, {}}; const auto country_two = ConvertCountry(source_world, c2, commonItems::LocalizationDatabase{{}, {}}, country_mapper, - states, + {}, mappers::IdeologyMapper({}, {}), mappers::UnitMapper(templates), {}, @@ -77,23 +82,24 @@ TEST(Hoi4worldCountriesCountryConverter, StartingResearchSlots_default) EXPECT_EQ(country_two.value().GetStartingResearchSlots(), 3); } -TEST(Hoi4worldCountriesCountryConverter, StartingResearchSlots_Unrecognized) + + +TEST(Hoi4worldCountriesCountryConverter, UnrecognizedCountriesHaveTwoResearchSlots) { - vic3::World source_world( + const vic3::World source_world( {.country_rankings = vic3::CountryRankings(std::set{4}, std::set{3, 2}, {{2, 10}, {3, 10}, {4, 10}})}); - vic3::Country c3({.number = 3, .country_type = "unrecognized"}); + const vic3::Country c3({.number = 3, .country_type = "unrecognized"}); const mappers::CountryMapper country_mapper({{3, "Z03"}}); - std::map dummy_characters; + std::map dummy_characters; std::map dummy_culture_queues; mappers::TemplateMap templates; - hoi4::States states{{}, {}}; const auto country_three = ConvertCountry(source_world, c3, commonItems::LocalizationDatabase{{}, {}}, country_mapper, - states, + {}, mappers::IdeologyMapper({}, {}), mappers::UnitMapper(templates), {}, @@ -112,23 +118,24 @@ TEST(Hoi4worldCountriesCountryConverter, StartingResearchSlots_Unrecognized) EXPECT_EQ(country_three.value().GetStartingResearchSlots(), 2); } -TEST(Hoi4worldCountriesCountryConverter, StartingResearchSlots_GreatPower) + + +TEST(Hoi4worldCountriesCountryConverter, GreatPowersHaveFourResearchSlots) { - vic3::World source_world( + const vic3::World source_world( {.country_rankings = vic3::CountryRankings(std::set{4}, std::set{3, 2}, {{2, 10}, {3, 10}, {4, 10}})}); - vic3::Country c4({.number = 4, .country_type = "recognized"}); + const vic3::Country c4({.number = 4, .country_type = "recognized"}); const mappers::CountryMapper country_mapper({{4, "Z04"}}); - std::map dummy_characters; + std::map dummy_characters; std::map dummy_culture_queues; mappers::TemplateMap templates; - hoi4::States states{{}, {}}; const auto country_four = ConvertCountry(source_world, c4, commonItems::LocalizationDatabase{{}, {}}, country_mapper, - states, + {}, mappers::IdeologyMapper({}, {}), mappers::UnitMapper(templates), {}, @@ -147,3 +154,5 @@ TEST(Hoi4worldCountriesCountryConverter, StartingResearchSlots_GreatPower) EXPECT_EQ(country_four.value().GetStartingResearchSlots(), 4); } + +} // namespace hoi4 \ No newline at end of file diff --git a/src/hoi4_world/countries/hoi4_country_tests.cpp b/src/hoi4_world/countries/hoi4_country_tests.cpp index ae3dce32..2406a4b5 100644 --- a/src/hoi4_world/countries/hoi4_country_tests.cpp +++ b/src/hoi4_world/countries/hoi4_country_tests.cpp @@ -4,11 +4,16 @@ +namespace hoi4 +{ + TEST(Hoi4worldCountriesCountry, PuppetsCanBeRemoved) { - hoi4::Country country({.puppets = {"ONE", "TWO", "THR", "FOR"}}); + Country country({.puppets = {"ONE", "TWO", "THR", "FOR"}}); country.RemovePuppets({"TWO", "FOR"}); EXPECT_THAT(country.GetPuppets(), testing::UnorderedElementsAre("ONE", "THR")); -} \ No newline at end of file +} + +} // namespace hoi4 \ No newline at end of file diff --git a/src/hoi4_world/map/coastal_provinces_creator_tests.cpp b/src/hoi4_world/map/coastal_provinces_creator_tests.cpp index 758579e1..bf2d507a 100644 --- a/src/hoi4_world/map/coastal_provinces_creator_tests.cpp +++ b/src/hoi4_world/map/coastal_provinces_creator_tests.cpp @@ -6,11 +6,14 @@ +namespace hoi4 +{ + TEST(Hoi4worldMapCoastalProvincesCreatorTests, CoastalProvincesDefaultToEmpty) { const maps::ProvinceDefinitions province_definitions; const maps::MapData map_data({.province_definitions = province_definitions}); - const hoi4::CoastalProvinces coastal_provinces = hoi4::CoastalProvinces{hoi4::CreateCoastalProvinces(map_data, + const CoastalProvinces coastal_provinces = CoastalProvinces{CreateCoastalProvinces(map_data, province_definitions.GetLandProvinces(), province_definitions.GetSeaProvinces())}; @@ -22,7 +25,7 @@ TEST(Hoi4worldMapCoastalProvincesCreatorTests, CoastalProvincesAreDetected) { const maps::ProvinceDefinitions province_definitions({.land_provinces = {"1"}, .sea_provinces = {"2"}}); const maps::MapData map_data({.province_neighbors = {{"1", {"2"}}}, .province_definitions = province_definitions}); - const hoi4::CoastalProvinces coastal_provinces = hoi4::CoastalProvinces{hoi4::CreateCoastalProvinces(map_data, + const CoastalProvinces coastal_provinces = CoastalProvinces{CreateCoastalProvinces(map_data, province_definitions.GetLandProvinces(), province_definitions.GetSeaProvinces())}; @@ -36,7 +39,7 @@ TEST(Hoi4worldMapCoastalProvincesCreatorTests, MultipleConnectingSeaProvincesAre const maps::ProvinceDefinitions province_definitions({.land_provinces = {"1"}, .sea_provinces = {"2", "3"}}); const maps::MapData map_data( {.province_neighbors = {{"1", {"2", "3"}}}, .province_definitions = province_definitions}); - const hoi4::CoastalProvinces coastal_provinces = hoi4::CoastalProvinces{hoi4::CreateCoastalProvinces(map_data, + const CoastalProvinces coastal_provinces = CoastalProvinces{CreateCoastalProvinces(map_data, province_definitions.GetLandProvinces(), province_definitions.GetSeaProvinces())}; @@ -49,7 +52,7 @@ TEST(Hoi4worldMapCoastalProvincesCreatorTests, NeighboringLandProvincesDoNotMake { const maps::ProvinceDefinitions province_definitions({.land_provinces = {"1", "2"}}); const maps::MapData map_data({.province_neighbors = {{"1", {"2"}}}, .province_definitions = province_definitions}); - const hoi4::CoastalProvinces coastal_provinces = hoi4::CoastalProvinces{hoi4::CreateCoastalProvinces(map_data, + const CoastalProvinces coastal_provinces = CoastalProvinces{CreateCoastalProvinces(map_data, province_definitions.GetLandProvinces(), province_definitions.GetSeaProvinces())}; @@ -62,10 +65,12 @@ TEST(Hoi4worldMapCoastalProvincesCreatorTests, BadProvinceNamesAreSkipped) const maps::ProvinceDefinitions province_definitions({.land_provinces = {"1", "a"}, .sea_provinces = {"2", "b"}}); const maps::MapData map_data( {.province_neighbors = {{"1", {"2", "b"}}, {"a", {"2", "b"}}}, .province_definitions = province_definitions}); - const hoi4::CoastalProvinces coastal_provinces = hoi4::CoastalProvinces{hoi4::CreateCoastalProvinces(map_data, + const CoastalProvinces coastal_provinces = CoastalProvinces{CreateCoastalProvinces(map_data, province_definitions.GetLandProvinces(), province_definitions.GetSeaProvinces())}; EXPECT_THAT(coastal_provinces.GetCoastalProvinces(), testing::UnorderedElementsAre(testing::Pair(1, std::vector{2}))); -} \ No newline at end of file +} + +} // namespace hoi4 \ No newline at end of file diff --git a/src/hoi4_world/map/hoi4_province_definition_importer_tests.cpp b/src/hoi4_world/map/hoi4_province_definition_importer_tests.cpp index 1c817514..df7dfcbf 100644 --- a/src/hoi4_world/map/hoi4_province_definition_importer_tests.cpp +++ b/src/hoi4_world/map/hoi4_province_definition_importer_tests.cpp @@ -4,20 +4,24 @@ +namespace hoi4 +{ + TEST(Hoi4worldMapHoi4provincedefinitionimporter, ExceptionThrownForNoDefinitions) { - commonItems::ModFilesystem mod_filesystem("", {}); + const commonItems::ModFilesystem mod_filesystem("", {}); - EXPECT_THROW(const maps::ProvinceDefinitions province_definitions = hoi4::ImportProvinceDefinitions(mod_filesystem), + EXPECT_THROW([[maybe_unused]] const maps::ProvinceDefinitions province_definitions = + ImportProvinceDefinitions(mod_filesystem), std::runtime_error); } TEST(Hoi4worldMapHoi4provincedefinitionimporter, DefinitionsCanBeImported) { - commonItems::ModFilesystem mod_filesystem("test_files/hoi4_world", {}); + const commonItems::ModFilesystem mod_filesystem("test_files/hoi4_world", {}); - const maps::ProvinceDefinitions province_definitions = hoi4::ImportProvinceDefinitions(mod_filesystem); + const maps::ProvinceDefinitions province_definitions = ImportProvinceDefinitions(mod_filesystem); EXPECT_THAT(province_definitions.GetLandProvinces(), testing::UnorderedElementsAre("10", "20", "30", "40", "50", "60")); @@ -26,9 +30,11 @@ TEST(Hoi4worldMapHoi4provincedefinitionimporter, DefinitionsCanBeImported) TEST(Hoi4worldMapHoi4provincedefinitionimporter, SeaProvincesAreDetected) { - commonItems::ModFilesystem mod_filesystem("test_files/hoi4_world", {}); + const commonItems::ModFilesystem mod_filesystem("test_files/hoi4_world", {}); - const maps::ProvinceDefinitions province_definitions = hoi4::ImportProvinceDefinitions(mod_filesystem); + const maps::ProvinceDefinitions province_definitions = ImportProvinceDefinitions(mod_filesystem); EXPECT_TRUE(province_definitions.IsSeaProvince("2")); -} \ No newline at end of file +} + +} // namespace hoi4 \ No newline at end of file diff --git a/src/hoi4_world/roles/role_importer_tests.cpp b/src/hoi4_world/roles/role_importer_tests.cpp index b82e24a2..de12e522 100644 --- a/src/hoi4_world/roles/role_importer_tests.cpp +++ b/src/hoi4_world/roles/role_importer_tests.cpp @@ -7,12 +7,15 @@ +namespace hoi4 +{ + TEST(Hoi4worldRolesRoleimporterTests, DefaultsAreDefaulted) { std::stringstream input; - hoi4::RoleImporter importer; - const hoi4::Role role = importer.ImportRole("", input); + RoleImporter importer; + const Role role = importer.ImportRole("", input); EXPECT_TRUE(role.GetName().empty()); EXPECT_TRUE(role.GetCategory().empty()); @@ -104,8 +107,8 @@ TEST(Hoi4worldRolesRoleimporterTests, ItemsCanBeImported) input << "\t\n"; input << "}\n"; - hoi4::RoleImporter importer; - const hoi4::Role role = importer.ImportRole("unification_italy", input); + RoleImporter importer; + const Role role = importer.ImportRole("unification_italy", input); EXPECT_EQ(role.GetName(), "unification_italy"); EXPECT_EQ(role.GetCategory(), "unification"); @@ -177,4 +180,6 @@ TEST(Hoi4worldRolesRoleimporterTests, ItemsCanBeImported) "= {\n" "\t\tid = $TAG$_another_event\n" "\t}")); -} \ No newline at end of file +} + +} // namespace hoi4 \ No newline at end of file diff --git a/src/hoi4_world/roles/roles_importer_tests.cpp b/src/hoi4_world/roles/roles_importer_tests.cpp index 18df43e8..26a9a0cf 100644 --- a/src/hoi4_world/roles/roles_importer_tests.cpp +++ b/src/hoi4_world/roles/roles_importer_tests.cpp @@ -6,12 +6,16 @@ +namespace hoi4 +{ TEST(Hoi4worldRolesRolesimporterTests, RolesCanBeImported) { - const std::map roles = hoi4::ImportRoles(); + const std::map roles = ImportRoles(); EXPECT_THAT(roles, - testing::ElementsAre(testing::Pair("role_1", hoi4::Role{{.name = "role_1"}}), - testing::Pair("role_2", hoi4::Role{{.name = "role_2"}}), - testing::Pair("role_3", hoi4::Role{{.name = "role_3"}}))); -} \ No newline at end of file + testing::ElementsAre(testing::Pair("role_1", Role{{.name = "role_1"}}), + testing::Pair("role_2", Role{{.name = "role_2"}}), + testing::Pair("role_3", Role{{.name = "role_3"}}))); +} + +} // namespace hoi4 \ No newline at end of file diff --git a/src/hoi4_world/states/default_states_importer_tests.cpp b/src/hoi4_world/states/default_states_importer_tests.cpp index 1415904d..9fc3a1bb 100644 --- a/src/hoi4_world/states/default_states_importer_tests.cpp +++ b/src/hoi4_world/states/default_states_importer_tests.cpp @@ -7,10 +7,13 @@ +namespace hoi4 +{ + TEST(Hoi4worldStatesDefaultstatesimporterTests, NoStateFilesMeansNoStates) { - commonItems::ModFilesystem filesystem("test_files/hoi4_world/NoStateFilesMeansNoStates", {}); - const auto default_states = hoi4::ImportDefaultStates(filesystem); + const commonItems::ModFilesystem filesystem("test_files/hoi4_world/NoStateFilesMeansNoStates", {}); + const auto default_states = ImportDefaultStates(filesystem); EXPECT_TRUE(default_states.empty()); } @@ -18,12 +21,12 @@ TEST(Hoi4worldStatesDefaultstatesimporterTests, NoStateFilesMeansNoStates) TEST(Hoi4worldStatesDefaultstatesimporterTests, DefaultStatesCanBeImported) { - commonItems::ModFilesystem filesystem("test_files/hoi4_world/DefaultStatesCanBeImported", {}); - const auto default_states = hoi4::ImportDefaultStates(filesystem); + const commonItems::ModFilesystem filesystem("test_files/hoi4_world/DefaultStatesCanBeImported", {}); + const auto default_states = ImportDefaultStates(filesystem); EXPECT_THAT(default_states, testing::UnorderedElementsAre(testing::Pair(1, - hoi4::DefaultState({.impassable = true, + DefaultState({.impassable = true, .owner_tag = "FRA", .provinces = {3838, 9851, 11804}, .manpower = 322900, @@ -32,7 +35,7 @@ TEST(Hoi4worldStatesDefaultstatesimporterTests, DefaultStatesCanBeImported) .dockyards = 2, .resources = {{"steel", 5}, {"test_resource", 42}}})), testing::Pair(2, - hoi4::DefaultState({.impassable = false, + DefaultState({.impassable = false, .owner_tag = "ITA", .provinces = {923, 6862, 9794, 9904, 11751, 11846, 11882}, .manpower = 2781971, @@ -40,4 +43,6 @@ TEST(Hoi4worldStatesDefaultstatesimporterTests, DefaultStatesCanBeImported) .military_factories = 1, .dockyards = 0, .resources = {}})))); -} \ No newline at end of file +} + +} // namespace hoi4 \ No newline at end of file diff --git a/src/hoi4_world/technology/technologies_converter_tests.cpp b/src/hoi4_world/technology/technologies_converter_tests.cpp index 9ad53392..d88e770c 100644 --- a/src/hoi4_world/technology/technologies_converter_tests.cpp +++ b/src/hoi4_world/technology/technologies_converter_tests.cpp @@ -9,11 +9,14 @@ +namespace hoi4 +{ + TEST(Hoi4worldTechnologyTechnologiesconverterTests, NoVic3TechsGivesNoHoi4Techs) { const std::set old_technologies; - const hoi4::Technologies technologies = - hoi4::ConvertTechnologies(old_technologies, {{{"vic3_tech"}, std::nullopt, {"hoi4_tech_one", "hoi4_tech_two"}}}); + const Technologies technologies = + ConvertTechnologies(old_technologies, {{{"vic3_tech"}, std::nullopt, {"hoi4_tech_one", "hoi4_tech_two"}}}); EXPECT_TRUE(technologies.GetTechnologies().empty()); } @@ -22,7 +25,7 @@ TEST(Hoi4worldTechnologyTechnologiesconverterTests, NoVic3TechsGivesNoHoi4Techs) TEST(Hoi4worldTechnologyTechnologiesconverterTests, NonmatchingVic3TechsGiveNoHoi4Techs) { const std::set old_technologies{"non_matching_tech"}; - const hoi4::Technologies technologies = hoi4::ConvertTechnologies(old_technologies, {}); + const Technologies technologies = ConvertTechnologies(old_technologies, {}); EXPECT_TRUE(technologies.GetTechnologies().empty()); } @@ -31,8 +34,8 @@ TEST(Hoi4worldTechnologyTechnologiesconverterTests, NonmatchingVic3TechsGiveNoHo TEST(Hoi4worldTechnologyTechnologiesconverterTests, MatchingVic3TechGivesHoi4Techs) { const std::set old_technologies{"vic3_tech"}; - const hoi4::Technologies technologies = - hoi4::ConvertTechnologies(old_technologies, {{{"vic3_tech"}, std::nullopt, {"hoi4_tech_one", "hoi4_tech_two"}}}); + const Technologies technologies = + ConvertTechnologies(old_technologies, {{{"vic3_tech"}, std::nullopt, {"hoi4_tech_one", "hoi4_tech_two"}}}); EXPECT_THAT(technologies.GetTechnologies(), testing::UnorderedElementsAre( @@ -43,7 +46,7 @@ TEST(Hoi4worldTechnologyTechnologiesconverterTests, MatchingVic3TechGivesHoi4Tec TEST(Hoi4worldTechnologyTechnologiesconverterTests, OnlyOneInstanceOfEachTech) { const std::set old_technologies{"vic3_tech", "vic3_tech_two"}; - const hoi4::Technologies technologies = hoi4::ConvertTechnologies(old_technologies, + const Technologies technologies = ConvertTechnologies(old_technologies, { {{"vic3_tech"}, std::nullopt, {"hoi4_tech_one", "hoi4_tech_two"}}, {{"vic3_tech_two"}, std::nullopt, {"hoi4_tech_two", "hoi4_tech_three"}}, @@ -58,7 +61,7 @@ TEST(Hoi4worldTechnologyTechnologiesconverterTests, OnlyOneInstanceOfEachTech) TEST(Hoi4worldTechnologyTechnologiesconverterTests, ConvertedTechsAreCategorizedByLimits) { const std::set old_technologies{"vic3_non_mtg_naval_tech", "vic3_mtg_naval_tech"}; - const hoi4::Technologies technologies = hoi4::ConvertTechnologies(old_technologies, + const Technologies technologies = ConvertTechnologies(old_technologies, {{{"vic3_non_mtg_naval_tech"}, R"(not = { has_dlc = "Man the Guns" })", {"hoi4_non_mtg_naval_tech_one", "hoi4_non_mtg_naval_tech_two"}}, @@ -78,7 +81,7 @@ TEST(Hoi4worldTechnologyTechnologiesconverterTests, ConvertedTechsAreCategorized TEST(Hoi4worldTechnologyTechnologiesconverterTests, NoTechIfNotAllRequirementsAreMet) { const std::set old_technologies{"requirement1"}; - const hoi4::Technologies technologies = hoi4::ConvertTechnologies(old_technologies, + const Technologies technologies = ConvertTechnologies(old_technologies, {{{"requirement1", "requirement2"}, std::nullopt, {"test_tech1", "test_tech2"}}}); EXPECT_TRUE(technologies.GetTechnologies().empty()); @@ -88,9 +91,11 @@ TEST(Hoi4worldTechnologyTechnologiesconverterTests, NoTechIfNotAllRequirementsAr TEST(Hoi4worldTechnologyTechnologiesconverterTests, MultipleVic3RequirementsCanSucceed) { const std::set old_technologies{"requirement1", "requirement2"}; - const hoi4::Technologies technologies = hoi4::ConvertTechnologies(old_technologies, + const Technologies technologies = ConvertTechnologies(old_technologies, {{{"requirement1", "requirement2"}, std::nullopt, {"test_tech1", "test_tech2"}}}); EXPECT_THAT(technologies.GetTechnologies(), testing::UnorderedElementsAre(testing::Pair(std::nullopt, std::set{"test_tech1", "test_tech2"}))); -} \ No newline at end of file +} + +} // namespace hoi4 \ No newline at end of file diff --git a/src/hoi4_world/technology/technologies_tests.cpp b/src/hoi4_world/technology/technologies_tests.cpp index 50572268..a35c8000 100644 --- a/src/hoi4_world/technology/technologies_tests.cpp +++ b/src/hoi4_world/technology/technologies_tests.cpp @@ -7,9 +7,13 @@ +namespace hoi4 +{ + + TEST(Hoi4worldTechnologyTechnologiesTests, HasTechnologyReturnsFalseIfTechNotThere) { - const hoi4::Technologies technologies(std::map, std::set>{}); + const Technologies technologies(std::map, std::set>{}); EXPECT_FALSE(technologies.HasTechnology("missing_technology")); } @@ -17,7 +21,7 @@ TEST(Hoi4worldTechnologyTechnologiesTests, HasTechnologyReturnsFalseIfTechNotThe TEST(Hoi4worldTechnologyTechnologiesTests, HasTechnologyReturnsTrueIfTechIsThere) { - const hoi4::Technologies technologies({{std::nullopt, {"test_technology"}}}); + const Technologies technologies({{std::nullopt, {"test_technology"}}}); EXPECT_TRUE(technologies.HasTechnology("test_technology")); } @@ -25,8 +29,9 @@ TEST(Hoi4worldTechnologyTechnologiesTests, HasTechnologyReturnsTrueIfTechIsThere TEST(Hoi4worldTechnologyTechnologiesTests, HasTechnologyReturnsTrueIfTechIsThereWithLimit) { - const hoi4::Technologies technologies( - {{std::nullopt, {"test_technology"}}, {"test_limit", {"test_technology_two"}}}); + const Technologies technologies({{std::nullopt, {"test_technology"}}, {"test_limit", {"test_technology_two"}}}); EXPECT_TRUE(technologies.HasTechnology("test_technology_two")); -} \ No newline at end of file +} + +} // namespace hoi4 \ No newline at end of file diff --git a/src/mappers/provinces/province_mapper_importer_tests.cpp b/src/mappers/provinces/province_mapper_importer_tests.cpp index 44756e8c..0e2e95e1 100644 --- a/src/mappers/provinces/province_mapper_importer_tests.cpp +++ b/src/mappers/provinces/province_mapper_importer_tests.cpp @@ -7,10 +7,13 @@ +namespace mappers +{ + TEST(MappersProvincesProvinceMapperImporterTests, ProvinceMappingsCanBeImported) { - commonItems::ModFilesystem mod_filesystem("./test_files/mappers/provinces/empty_definition/", {}); - const auto province_mappings = mappers::ProvinceMapperImporter{mod_filesystem}.ImportProvinceMappings(); + const commonItems::ModFilesystem mod_filesystem("./test_files/mappers/provinces/empty_definition/", {}); + const auto province_mappings = ProvinceMapperImporter{mod_filesystem}.ImportProvinceMappings(); EXPECT_THAT(province_mappings.GetVic3ToHoi4ProvinceMapping("x000001"), testing::ElementsAre(1, 10)); EXPECT_THAT(province_mappings.GetVic3ToHoi4ProvinceMapping("x000200"), testing::ElementsAre(2)); @@ -27,8 +30,9 @@ TEST(MappersProvincesProvinceMapperImporterTests, ProvinceMappingsCanBeImported) TEST(MappersProvincesProvinceMapperImporterTests, MissingMapDefinitionThrowsException) { - commonItems::ModFilesystem mod_filesystem("./test_files/mappers/provinces/no_definition/", {}); - EXPECT_THROW(const auto province_mappings = mappers::ProvinceMapperImporter{mod_filesystem}.ImportProvinceMappings(), + const commonItems::ModFilesystem mod_filesystem("./test_files/mappers/provinces/no_definition/", {}); + EXPECT_THROW( + [[maybe_unused]] const auto province_mappings = ProvinceMapperImporter{mod_filesystem}.ImportProvinceMappings(), std::runtime_error); } @@ -36,11 +40,11 @@ TEST(MappersProvincesProvinceMapperImporterTests, MissingMapDefinitionThrowsExce TEST(MappersProvincesProvinceMapperImporterTests, BadLineInMapDefinitionLogsWarning) { std::stringstream log; - auto stdOutBuf = std::cout.rdbuf(); + std::streambuf* stdOutBuf = std::cout.rdbuf(); std::cout.rdbuf(log.rdbuf()); - commonItems::ModFilesystem mod_filesystem("./test_files/mappers/provinces/bad_line_definition/", {}); - auto _ = mappers::ProvinceMapperImporter{mod_filesystem}.ImportProvinceMappings(); + const commonItems::ModFilesystem mod_filesystem("./test_files/mappers/provinces/bad_line_definition/", {}); + auto _ = ProvinceMapperImporter{mod_filesystem}.ImportProvinceMappings(); std::cout.rdbuf(stdOutBuf); EXPECT_THAT(log.str(), @@ -51,11 +55,11 @@ TEST(MappersProvincesProvinceMapperImporterTests, BadLineInMapDefinitionLogsWarn TEST(MappersProvincesProvinceMapperImporterTests, MissingHoi4ProvinceMappingLogsWarning) { std::stringstream log; - auto stdOutBuf = std::cout.rdbuf(); + std::streambuf* stdOutBuf = std::cout.rdbuf(); std::cout.rdbuf(log.rdbuf()); - commonItems::ModFilesystem mod_filesystem("./test_files/mappers/provinces/missing_definition/", {}); - const auto province_mappings = mappers::ProvinceMapperImporter{mod_filesystem}.ImportProvinceMappings(); + const commonItems::ModFilesystem mod_filesystem("./test_files/mappers/provinces/missing_definition/", {}); + const auto province_mappings = ProvinceMapperImporter{mod_filesystem}.ImportProvinceMappings(); const auto _ = province_mappings.GetHoi4ToVic3ProvinceMapping(12); std::cout.rdbuf(stdOutBuf); @@ -67,11 +71,11 @@ TEST(MappersProvincesProvinceMapperImporterTests, MissingHoi4ProvinceMappingLogs TEST(MappersProvincesProvinceMapperImporterTests, MissingVic3ProvinceMappingLogsWarning) { - commonItems::ModFilesystem mod_filesystem("./test_files/mappers/provinces/empty_definition/", {}); - const auto province_mappings = mappers::ProvinceMapperImporter{mod_filesystem}.ImportProvinceMappings(); + const commonItems::ModFilesystem mod_filesystem("./test_files/mappers/provinces/empty_definition/", {}); + const auto province_mappings = ProvinceMapperImporter{mod_filesystem}.ImportProvinceMappings(); std::stringstream log; - auto stdOutBuf = std::cout.rdbuf(); + std::streambuf* stdOutBuf = std::cout.rdbuf(); std::cout.rdbuf(log.rdbuf()); const auto _ = province_mappings.GetVic3ToHoi4ProvinceMapping("0x000012"); @@ -85,14 +89,16 @@ TEST(MappersProvincesProvinceMapperImporterTests, MissingVic3ProvinceMappingLogs TEST(MappersProvincesProvinceMapperImporterTests, ExtraProvinceMappingsLogWarning) { std::stringstream log; - auto stdOutBuf = std::cout.rdbuf(); + std::streambuf* stdOutBuf = std::cout.rdbuf(); std::cout.rdbuf(log.rdbuf()); - commonItems::ModFilesystem mod_filesystem("./test_files/mappers/provinces/good_definition/", {}); - const auto province_mappings = mappers::ProvinceMapperImporter{mod_filesystem}.ImportProvinceMappings(); + const commonItems::ModFilesystem mod_filesystem("./test_files/mappers/provinces/good_definition/", {}); + [[maybe_unused]] const auto province_mappings = ProvinceMapperImporter{mod_filesystem}.ImportProvinceMappings(); std::cout.rdbuf(stdOutBuf); EXPECT_THAT(log.str(), testing::HasSubstr("[WARNING] Vic3 province x000001 was in multiple mappings.")); EXPECT_THAT(log.str(), testing::HasSubstr("[WARNING] Hoi4 province 1 was in multiple mappings.")); -} \ No newline at end of file +} + +} // namespace mappers \ No newline at end of file diff --git a/src/mappers/provinces/province_mapping_importer_tests.cpp b/src/mappers/provinces/province_mapping_importer_tests.cpp index da77e6fd..25d3dc78 100644 --- a/src/mappers/provinces/province_mapping_importer_tests.cpp +++ b/src/mappers/provinces/province_mapping_importer_tests.cpp @@ -7,11 +7,14 @@ +namespace mappers +{ + TEST(MappersProvincesProvinceMappingImporterTests, Vic2ProvincesDefaultsToZero) { std::stringstream input; - const auto mapping = mappers::ProvinceMappingImporter{}.ImportProvinceMapping(input); + const auto mapping = ProvinceMappingImporter{}.ImportProvinceMapping(input); EXPECT_TRUE(mapping.vic3_provinces.empty()); } @@ -22,7 +25,7 @@ TEST(MappersProvincesProvinceMappingImporterTests, Vic2ProvincesCanBeAdded) std::stringstream input; input << "= { vic3 = 0x000042 vic3 = 0x001440 }"; - const auto mapping = mappers::ProvinceMappingImporter{}.ImportProvinceMapping(input); + const auto mapping = ProvinceMappingImporter{}.ImportProvinceMapping(input); EXPECT_THAT(mapping.vic3_provinces, testing::ElementsAre("x000042", "x001440")); } @@ -32,7 +35,7 @@ TEST(MappersProvincesProvinceMappingImporterTests, HoI4ProvincesDefaultsToZero) { std::stringstream input; - const auto mapping = mappers::ProvinceMappingImporter{}.ImportProvinceMapping(input); + const auto mapping = ProvinceMappingImporter{}.ImportProvinceMapping(input); EXPECT_TRUE(mapping.hoi4_provinces.empty()); } @@ -43,7 +46,9 @@ TEST(MappersProvincesProvinceMappingImporterTests, HoI4ProvincesCanBeAdded) std::stringstream input; input << "= { hoi4 = 42 hoi4 = 144 }"; - const auto mapping = mappers::ProvinceMappingImporter{}.ImportProvinceMapping(input); + const auto mapping = ProvinceMappingImporter{}.ImportProvinceMapping(input); EXPECT_THAT(mapping.hoi4_provinces, testing::ElementsAre(42, 144)); -} \ No newline at end of file +} + +} // namespace mappers \ No newline at end of file diff --git a/src/mappers/technology/tech_mapping_importer_tests.cpp b/src/mappers/technology/tech_mapping_importer_tests.cpp index eb6f3cb7..a8b2abb8 100644 --- a/src/mappers/technology/tech_mapping_importer_tests.cpp +++ b/src/mappers/technology/tech_mapping_importer_tests.cpp @@ -5,10 +5,13 @@ +namespace mappers +{ + TEST(MappersTechnologyTechmappingimporterTests, DefaultsAreEmpty) { std::stringstream input; - const auto mapping = mappers::TechMappingImporter().ImportTechMapping(input); + const auto mapping = TechMappingImporter().ImportTechMapping(input); EXPECT_TRUE(mapping.GetVic3Requirements().empty()); EXPECT_FALSE(mapping.GetLimit().has_value()); @@ -24,10 +27,12 @@ TEST(MappersTechnologyTechmappingimporterTests, ItemsCanBeSet) input << "limit = test_limit\n"; input << "hoi4 = test_tech\n"; input << "hoi4 = test_tech2"; - const auto mapping = mappers::TechMappingImporter().ImportTechMapping(input); + const auto mapping = TechMappingImporter().ImportTechMapping(input); EXPECT_THAT(mapping.GetVic3Requirements(), testing::UnorderedElementsAre("test_item", "test_item_two")); ASSERT_TRUE(mapping.GetLimit().has_value()); EXPECT_EQ(*mapping.GetLimit(), "test_limit"); EXPECT_THAT(mapping.GetTechs(), testing::UnorderedElementsAre("test_tech", "test_tech2")); -} \ No newline at end of file +} + +} // namespace mappers \ No newline at end of file diff --git a/src/mappers/technology/tech_mappings_importer_tests.cpp b/src/mappers/technology/tech_mappings_importer_tests.cpp index be8a0574..e626f4de 100644 --- a/src/mappers/technology/tech_mappings_importer_tests.cpp +++ b/src/mappers/technology/tech_mappings_importer_tests.cpp @@ -5,15 +5,20 @@ +namespace mappers +{ + TEST(MappersTechnologyTechmappingsimporterTests, TechMappingsAreImported) { - const std::vector tech_mappings = mappers::ImportTechMappings(); + const std::vector tech_mappings = ImportTechMappings(); EXPECT_THAT(tech_mappings, - testing::ElementsAre(mappers::TechMapping{std::set{"source_tech"}, + testing::ElementsAre(TechMapping{std::set{"source_tech"}, std::nullopt, std::set{"dest_tech_one", "dest_tech_two"}}, - mappers::TechMapping{std::set{"source_tech_two", "source_tech_three"}, + TechMapping{std::set{"source_tech_two", "source_tech_three"}, std::optional{R"(not = { has_dlc = "Test DLC" })"}, std::set{"dest_tech_three"}})); -} \ No newline at end of file +} + +} // namespace mappers \ No newline at end of file diff --git a/src/maps/map_data_tests.cpp b/src/maps/map_data_tests.cpp index d4cf501e..39c92d36 100644 --- a/src/maps/map_data_tests.cpp +++ b/src/maps/map_data_tests.cpp @@ -40,11 +40,14 @@ maps::MapData MapsMapdata::map_data; } // namespace +namespace maps +{ + TEST_F(MapsMapdata, ExceptionThrownForMissingProvincesBmp) { const commonItems::ModFilesystem mod_filesystem("", {}); - const maps::ProvinceDefinitions province_definitions; - maps::MapDataImporter importer(province_definitions); + const ProvinceDefinitions province_definitions; + MapDataImporter importer(province_definitions); EXPECT_THROW(importer.ImportMapData(mod_filesystem), std::runtime_error); } @@ -53,8 +56,8 @@ TEST_F(MapsMapdata, ExceptionThrownForMissingProvincesBmp) TEST_F(MapsMapdata, ExceptionThrownForMissingAdjacenciesCsv) { const commonItems::ModFilesystem mod_filesystem("test_files/maps/nocsv", {}); - const maps::ProvinceDefinitions province_definitions; - maps::MapDataImporter importer(province_definitions); + const ProvinceDefinitions province_definitions; + MapDataImporter importer(province_definitions); EXPECT_THROW(importer.ImportMapData(mod_filesystem), std::runtime_error); } @@ -83,14 +86,14 @@ TEST_F(MapsMapdata, SpecifiedBordersCanBeLookedUp) // Bordering provinces const auto border_point = map_data.GetSpecifiedBorderCenter("1", "3"); ASSERT_TRUE(border_point); - constexpr maps::Point expected_point{13, 591}; // y-axis is from the bottom + constexpr Point expected_point{13, 591}; // y-axis is from the bottom EXPECT_EQ(*border_point, expected_point); // Impassable border for bordering provinces const auto impassable_border_point = map_data.GetSpecifiedBorderCenter("6", "7"); ASSERT_TRUE(impassable_border_point); - constexpr maps::Point expected_impassable_point{44, 586}; // y-axis is from the bottom + constexpr Point expected_impassable_point{44, 586}; // y-axis is from the bottom EXPECT_EQ(*impassable_border_point, expected_impassable_point); } @@ -104,7 +107,7 @@ TEST_F(MapsMapdata, AnyBordersCanBeLookedUp) const auto border_point = map_data.GetAnyBorderCenter("3"); ASSERT_TRUE(border_point); - constexpr maps::Point expected_point{13, 590}; // y-axis is from the bottom + constexpr Point expected_point{13, 590}; // y-axis is from the bottom EXPECT_EQ(*border_point, expected_point); } @@ -113,7 +116,7 @@ TEST_F(MapsMapdata, CentralPointCanBeLookedUp) { const auto central_point = map_data.GetCentermostPoint("3"); - EXPECT_EQ(central_point, std::make_optional(maps::Point{13, 586})); + EXPECT_EQ(central_point, std::make_optional(Point{13, 586})); } @@ -144,6 +147,8 @@ TEST_F(MapsMapdata, ProvincePointsCanBeLookedUp) const auto provincePoints = map_data.GetProvincePoints("1"); ASSERT_TRUE(provincePoints); - constexpr maps::Point expected_point{13, 595}; + constexpr Point expected_point{13, 595}; EXPECT_EQ(provincePoints->GetCentermostPoint(), expected_point); -} \ No newline at end of file +} + +} // namespace maps \ No newline at end of file diff --git a/src/maps/province_definitions_tests.cpp b/src/maps/province_definitions_tests.cpp index 2c0b3cff..fd1283b0 100644 --- a/src/maps/province_definitions_tests.cpp +++ b/src/maps/province_definitions_tests.cpp @@ -4,9 +4,12 @@ +namespace maps +{ + TEST(MapsProvincedefinitions, LandProvincesDefaultToEmpty) { - const maps::ProvinceDefinitions province_definitions; + const ProvinceDefinitions province_definitions; EXPECT_TRUE(province_definitions.GetLandProvinces().empty()); } @@ -14,7 +17,7 @@ TEST(MapsProvincedefinitions, LandProvincesDefaultToEmpty) TEST(MapsProvincedefinitions, LandProvincesAreReturned) { - const maps::ProvinceDefinitions province_definitions({.land_provinces = {"1", "2", "3", "4", "0x000005"}}); + const ProvinceDefinitions province_definitions({.land_provinces = {"1", "2", "3", "4", "0x000005"}}); EXPECT_THAT(province_definitions.GetLandProvinces(), testing::UnorderedElementsAre("1", "2", "3", "4", "0x000005")); } @@ -22,7 +25,7 @@ TEST(MapsProvincedefinitions, LandProvincesAreReturned) TEST(MapsProvincedefinitions, ProvincesCanBeShownAreNotLandProvinces) { - const maps::ProvinceDefinitions province_definitions; + const ProvinceDefinitions province_definitions; EXPECT_FALSE(province_definitions.IsLandProvince("1")); EXPECT_FALSE(province_definitions.IsLandProvince("0x000002")); @@ -31,7 +34,7 @@ TEST(MapsProvincedefinitions, ProvincesCanBeShownAreNotLandProvinces) TEST(MapsProvincedefinitions, ProvincesCanBeShownAreLandProvinces) { - const maps::ProvinceDefinitions province_definitions({.land_provinces = {"1", "0x000002"}}); + const ProvinceDefinitions province_definitions({.land_provinces = {"1", "0x000002"}}); EXPECT_TRUE(province_definitions.IsLandProvince("1")); EXPECT_TRUE(province_definitions.IsLandProvince("0x000002")); @@ -40,7 +43,7 @@ TEST(MapsProvincedefinitions, ProvincesCanBeShownAreLandProvinces) TEST(MapsProvincedefinitions, SeaProvincesAreReturned) { - const maps::ProvinceDefinitions province_definitions({.sea_provinces = {"1", "2", "3", "4", "0x000005"}}); + const ProvinceDefinitions province_definitions({.sea_provinces = {"1", "2", "3", "4", "0x000005"}}); EXPECT_THAT(province_definitions.GetSeaProvinces(), testing::UnorderedElementsAre("1", "2", "3", "4", "0x000005")); } @@ -48,7 +51,7 @@ TEST(MapsProvincedefinitions, SeaProvincesAreReturned) TEST(MapsProvincedefinitions, ProvincesCanBeShownAreNotSeaProvinces) { - const maps::ProvinceDefinitions province_definitions; + const ProvinceDefinitions province_definitions; EXPECT_FALSE(province_definitions.IsSeaProvince("1")); EXPECT_FALSE(province_definitions.IsSeaProvince("0x000002")); @@ -57,7 +60,7 @@ TEST(MapsProvincedefinitions, ProvincesCanBeShownAreNotSeaProvinces) TEST(MapsProvincedefinitions, ProvincesCanBeShownAreSeaProvinces) { - const maps::ProvinceDefinitions province_definitions({.sea_provinces = {"1", "0x000002"}}); + const ProvinceDefinitions province_definitions({.sea_provinces = {"1", "0x000002"}}); EXPECT_TRUE(province_definitions.IsSeaProvince("1")); EXPECT_TRUE(province_definitions.IsSeaProvince("0x000002")); @@ -66,7 +69,7 @@ TEST(MapsProvincedefinitions, ProvincesCanBeShownAreSeaProvinces) TEST(MapsProvincedefinitions, ColorWithNoProvinceReturnsNullopt) { - const maps::ProvinceDefinitions province_definitions; + const ProvinceDefinitions province_definitions; EXPECT_EQ(province_definitions.GetProvinceFromColor(commonItems::Color(std::array{0, 0, 0})), std::nullopt); } @@ -74,7 +77,7 @@ TEST(MapsProvincedefinitions, ColorWithNoProvinceReturnsNullopt) TEST(MapsProvincedefinitions, ProvincesCanBeLookedUpByColor) { - const maps::ProvinceDefinitions province_definitions( + const ProvinceDefinitions province_definitions( {.color_to_province_map = {{{0x01'02'03, "1"}, {0x10'20'30, "0x000010"}}}}); EXPECT_EQ(province_definitions.GetProvinceFromColor(commonItems::Color(std::array{1, 2, 3})), "1"); @@ -84,7 +87,7 @@ TEST(MapsProvincedefinitions, ProvincesCanBeLookedUpByColor) TEST(MapsProvincedefinitions, TerrainTypeDefaultsToNullopt) { - const maps::ProvinceDefinitions province_definitions; + const ProvinceDefinitions province_definitions; EXPECT_EQ(province_definitions.GetTerrainType("1"), std::nullopt); EXPECT_EQ(province_definitions.GetTerrainType("0x000002"), std::nullopt); @@ -93,9 +96,11 @@ TEST(MapsProvincedefinitions, TerrainTypeDefaultsToNullopt) TEST(MapsProvincedefinitions, TerrainTypeCanBeLookedUp) { - const maps::ProvinceDefinitions province_definitions( + const ProvinceDefinitions province_definitions( {.terrain_types = {{"1", "test_terrain"}, {"0x000002", "test_terrain_two"}}}); EXPECT_EQ(province_definitions.GetTerrainType("1"), "test_terrain"); EXPECT_EQ(province_definitions.GetTerrainType("0x000002"), "test_terrain_two"); -} \ No newline at end of file +} + +} // namespace maps \ No newline at end of file diff --git a/src/maps/province_points_tests.cpp b/src/maps/province_points_tests.cpp index 1acf50f2..2d9f7ab6 100644 --- a/src/maps/province_points_tests.cpp +++ b/src/maps/province_points_tests.cpp @@ -3,84 +3,89 @@ +namespace maps +{ + TEST(MapsProvincepoints, CentermostIsOriginIfNoPoints) { - const maps::ProvincePoints province_points(std::set{}); + const ProvincePoints province_points(std::set{}); - constexpr maps::Point expected_point{0, 0}; + constexpr Point expected_point{0, 0}; EXPECT_EQ(province_points.GetCentermostPoint(), expected_point); } TEST(MapsProvincepoints, CenterPointIsAverageLatitude) { - maps::ProvincePoints province_points({maps::Point{0, 1}, maps::Point{0, 2}, maps::Point{0, 3}, maps::Point{0, 4}}); + const ProvincePoints province_points({Point{0, 1}, Point{0, 2}, Point{0, 3}, Point{0, 4}}); - constexpr maps::Point expected_point{0, 2}; + constexpr Point expected_point{0, 2}; EXPECT_EQ(province_points.GetCentermostPoint(), expected_point); } TEST(MapsProvincepoints, CenterPointIsAverageLongitude) { - maps::ProvincePoints province_points({maps::Point{1, 0}, maps::Point{2, 0}, maps::Point{3, 0}, maps::Point{4, 0}}); + const ProvincePoints province_points({Point{1, 0}, Point{2, 0}, Point{3, 0}, Point{4, 0}}); - constexpr maps::Point expected_point{2, 0}; + constexpr Point expected_point{2, 0}; EXPECT_EQ(province_points.GetCentermostPoint(), expected_point); } TEST(MapsProvincepoints, CentermostPointWhenCenterNotControlled) { - maps::ProvincePoints province_points({maps::Point{1, 0}, maps::Point{3, 0}, maps::Point{10, 0}}); + const ProvincePoints province_points({Point{1, 0}, Point{3, 0}, Point{10, 0}}); - constexpr maps::Point expected_point{3, 0}; + constexpr Point expected_point{3, 0}; EXPECT_EQ(province_points.GetCentermostPoint(), expected_point); } TEST(MapsProvincepoints, CentermostIsOriginIfNoPointsWhenAddingPoints) { - const maps::ProvincePoints province_points; + const ProvincePoints province_points; - constexpr maps::Point expected_point{0, 0}; + constexpr Point expected_point{0, 0}; EXPECT_EQ(province_points.GetCentermostPoint(), expected_point); } TEST(MapsProvincepoints, CenterPointIsAverageLatitudeWhenAddingPoints) { - maps::ProvincePoints province_points; - province_points.AddPoint(maps::Point{0, 1}); - province_points.AddPoint(maps::Point{0, 2}); - province_points.AddPoint(maps::Point{0, 3}); - province_points.AddPoint(maps::Point{0, 4}); + ProvincePoints province_points; + province_points.AddPoint(Point{0, 1}); + province_points.AddPoint(Point{0, 2}); + province_points.AddPoint(Point{0, 3}); + province_points.AddPoint(Point{0, 4}); - constexpr maps::Point expected_point{0, 2}; + constexpr Point expected_point{0, 2}; EXPECT_EQ(province_points.GetCentermostPoint(), expected_point); } TEST(MapsProvincepoints, CenterPointIsAverageLongitudeWhenAddingPoints) { - maps::ProvincePoints province_points; - province_points.AddPoint(maps::Point{1, 0}); - province_points.AddPoint(maps::Point{2, 0}); - province_points.AddPoint(maps::Point{3, 0}); - province_points.AddPoint(maps::Point{4, 0}); + ProvincePoints province_points; + province_points.AddPoint(Point{1, 0}); + province_points.AddPoint(Point{2, 0}); + province_points.AddPoint(Point{3, 0}); + province_points.AddPoint(Point{4, 0}); - constexpr maps::Point expected_point{2, 0}; + constexpr Point expected_point{2, 0}; EXPECT_EQ(province_points.GetCentermostPoint(), expected_point); } TEST(MapsProvincepoints, CentermostPointWhenCenterNotControlledWhenAddingPoints) { - maps::ProvincePoints province_points; - province_points.AddPoint(maps::Point{1, 0}); - province_points.AddPoint(maps::Point{3, 0}); - province_points.AddPoint(maps::Point{10, 0}); + ProvincePoints province_points; + province_points.AddPoint(Point{1, 0}); + province_points.AddPoint(Point{3, 0}); + province_points.AddPoint(Point{10, 0}); - constexpr maps::Point expected_point{3, 0}; + constexpr Point expected_point{3, 0}; EXPECT_EQ(province_points.GetCentermostPoint(), expected_point); -} \ No newline at end of file +} + +} // namespace maps \ No newline at end of file diff --git a/src/maps/utility_tests.cpp b/src/maps/utility_tests.cpp index ad90215e..d38b4092 100644 --- a/src/maps/utility_tests.cpp +++ b/src/maps/utility_tests.cpp @@ -4,25 +4,30 @@ +namespace maps +{ + TEST(MapsUtility, IntDefaultsToZero) { - EXPECT_EQ(maps::GetIntFromColor(commonItems::Color(std::array{0, 0, 0})), 0); + EXPECT_EQ(GetIntFromColor(commonItems::Color(std::array{0, 0, 0})), 0); } TEST(MapsUtility, RedIsLeftShiftedBy16) { - EXPECT_EQ(maps::GetIntFromColor(commonItems::Color(std::array{0x42, 0, 0})), 0x42'00'00); + EXPECT_EQ(GetIntFromColor(commonItems::Color(std::array{0x42, 0, 0})), 0x42'00'00); } TEST(MapsUtility, GreenIsLeftShiftedBy8) { - EXPECT_EQ(maps::GetIntFromColor(commonItems::Color(std::array{0, 0x42, 0})), 0x00'42'00); + EXPECT_EQ(GetIntFromColor(commonItems::Color(std::array{0, 0x42, 0})), 0x00'42'00); } TEST(MapsUtility, BlueIsNotShifted) { - EXPECT_EQ(maps::GetIntFromColor(commonItems::Color(std::array{0, 0, 0x42})), 0x00'00'42); -} \ No newline at end of file + EXPECT_EQ(GetIntFromColor(commonItems::Color(std::array{0, 0, 0x42})), 0x00'00'42); +} + +} // namespace maps \ No newline at end of file diff --git a/src/out_hoi4/map/out_supply_nodes_tests.cpp b/src/out_hoi4/map/out_supply_nodes_tests.cpp index 61adfee8..a1613a79 100644 --- a/src/out_hoi4/map/out_supply_nodes_tests.cpp +++ b/src/out_hoi4/map/out_supply_nodes_tests.cpp @@ -6,9 +6,12 @@ +namespace out +{ + TEST(Outhoi4MapOutsupplynodesTests, ExceptionThrownOnBadPath) { - ASSERT_THROW(out::OutputSupplyNodes("OutHoI4Tests/ExceptionThrownOnBadPath", std::set{}), std::runtime_error); + ASSERT_THROW(OutputSupplyNodes("OutHoI4Tests/ExceptionThrownOnBadPath", std::set{}), std::runtime_error); } @@ -19,7 +22,7 @@ TEST(Outhoi4MapOutsupplynodesTests, SupplyNodesAreOutput) commonItems::TryCreateFolder("output/Outhoi4MapOutsupplynodesTests/SupplyNodesAreOutput"); commonItems::TryCreateFolder("output/Outhoi4MapOutsupplynodesTests/SupplyNodesAreOutput/map"); - out::OutputSupplyNodes("Outhoi4MapOutsupplynodesTests/SupplyNodesAreOutput", {1, 2, 3}); + OutputSupplyNodes("Outhoi4MapOutsupplynodesTests/SupplyNodesAreOutput", {1, 2, 3}); std::ifstream file("output/Outhoi4MapOutsupplynodesTests/SupplyNodesAreOutput/map/supply_nodes.txt"); const std::string content((std::istreambuf_iterator(file)), std::istreambuf_iterator()); @@ -29,4 +32,6 @@ TEST(Outhoi4MapOutsupplynodesTests, SupplyNodesAreOutput) expected << "1 2\n"; expected << "1 3\n"; EXPECT_EQ(content, expected.str()); -} \ No newline at end of file +} + +} // namespace out \ No newline at end of file diff --git a/src/out_hoi4/out_mod_test.cpp b/src/out_hoi4/out_mod_test.cpp index 9f1a350a..8efc522d 100644 --- a/src/out_hoi4/out_mod_test.cpp +++ b/src/out_hoi4/out_mod_test.cpp @@ -15,13 +15,16 @@ +namespace out +{ + TEST(OutHoi4OutModTest, ModFolderIsCleared) { commonItems::TryCreateFolder("output"); commonItems::TryCreateFolder("output/test_output"); EXPECT_TRUE(commonItems::DoesFolderExist("output/test_output")); - out::ClearOutputFolder("test_output"); + ClearOutputFolder("test_output"); EXPECT_FALSE(commonItems::DoesFolderExist("output/test_output")); } @@ -35,7 +38,7 @@ TEST(OutHoi4OutModTest, FolderIsLoggedWhenCleared) std::streambuf* cout_buffer = std::cout.rdbuf(); std::cout.rdbuf(log.rdbuf()); - out::ClearOutputFolder("test_output"); + ClearOutputFolder("test_output"); EXPECT_THAT(log.str(), testing::HasSubstr("[INFO] Removing pre-existing copy of test_output")); std::cout.rdbuf(cout_buffer); @@ -46,7 +49,7 @@ TEST(OutHoi4OutModTest, NoOperationOnMissingModFolder) { EXPECT_FALSE(commonItems::DoesFolderExist("output/test_output")); - out::ClearOutputFolder("test_output"); + ClearOutputFolder("test_output"); EXPECT_FALSE(commonItems::DoesFolderExist("output/test_output")); } @@ -57,7 +60,7 @@ TEST(OutHoi4OutModTest, FolderIsNotLoggedWhenNotCleared) std::streambuf* cout_buffer = std::cout.rdbuf(); std::cout.rdbuf(log.rdbuf()); - out::ClearOutputFolder("test_output"); + ClearOutputFolder("test_output"); EXPECT_EQ(log.str(), ""); @@ -67,14 +70,14 @@ TEST(OutHoi4OutModTest, FolderIsNotLoggedWhenNotCleared) TEST(OutHoi4OutModTest, StatusIsLoggedWhenWritingMod) { - out::ClearOutputFolder("status_test_output"); + ClearOutputFolder("status_test_output"); std::filesystem::remove("output/status_test_output.mod"); std::stringstream log; std::streambuf* cout_buffer = std::cout.rdbuf(); std::cout.rdbuf(log.rdbuf()); - out::OutputMod("status_test_output", GameVersion()); + OutputMod("status_test_output", GameVersion()); EXPECT_THAT(log.str(), testing::HasSubstr("[PROGRESS] 80%")); EXPECT_THAT(log.str(), testing::HasSubstr("[INFO] Outputting mod")); @@ -88,9 +91,9 @@ TEST(OutHoi4OutModTest, StatusIsLoggedWhenWritingMod) TEST(OutHoi4OutModTest, ModFolderIsCreated) { - out::ClearOutputFolder("mod_folder_test_output"); + ClearOutputFolder("mod_folder_test_output"); std::filesystem::remove("output/mod_folder_test_output.mod"); - out::OutputMod("mod_folder_test_output", GameVersion()); + OutputMod("mod_folder_test_output", GameVersion()); EXPECT_TRUE(commonItems::DoesFolderExist("output/mod_folder_test_output")); } @@ -98,9 +101,9 @@ TEST(OutHoi4OutModTest, ModFolderIsCreated) TEST(OutHoi4OutModTest, ModFileIsCreated) { - out::ClearOutputFolder("mod_file_test_output"); + ClearOutputFolder("mod_file_test_output"); std::filesystem::remove("output/mod_file_test_output.mod"); - out::OutputMod("mod_file_test_output", GameVersion()); + OutputMod("mod_file_test_output", GameVersion()); ASSERT_TRUE(commonItems::DoesFolderExist("output/mod_file_test_output")); @@ -132,9 +135,9 @@ TEST(OutHoi4OutModTest, ModFileIsCreated) TEST(OutHoi4OutModTest, DescriptorFileIsCreated) { - out::ClearOutputFolder("descriptor_file_test_output"); + ClearOutputFolder("descriptor_file_test_output"); std::filesystem::remove("output/descriptor_file_test_output.mod"); - out::OutputMod("descriptor_file_test_output", GameVersion()); + OutputMod("descriptor_file_test_output", GameVersion()); ASSERT_TRUE(commonItems::DoesFolderExist("output/descriptor_file_test_output")); @@ -166,9 +169,9 @@ TEST(OutHoi4OutModTest, DescriptorFileIsCreated) TEST(OutHoi4OutModTest, SupportedVersionIsFromSuppliedVersion) { - out::ClearOutputFolder("version_test_output"); + ClearOutputFolder("version_test_output"); std::filesystem::remove("output/version_test_output.mod"); - out::OutputMod("version_test_output", GameVersion("42.13")); + OutputMod("version_test_output", GameVersion("42.13")); ASSERT_TRUE(commonItems::DoesFolderExist("output/version_test_output")); @@ -191,4 +194,6 @@ TEST(OutHoi4OutModTest, SupportedVersionIsFromSuppliedVersion) descriptor_file.close(); EXPECT_THAT(descriptor_file_stream.str(), testing::HasSubstr("supported_version=\"42.13.*\"")); -} \ No newline at end of file +} + +} // namespace out \ No newline at end of file diff --git a/src/vic3_world/countries/vic3_country_tests.cpp b/src/vic3_world/countries/vic3_country_tests.cpp index 9c1e0bcb..176fe49e 100644 --- a/src/vic3_world/countries/vic3_country_tests.cpp +++ b/src/vic3_world/countries/vic3_country_tests.cpp @@ -6,10 +6,12 @@ -TEST(Vic3worldCountriesVic3country, ColorCanBeSet) +namespace vic3 { - vic3::Country country({.number = 1}); +TEST(Vic3worldCountriesVic3country, ColorCanBeSet) +{ + Country country({.number = 1}); country.SetColor(commonItems::Color{std::array{1, 2, 3}}); const commonItems::Color expected_color{std::array{1, 2, 3}}; @@ -19,21 +21,21 @@ TEST(Vic3worldCountriesVic3country, ColorCanBeSet) TEST(Vic3worldCountriesVic3country, GetAcquiredTechEmpty) { - const auto state = vic3::Country(vic3::CountryOptions{ + const Country country = Country(CountryOptions{ .number = 2, }); - const auto world = vic3::World({.acquired_technologies = {{1, {"tech_a", "tech_b"}}}}); - EXPECT_TRUE(state.GetAcquiredTechnologies(world).empty()); + const auto world = World({.acquired_technologies = {{1, {"tech_a", "tech_b"}}}}); + EXPECT_TRUE(country.GetAcquiredTechnologies(world).empty()); } TEST(Vic3worldCountriesVic3country, GetAcquiredTech) { - const auto state = vic3::Country(vic3::CountryOptions{ + const Country country = Country(CountryOptions{ .number = 1, }); - const auto world = vic3::World({.acquired_technologies = {{1, {"tech_a", "tech_b"}}}}); - EXPECT_THAT(state.GetAcquiredTechnologies(world), testing::UnorderedElementsAre("tech_a", "tech_b")); + const auto world = World({.acquired_technologies = {{1, {"tech_a", "tech_b"}}}}); + EXPECT_THAT(country.GetAcquiredTechnologies(world), testing::UnorderedElementsAre("tech_a", "tech_b")); } @@ -64,13 +66,13 @@ TEST(Vic3worldCountriesVic3country, PowerRankWorks) input << " }\n"; input << "}"; - const vic3::CountryRankings country_rankings = vic3::ImportCountryRankings(input); + const CountryRankings country_rankings = ImportCountryRankings(input); - const vic3::Country c1({.number = 1}); - const vic3::Country c2({.number = 2}); - const vic3::Country c3({.number = 3}); + const Country c1({.number = 1}); + const Country c2({.number = 2}); + const Country c3({.number = 3}); - const vic3::World world({ + const World world({ .countries = { {1, c1}, @@ -80,69 +82,71 @@ TEST(Vic3worldCountriesVic3country, PowerRankWorks) .country_rankings = country_rankings, }); - EXPECT_EQ(c1.GetCountryRankCategory(world), vic3::RankCategory::GreatPower); - EXPECT_EQ(c2.GetCountryRankCategory(world), vic3::RankCategory::MajorPower); - EXPECT_EQ(c3.GetCountryRankCategory(world), vic3::RankCategory::MinorPower); + EXPECT_EQ(c1.GetCountryRankCategory(world), RankCategory::GreatPower); + EXPECT_EQ(c2.GetCountryRankCategory(world), RankCategory::MajorPower); + EXPECT_EQ(c3.GetCountryRankCategory(world), RankCategory::MinorPower); } -TEST(Vic3worldCountriesVic3country, IsDecentralized_DecentralizedNation) +TEST(Vic3worldCountriesVic3country, DecentralizedCountriesAreDecentralized) { - vic3::Country c1({.country_type = "decentralized"}); + const Country c1({.country_type = "decentralized"}); EXPECT_TRUE(c1.IsDecentralized()); } -TEST(Vic3worldCountriesVic3country, IsDecentralized_ColonialNation) +TEST(Vic3worldCountriesVic3country, ColonalCountriesAreNotDecentralized) { - vic3::Country c2({.country_type = "colonial"}); + const Country c2({.country_type = "colonial"}); EXPECT_FALSE(c2.IsDecentralized()); } -TEST(Vic3worldCountriesVic3country, IsDecentralized_UnrecognizedNation) +TEST(Vic3worldCountriesVic3country, UnrecognizedCountriesAreNotDecentralized) { - vic3::Country c3({.country_type = "unrecognized"}); + const Country c3({.country_type = "unrecognized"}); EXPECT_FALSE(c3.IsDecentralized()); } -TEST(Vic3worldCountriesVic3country, IsDecentralized_RecognizedNation) +TEST(Vic3worldCountriesVic3country, RecognizedCountriesAreNotDecentralized) { - vic3::Country c4({.country_type = "recognized"}); + const Country c4({.country_type = "recognized"}); EXPECT_FALSE(c4.IsDecentralized()); } -TEST(Vic3worldCountriesVic3country, IsRecognized_DecentralizedNation) +TEST(Vic3worldCountriesVic3country, DecentralizedCountriesAreNotRecognized) { - vic3::Country c1({.country_type = "decentralized"}); + const Country c1({.country_type = "decentralized"}); EXPECT_FALSE(c1.IsRecognized()); } -TEST(Vic3worldCountriesVic3country, IsRecognized_ColonialNation) +TEST(Vic3worldCountriesVic3country, ColonialCountriesAreRecognized) { - vic3::Country c2({.country_type = "colonial"}); + const Country c2({.country_type = "colonial"}); EXPECT_TRUE(c2.IsRecognized()); } -TEST(Vic3worldCountriesVic3country, IsRecognized_UnrecognizedNation) +TEST(Vic3worldCountriesVic3country, UnrecognizedCountriesAreNotRecognized) { - vic3::Country c3({.country_type = "unrecognized"}); + const Country c3({.country_type = "unrecognized"}); EXPECT_FALSE(c3.IsRecognized()); } -TEST(Vic3worldCountriesVic3country, IsRecognized_RecognizedNation) +TEST(Vic3worldCountriesVic3country, RecognizedCountriesAreRecognized) { - vic3::Country c4({.country_type = "recognized"}); + const Country c4({.country_type = "recognized"}); EXPECT_TRUE(c4.IsRecognized()); } TEST(Vic3worldCountriesVic3country, DefaultLegitimacyZero) { - vic3::Country c4({}); + const Country c4({}); EXPECT_EQ(c4.GetLegitimacy(), 0); -} \ No newline at end of file +} + +} // namespace vic3 \ No newline at end of file