• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ParadoxGameConverters / Vic3ToHoI4 / 16851853331

09 Aug 2025 05:21PM UTC coverage: 94.214% (+0.01%) from 94.201%
16851853331

Pull #746

github

web-flow
Merge 902d0a8c6 into 27b1ac9ea
Pull Request #746: More triggers

374 of 431 new or added lines in 32 files covered. (86.77%)

1 existing line in 1 file now uncovered.

22488 of 23869 relevant lines covered (94.21%)

56595.73 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

82.83
/src/hoi4_world/world/hoi4_world_converter_tests.cpp
1
#include <external/commonItems/external/googletest/googlemock/include/gmock/gmock-matchers.h>
2
#include <external/commonItems/external/googletest/googletest/include/gtest/gtest.h>
3
#include <external/fmt/include/fmt/format.h>
4

5
#include <sstream>
6

7
#include "hoi4_world_framework_builder.h"
8
#include "src/hoi4_world/countries/hoi4_country.h"
9
#include "src/hoi4_world/world/hoi4_world.h"
10
#include "src/hoi4_world/world/hoi4_world_converter.h"
11
#include "src/mappers/country/country_mapper.h"
12
#include "src/mappers/provinces/province_mapper.h"
13
#include "src/mappers/world/world_mapper_builder.h"
14
#include "src/maps/province_definitions.h"
15
#include "src/vic3_world/characters/vic3_character.h"
16
#include "src/vic3_world/countries/vic3_country.h"
17
#include "src/vic3_world/provinces/vic3_province_definitions.h"
18
#include "src/vic3_world/world/vic3_world.h"
19

20

21

22
namespace hoi4
23
{
24

25
TEST(Hoi4worldWorldHoi4worldconverter, EmptyWorldIsEmpty)
4✔
26
{
27
   const vic3::World source_world(vic3::WorldOptions{});
1✔
28
   const mappers::WorldMapper world_mapper = mappers::WorldMapperBuilder::CreateNullMapper().Build();
1✔
29

30
   const World world = ConvertWorld(commonItems::ModFilesystem("test_files/hoi4_world", {}),
2✔
31
       source_world,
32
       world_mapper,
33
       std::async<>(std::launch::async, []() {
3✔
34
          return hoi4::WorldFrameworkBuilder::CreateNullWorldFramework().Build();
2✔
35
       }));
1✔
36

37
   EXPECT_TRUE(world.GetCountries().empty());
1✔
38
   EXPECT_TRUE(world.GetStates().states.empty());
1✔
39
   EXPECT_TRUE(world.GetStates().province_to_state_id_map.empty());
1✔
40
   EXPECT_TRUE(world.GetCharacters().empty());
1✔
41
}
3✔
42

43

44
TEST(Hoi4worldWorldHoi4worldconverter, CountriesAreConverted)
4✔
45
{
46
   const vic3::Country source_country_one({
47
       .number = 1,
48
       .tag = "TAG",
49
       .color = commonItems::Color{std::array{1, 2, 3}},
50
       .head_of_state_id = 1,
51
       .character_ids = {1},
52
   });
2✔
53
   const vic3::Country source_country_two({
54
       .number = 3,
55
       .tag = "TWO",
56
       .color = commonItems::Color{std::array{2, 4, 6}},
57
       .head_of_state_id = 3,
58
       .character_ids = {2, 3},
59
   });
1✔
60

61
   vic3::Character character_one({.id = 1});  // Compiler was being weird about it directly in map
1✔
62
   vic3::Character character_two({.id = 2, .roles = {"agitator"}});
2✔
63
   vic3::Character character_three({.id = 3});
1✔
64
   const vic3::World source_world({
65
       .countries = {{1, source_country_one}, {3, source_country_two}},
×
66
       .states = {},
67
       .acquired_technologies =
68
           {
69
               {1, {"source_tech"}},
×
70
               {3, {"source_tech_two", "source_tech_three"}},
×
71
           },
72
       .characters =
73
           {
74
               {1, character_one},
×
75
               {2, character_two},
×
76
               {3, character_three},
×
77
           },
78
   });
11✔
79

80
   const mappers::WorldMapper world_mapper = mappers::WorldMapperBuilder::CreateNullMapper()
×
81
                                                 .AddCountries({{1, "TAG"}, {3, "TWO"}})
4✔
82
                                                 .DefaultTechMapper()
1✔
83
                                                 .Build();
1✔
84
   const World world = ConvertWorld(commonItems::ModFilesystem("test_files/hoi4_world", {}),
2✔
85
       source_world,
86
       world_mapper,
87
       std::async<>(std::launch::async, []() {
3✔
88
          return hoi4::WorldFrameworkBuilder::CreateNullWorldFramework().Build();
2✔
89
       }));
1✔
90

91
   const Technologies expected_techs_one{std::map<std::optional<std::string>, std::set<std::string>>{
4✔
92
       {std::nullopt, std::set<std::string>{"dest_tech_one", "dest_tech_two"}}}};
7✔
93
   const Technologies expected_techs_two{std::map<std::optional<std::string>, std::set<std::string>>{
4✔
94
       {R"(not = { has_dlc = "Test DLC" })", std::set<std::string>{"dest_tech_three"}}}};
6✔
95
   const std::vector<EquipmentVariant> expected_legacy_ship_variants_one = {
96
       EquipmentVariant("Test Legacy Ship Variant Three", "", {}, {"dest_technology_two"}, {}),
1✔
97
       EquipmentVariant("Test Legacy Ship Variant Four", "", {}, {"dest_technology_four"}, {}),
1✔
98
   };
3✔
99
   const std::vector<EquipmentVariant> expected_legacy_ship_variants_two = {
100
       EquipmentVariant("Test Legacy Ship Variant Three", "", {}, {"dest_technology_two"}, {}),
1✔
101
       EquipmentVariant("Test Legacy Ship Variant Four", "", {}, {"dest_technology_four"}, {}),
1✔
102
   };
3✔
103
   const std::vector<EquipmentVariant> expected_ship_variants_one = {
104
       EquipmentVariant("Test Ship Variant Three", "", {}, {"dest_technology_two"}, {}),
1✔
105
       EquipmentVariant("Test Ship Variant Four", "", {}, {"dest_technology_four"}, {}),
1✔
106
   };
3✔
107
   const std::vector<EquipmentVariant> expected_ship_variants_two = {
108
       EquipmentVariant("Test Ship Variant Three", "", {}, {"dest_technology_two"}, {}),
1✔
109
       EquipmentVariant("Test Ship Variant Four", "", {}, {"dest_technology_four"}, {}),
1✔
110
   };
3✔
111
   const std::vector<EquipmentVariant> expected_plane_variants_one = {
112
       EquipmentVariant("Test Plane Design Three", "", {}, {"dest_technology_two"}, {}),
1✔
113
       EquipmentVariant("Test Plane Design Four", "", {}, {"dest_technology_four"}, {}),
1✔
114
   };
3✔
115
   const std::vector<EquipmentVariant> expected_plane_variants_two = {
116
       EquipmentVariant("Test Plane Design Three", "", {}, {"dest_technology_two"}, {}),
1✔
117
       EquipmentVariant("Test Plane Design Four", "", {}, {"dest_technology_four"}, {}),
1✔
118
   };
3✔
119
   const std::vector<EquipmentVariant> expected_tank_variants_one = {
120
       EquipmentVariant("Test Tank Design Three", "", {}, {"dest_technology_two"}, {}),
1✔
121
       EquipmentVariant("Test Tank Design Four", "", {}, {"dest_technology_four"}, {}),
1✔
122
   };
3✔
123
   const std::vector<EquipmentVariant> expected_tank_variants_two = {
124
       EquipmentVariant("Test Tank Design Three", "", {}, {"dest_technology_two"}, {}),
1✔
125
       EquipmentVariant("Test Tank Design Four", "", {}, {"dest_technology_four"}, {}),
1✔
126
   };
3✔
127

128
   EXPECT_THAT(world.GetCountries(),
6✔
129
       testing::ElementsAre(testing::Pair("TAG",
130
                                Country(CountryOptions{
131
                                    .source_country_number = 1,
132
                                    .tag = "TAG",
133
                                    .color = commonItems::Color{std::array{1, 2, 3}},
134
                                    .ideology_support = {{"neutrality", 100}},
135
                                    .technologies = expected_techs_one,
136
                                    .legacy_ship_variants = expected_legacy_ship_variants_one,
137
                                    .ship_variants = expected_ship_variants_one,
138
                                    .plane_variants = expected_plane_variants_one,
139
                                    .tank_variants = expected_tank_variants_one,
140
                                    .character_ids = {1},
141
                                    .starting_research_slots = 3,
142
                                })),
143
           testing::Pair("TWO",
144
               Country(CountryOptions{
145
                   .source_country_number = 3,
146
                   .tag = "TWO",
147
                   .color = commonItems::Color{std::array{2, 4, 6}},
148
                   .ideology_support = {{"neutrality", 100}},
149
                   .technologies = expected_techs_two,
150
                   .legacy_ship_variants = expected_legacy_ship_variants_two,
151
                   .ship_variants = expected_ship_variants_two,
152
                   .plane_variants = expected_plane_variants_two,
153
                   .tank_variants = expected_tank_variants_two,
154
                   .character_ids = {3},
155
                   .spy_ids = {2},
156
                   .starting_research_slots = 3,
157
               }))));
1✔
158
}
53✔
159

160

161
TEST(Hoi4worldWorldHoi4worldconverter, StatesAreConverted)
4✔
162
{
163
   const std::map<std::string, vic3::StateRegion> state_regions({{"STATE_ONE",
164
       vic3::StateRegion(
8✔
165
           {
166
               {"x000005", "city"},
167
               {"x000004", "port"},
168
               {"x000003", "farm"},
169
               {"x000002", "mine"},
170
               {"x000001", "wood"},
171
           },
172
           {})}});
10✔
173
   const auto province_definitions = vic3::ProvinceDefinitions({
174
       "x000001",
175
       "x000002",
176
       "x000003",
177
       "x000004",
178
       "x000005",
179
       "x000006",
180
   });
7✔
181
   const vic3::Buildings vic3_buildings({
182
       {1, std::vector{vic3::Building("", 1, 875'000)}},
3✔
183
       {2, std::vector{vic3::Building("", 2, 700'000)}},
3✔
184
   });
3✔
185

186
   const vic3::World source_world(vic3::WorldOptions{
1✔
187
       .states =
188
           {
189
               {1, vic3::State({.owner_number = 1, .owner_tag = "TAG", .provinces = {1, 2, 3}})},
1✔
190
               {2, vic3::State({.owner_number = 2, .owner_tag = "TWO", .provinces = {4, 5, 6}})},
1✔
191
           },
192
       .state_regions = state_regions,
193
       .province_definitions = province_definitions,
194
       .buildings = vic3_buildings,
195
   });
2✔
196

197
   const mappers::WorldMapper world_mapper = mappers::WorldMapperBuilder::CreateNullMapper()
×
198
                                                 .AddCountries({{1, "TAG"}, {2, "TWO"}})
4✔
199
                                                 .AddProvinces({
20✔
200
                                                     {"x000001", {10}},
×
201
                                                     {"x000002", {20}},
×
202
                                                     {"x000003", {30}},
×
203
                                                     {"x000004", {40}},
×
204
                                                     {"x000005", {50}},
×
205
                                                     {"x000006", {60}},
×
206
                                                 })
207
                                                 .Build();
1✔
208
   const World world = ConvertWorld(commonItems::ModFilesystem("test_files/hoi4_world", {}),
2✔
209
       source_world,
210
       world_mapper,
211
       std::async<>(std::launch::async, []() {
3✔
212
          return hoi4::WorldFrameworkBuilder::CreateDefaultWorldFramework(
2✔
213
              commonItems::ModFilesystem("test_files/hoi4_world", {}))
2✔
214
              .Build();
2✔
215
       }));
1✔
216

217
   EXPECT_THAT(world.GetStates().states,
3✔
218
       testing::ElementsAre(State(1,
219
                                {.owner = "TAG",
220
                                    .provinces = {10, 20, 30},
221
                                    .category = "large_city",
222
                                    .continent = "europe",
223
                                    .victory_points = {{30, 3}},
224
                                    .civilian_factories = 3,
225
                                    .military_factories = 2,
226
                                    .air_base_level = 1}),
227
           State(2,
228
               {.owner = "TWO",
229
                   .provinces = {40, 50, 60},
230
                   .category = "city",
231
                   .continent = "australia",
232
                   .victory_points = {{50, 2}},
233
                   .civilian_factories = 2,
234
                   .military_factories = 2,
235
                   .air_base_level = 1})));
1✔
236
   EXPECT_THAT(world.GetStates().province_to_state_id_map,
1✔
237
       testing::UnorderedElementsAre(testing::Pair(10, 1),
238
           testing::Pair(20, 1),
239
           testing::Pair(30, 1),
240
           testing::Pair(40, 2),
241
           testing::Pair(50, 2),
242
           testing::Pair(60, 2)));
1✔
243
}
31✔
244

245

246
TEST(Hoi4worldWorldHoi4worldconverter, CapitalsGetExtraVictoryPointValue)
4✔
247
{
248
   std::map<int, vic3::Country> countries;
1✔
249
   std::map<std::string, vic3::StateRegion> state_regions;
1✔
250
   std::vector<std::string> province_definitions_initializer;
1✔
251
   std::map<int, std::vector<vic3::Building>> buildings_initializer;
1✔
252
   std::map<int, int> scored_countries;
1✔
253
   std::map<int, vic3::State> vic3_states;
1✔
254

255
   mappers::WorldMapperBuilder mapper_builder = mappers::WorldMapperBuilder::CreateNullMapper();
1✔
256
   for (int i = 1; i <= 80; ++i)
81✔
257
   {
258
      mapper_builder.AddCountries({{i, fmt::format("X{:0>2}", i)}});
160✔
259
      countries.emplace(i,
80✔
260
          vic3::Country({
80✔
261
              .number = i,
262
              .tag = fmt::format("X{:0>2}", i),
263
              .capital_state = i,
264
          }));
265
      state_regions.emplace(fmt::format("STATE_{:0>2}", i),
80✔
266
          vic3::StateRegion(
400✔
267
              {
268
                  {fmt::format("x0000{:0>2}", i), "city"},
80✔
269
              },
270
              {}));
160✔
271
      province_definitions_initializer.emplace_back(fmt::format("x0000{:0>2}", i));
80✔
272
      buildings_initializer.emplace(i, std::vector{vic3::Building("", i, 1000.0f - i)});
160✔
273
      scored_countries.emplace(i, i);
80✔
274
      vic3_states.emplace(i,
80✔
275
          vic3::State({.owner_number = i, .owner_tag = fmt::format("x0000{:0>2}", i), .provinces = {i}}));
160✔
276
      mapper_builder.AddProvinces({{fmt::format("x0000{:0>2}", i), i}});
160✔
277
   }
278
   const vic3::ProvinceDefinitions province_definitions(province_definitions_initializer);
1✔
279
   const vic3::Buildings buildings;
1✔
280
   const vic3::CountryRankings country_rankings({1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}, scored_countries);
1✔
281

282
   const vic3::World source_world(vic3::WorldOptions{
1✔
283
       .countries = countries,
284
       .states = vic3_states,
285
       .state_regions = state_regions,
286
       .province_definitions = province_definitions,
287
       .buildings = buildings,
288
       .country_rankings = country_rankings,
289
   });
1✔
290

291
   const World world =
292
       ConvertWorld(commonItems::ModFilesystem("test_files/hoi4_world/CapitalsGetExtraVictoryPointValue", {}),
2✔
293
           source_world,
294
           mapper_builder.Build(),
2✔
295
           std::async<>(std::launch::async, []() {
2✔
296
              return hoi4::WorldFrameworkBuilder::CreateDefaultWorldFramework(
2✔
297
                  commonItems::ModFilesystem("test_files/hoi4_world/CapitalsGetExtraVictoryPointValue", {}))
2✔
298
                  .Build();
2✔
299
           }));
1✔
300

301
   // HoI4 states are in an arbitrary order compared to Vic3 states, so store by province number for the actual checks
302
   std::map<int, State> states;
1✔
303
   for (const auto& state: world.GetStates().states)
81✔
304
   {
305
      ASSERT_FALSE(state.GetProvinces().empty());
80✔
306
      const int province = *state.GetProvinces().begin();
80✔
307
      states.emplace(province, state);
80✔
308
   }
309

310
   // five great powers, first two have a VP of 50
311
   EXPECT_THAT(states.at(1).GetVictoryPoints(), testing::UnorderedElementsAre(testing::Pair(1, 50)));
1✔
312
   EXPECT_THAT(states.at(2).GetVictoryPoints(), testing::UnorderedElementsAre(testing::Pair(2, 50)));
1✔
313

314
   // remaining GPs have VPs worth 40
315
   EXPECT_THAT(states.at(3).GetVictoryPoints(), testing::UnorderedElementsAre(testing::Pair(3, 40)));
1✔
316
   EXPECT_THAT(states.at(4).GetVictoryPoints(), testing::UnorderedElementsAre(testing::Pair(4, 40)));
1✔
317
   EXPECT_THAT(states.at(5).GetVictoryPoints(), testing::UnorderedElementsAre(testing::Pair(5, 40)));
1✔
318

319
   // five major powers, first two have a VP of 30
320
   EXPECT_THAT(states.at(6).GetVictoryPoints(), testing::UnorderedElementsAre(testing::Pair(6, 30)));
1✔
321
   EXPECT_THAT(states.at(7).GetVictoryPoints(), testing::UnorderedElementsAre(testing::Pair(7, 30)));
1✔
322

323
   // remaining majors have VPs worth 25
324
   EXPECT_THAT(states.at(8).GetVictoryPoints(), testing::UnorderedElementsAre(testing::Pair(8, 25)));
1✔
325
   EXPECT_THAT(states.at(9).GetVictoryPoints(), testing::UnorderedElementsAre(testing::Pair(9, 25)));
1✔
326
   EXPECT_THAT(states.at(10).GetVictoryPoints(), testing::UnorderedElementsAre(testing::Pair(10, 25)));
1✔
327

328
   // the first 30 of the remaining countries have VPs worth 20
329
   for (int i = 11; i < 41; ++i)
31✔
330
   {
331
      EXPECT_THAT(states.at(i).GetVictoryPoints(), testing::UnorderedElementsAre(testing::Pair(i, 20)));
30✔
332
   }
333

334
   // the next 30 of the remaining countries have VPs worth 15
335
   for (int i = 41; i < 71; ++i)
31✔
336
   {
337
      EXPECT_THAT(states.at(i).GetVictoryPoints(), testing::UnorderedElementsAre(testing::Pair(i, 15)));
30✔
338
   }
339

340
   // the remaining countries have VPs worth 10
341
   for (int i = 71; i < 81; ++i)
11✔
342
   {
343
      EXPECT_THAT(states.at(i).GetVictoryPoints(), testing::UnorderedElementsAre(testing::Pair(i, 10)));
10✔
344
   }
345
}
563✔
346

347

348
TEST(Hoi4worldWorldHoi4worldconverter, CapitalsGetExtraAirBaseLevel)
4✔
349
{
350
   const vic3::Country source_country_one({
351
       .number = 1,
352
       .tag = "TAG",
353
       .color = commonItems::Color{std::array{1, 2, 3}},
354
       .head_of_state_id = 1,
355
       .character_ids = {1},
356
   });
2✔
357

358
   const std::map<std::string, vic3::StateRegion> state_regions({{"STATE_ONE",
359
       vic3::StateRegion(
8✔
360
           {
361
               {"x000005", "city"},
362
               {"x000004", "port"},
363
               {"x000003", "farm"},
364
               {"x000002", "mine"},
365
               {"x000001", "wood"},
366
           },
367
           {})}});
9✔
368
   const auto province_definitions = vic3::ProvinceDefinitions({
369
       "x000001",
370
       "x000002",
371
       "x000003",
372
       "x000004",
373
       "x000005",
374
       "x000006",
375
   });
7✔
376
   const vic3::Buildings vic3_buildings({
377
       {1, std::vector{vic3::Building("", 1, 0)}},
3✔
378
       {2, std::vector{vic3::Building("", 2, 0)}},
3✔
379
   });
3✔
380

381
   const vic3::World source_world(vic3::WorldOptions{
1✔
382
       .countries = {{1, source_country_one}},
×
383
       .states =
384
           {
385
               {1, vic3::State({.owner_number = 1, .owner_tag = "TAG", .provinces = {1, 2, 3}})},
1✔
386
               {2, vic3::State({.owner_number = 2, .owner_tag = "TWO", .provinces = {4, 5, 6}})},
1✔
387
           },
388
       .state_regions = state_regions,
389
       .province_definitions = province_definitions,
390
       .buildings = vic3_buildings,
391
   });
3✔
392

393
   const mappers::WorldMapper world_mapper = mappers::WorldMapperBuilder::CreateNullMapper()
×
394
                                                 .AddCountries({{1, "TAG"}})
3✔
395
                                                 .AddProvinces({
20✔
396
                                                     {"x000001", {10}},
×
397
                                                     {"x000002", {20}},
×
398
                                                     {"x000003", {30}},
×
399
                                                     {"x000004", {40}},
×
400
                                                     {"x000005", {50}},
×
401
                                                     {"x000006", {60}},
×
402
                                                 })
403
                                                 .Build();
1✔
404
   const World world = ConvertWorld(commonItems::ModFilesystem("test_files/hoi4_world", {}),
2✔
405
       source_world,
406
       world_mapper,
407
       std::async<>(std::launch::async, []() {
3✔
408
          return hoi4::WorldFrameworkBuilder::CreateDefaultWorldFramework(
2✔
409
              commonItems::ModFilesystem("test_files/hoi4_world", {}))
2✔
410
              .Build();
2✔
411
       }));
1✔
412

413
   EXPECT_THAT(world.GetStates().states,
3✔
414
       testing::ElementsAre(State(1,
415
                                {.owner = "TAG",
416
                                    .provinces = {10, 20, 30},
417
                                    .category = "rural",
418
                                    .is_capital = true,
419
                                    .continent = "europe",
420
                                    .victory_points = {{30, 1}},
421
                                    .air_base_level = 5}),
422
           State(2,
423
               {.provinces = {40, 50, 60},
424
                   .category = "rural",
425
                   .continent = "australia",
426
                   .victory_points = {{50, 1}},
427
                   .air_base_level = 0})));
1✔
428
}
33✔
429

430

431
TEST(Hoi4worldWorldHoi4worldconverter, CapitalsAreMarkedAsCapitals)
4✔
432
{
433
   const vic3::Country source_country_one(
434
       {.number = 1, .tag = "TAG", .color = commonItems::Color{std::array{1, 2, 3}}, .capital_state = 1});
2✔
435

436
   const std::map<std::string, vic3::StateRegion> state_regions({{"STATE_ONE",
437
       vic3::StateRegion(
8✔
438
           {
439
               {"x000005", "city"},
440
               {"x000004", "port"},
441
               {"x000003", "farm"},
442
               {"x000002", "mine"},
443
               {"x000001", "wood"},
444
           },
445
           {})}});
9✔
446
   const auto province_definitions = vic3::ProvinceDefinitions({
447
       "x000001",
448
       "x000002",
449
       "x000003",
450
       "x000004",
451
       "x000005",
452
       "x000006",
453
   });
7✔
454
   const vic3::Buildings vic3_buildings({
455
       {1, std::vector{vic3::Building("", 1, 0)}},
3✔
456
       {2, std::vector{vic3::Building("", 2, 0)}},
3✔
457
   });
3✔
458

459
   const vic3::World source_world(vic3::WorldOptions{
1✔
NEW
460
       .countries = {{1, source_country_one}},
×
461
       .states =
462
           {
463
               {1, vic3::State({.owner_number = 1, .owner_tag = "TAG", .provinces = {1, 2, 3}})},
1✔
464
               {2, vic3::State({.owner_number = 2, .owner_tag = "TWO", .provinces = {4, 5, 6}})},
1✔
465
           },
466
       .state_regions = state_regions,
467
       .province_definitions = province_definitions,
468
       .buildings = vic3_buildings,
469
   });
3✔
470

NEW
471
   const mappers::WorldMapper world_mapper = mappers::WorldMapperBuilder::CreateNullMapper()
×
472
                                                 .AddCountries({{1, "TAG"}})
3✔
473
                                                 .AddProvinces({
20✔
NEW
474
                                                     {"x000001", {10}},
×
NEW
475
                                                     {"x000002", {20}},
×
NEW
476
                                                     {"x000003", {30}},
×
NEW
477
                                                     {"x000004", {40}},
×
NEW
478
                                                     {"x000005", {50}},
×
NEW
479
                                                     {"x000006", {60}},
×
480
                                                 })
481
                                                 .Build();
1✔
482
   const World world = ConvertWorld(commonItems::ModFilesystem("test_files/hoi4_world", {}),
2✔
483
       source_world,
484
       world_mapper,
485
       std::async<>(std::launch::async, []() {
3✔
486
          return hoi4::WorldFrameworkBuilder::CreateDefaultWorldFramework(
2✔
487
              commonItems::ModFilesystem("test_files/hoi4_world", {}))
2✔
488
              .Build();
2✔
489
       }));
1✔
490

491
   EXPECT_TRUE(world.GetStates().states[0].IsCapital());
1✔
492
   EXPECT_FALSE(world.GetStates().states[1].IsCapital());
1✔
493
}
30✔
494

495

496
TEST(Hoi4worldWorldHoi4worldconverter, StrategicRegionsAreCreated)
4✔
497
{
498
   const auto province_definitions = vic3::ProvinceDefinitions({
499
       "x000001",
500
       "x000002",
501
       "x000003",
502
       "x000004",
503
       "x000005",
504
       "x000006",
505
   });
7✔
506

507
   const vic3::World source_world({
508
       .states =
509
           {
510
               {1, vic3::State({.provinces = {1, 2, 3}})},
1✔
511
               {2, vic3::State({.provinces = {4, 5, 6}})},
1✔
512
           },
513
       .province_definitions = province_definitions,
514
   });
3✔
515
   const mappers::WorldMapper world_mapper = mappers::WorldMapperBuilder::CreateNullMapper()
×
516
                                                 .AddProvinces({
20✔
517
                                                     {"x000001", {10}},
×
518
                                                     {"x000002", {20}},
×
519
                                                     {"x000003", {30}},
×
520
                                                     {"x000004", {40}},
×
521
                                                     {"x000005", {50}},
×
522
                                                     {"x000006", {60}},
×
523
                                                 })
524
                                                 .Build();
1✔
525

526
   const World world = ConvertWorld(commonItems::ModFilesystem("test_files/hoi4_world/StrategicRegionsAreCreated", {}),
2✔
527
       source_world,
528
       world_mapper,
529
       std::async<>(std::launch::async, []() {
3✔
530
          return hoi4::WorldFrameworkBuilder::CreateDefaultWorldFramework(
2✔
531
              commonItems::ModFilesystem("test_files/hoi4_world/StrategicRegionsAreCreated", {}))
2✔
532
              .Build();
2✔
533
       }));
1✔
534

535
   const auto strategic_regions = world.GetStrategicRegions().GetStrategicRegions();
1✔
536
   ASSERT_TRUE(strategic_regions.contains(10));
1✔
537
   ASSERT_TRUE(strategic_regions.contains(50));
1✔
538

539
   const auto region_10 = strategic_regions.find(10)->second;
1✔
540
   EXPECT_EQ(region_10.GetFilename(), "strategic_region_10.txt");
1✔
541
   EXPECT_EQ(region_10.GetID(), 10);
1✔
542
   EXPECT_EQ(region_10.GetName(), "STRATEGICREGION_10");
1✔
543
   EXPECT_THAT(region_10.GetOldProvinces(), testing::UnorderedElementsAre(10, 20, 30, 40));
1✔
544
   EXPECT_THAT(region_10.GetNewProvinces(), testing::UnorderedElementsAre(10, 20, 30));
1✔
545
   EXPECT_TRUE(region_10.HasStaticModifiers());
1✔
546
   EXPECT_THAT(region_10.GetStaticModifiers(),
1✔
547
       testing::UnorderedElementsAre(testing::Pair("test_modifier", "always"),
548
           testing::Pair("test_modifier_two", "always")));
1✔
549
   ASSERT_TRUE(region_10.GetNavalTerrain().has_value());
1✔
550
   EXPECT_EQ(region_10.GetNavalTerrain().value(), "test_naval_terrain");
1✔
551
   EXPECT_EQ(region_10.GetWeather(),
1✔
552
       "= {\n"
553
       "\t\tperiod={\n"
554
       "\t\t\tbetween={ 0.0 30.0 }\n"
555
       "\t\t\ttemperature={ -6.0 12.0 }\n"
556
       "\t\t\tno_phenomenon=0.500\n"
557
       "\t\t\train_light=1.000\n"
558
       "\t\t\train_heavy=0.150\n"
559
       "\t\t\tsnow=0.200\n"
560
       "\t\t\tblizzard=0.000\n"
561
       "\t\t\tarctic_water=0.000\n"
562
       "\t\t\tmud=0.300\n"
563
       "\t\t\tsandstorm=0.000\n"
564
       "\t\t\tmin_snow_level=0.000\n"
565
       "\t\t}\n"
566
       "\t\tperiod={\n"
567
       "\t\t\tbetween={ 0.1 27.1 }\n"
568
       "\t\t\ttemperature={ -7.0 12.0 }\n"
569
       "\t\t\tno_phenomenon=0.500\n"
570
       "\t\t\train_light=1.000\n"
571
       "\t\t\train_heavy=0.150\n"
572
       "\t\t\tsnow=0.200\n"
573
       "\t\t\tblizzard=0.050\n"
574
       "\t\t\tarctic_water=0.000\n"
575
       "\t\t\tmud=0.300\n"
576
       "\t\t\tsandstorm=0.000\n"
577
       "\t\t\tmin_snow_level=0.000\n"
578
       "\t\t}\n"
579
       "\t}");
1✔
580

581
   const auto region_50 = strategic_regions.find(50)->second;
1✔
582
   EXPECT_EQ(region_50.GetFilename(), "strategic_region_50.txt");
1✔
583
   EXPECT_EQ(region_50.GetID(), 50);
1✔
584
   EXPECT_EQ(region_50.GetName(), "STRATEGICREGION_50");
1✔
585
   EXPECT_THAT(region_50.GetOldProvinces(), testing::UnorderedElementsAre(50, 60));
1✔
586
   EXPECT_THAT(region_50.GetNewProvinces(), testing::UnorderedElementsAre(40, 50, 60));
1✔
587
   EXPECT_FALSE(region_50.HasStaticModifiers());
1✔
588
   EXPECT_TRUE(region_50.GetStaticModifiers().empty());
1✔
589
   ASSERT_FALSE(region_50.GetNavalTerrain().has_value());
1✔
590
   EXPECT_TRUE(region_50.GetWeather().empty());
1✔
591

592
   EXPECT_THAT(world.GetStrategicRegions().GetProvinceToStrategicRegionMap(),
1✔
593
       testing::UnorderedElementsAre(testing::Pair(10, 10),
594
           testing::Pair(20, 10),
595
           testing::Pair(30, 10),
596
           testing::Pair(40, 50),
597
           testing::Pair(50, 50),
598
           testing::Pair(60, 50)));
1✔
599
   EXPECT_THAT(world.GetStrategicRegions().GetStrategicRegions().at(10).GetNewProvinces(),
1✔
600
       testing::UnorderedElementsAre(10, 20, 30));
1✔
601
   EXPECT_THAT(world.GetStrategicRegions().GetStrategicRegions().at(50).GetNewProvinces(),
1✔
602
       testing::UnorderedElementsAre(40, 50, 60));
1✔
603
}
21✔
604

605

606
TEST(Hoi4worldWorldHoi4worldconverter, BuildingsAreCreated)
4✔
607
{
608
   const auto province_definitions = vic3::ProvinceDefinitions({
609
       "x000001",
610
       "x000002",
611
       "x000003",
612
       "x000004",
613
       "x000005",
614
       "x000006",
615
       "x000007",
616
       "x000008",
617
   });
9✔
618

619
   const vic3::World source_world({
620
       .states =
621
           {
622
               {1, vic3::State({.provinces = {1, 2, 3, 4, 5}})},
1✔
623
               {2, vic3::State({.provinces = {6, 7}})},
1✔
624
               {3, vic3::State({.provinces = {8}})},
1✔
625
           },
626
       .province_definitions = province_definitions,
627
   });
4✔
628

629
   const mappers::WorldMapper world_mapper = mappers::WorldMapperBuilder::CreateNullMapper()
×
630
                                                 .AddProvinces({
26✔
631
                                                     {{"x000001"}, 1},
×
632
                                                     {{"x000002"}, 2},
×
633
                                                     {{"x000003"}, 3},
×
634
                                                     {{"x000004"}, 4},
×
635
                                                     {{"x000005"}, 5},
×
636
                                                     {{"x000006"}, 6},
×
637
                                                     {{"x000007"}, 7},
×
638
                                                     {{"x000008"}, 8},
×
639
                                                 })
640
                                                 .Build();
1✔
641

642
   const World world = ConvertWorld(commonItems::ModFilesystem("test_files/hoi4_world/BuildingsAreCreated", {}),
2✔
643
       source_world,
644
       world_mapper,
645
       std::async<>(std::launch::async, []() {
3✔
646
          return hoi4::WorldFrameworkBuilder::CreateDefaultWorldFramework(
2✔
647
              commonItems::ModFilesystem("test_files/hoi4_world/BuildingsAreCreated", {}))
2✔
648
              .Build();
2✔
649
       }));
1✔
650

651
   EXPECT_FALSE(world.GetBuildings().GetBuildings().empty());
1✔
652
}
27✔
653

654

655
TEST(Hoi4worldWorldHoi4worldconverter, RailwaysAreCreated)
4✔
656
{
657
   const vic3::StateRegion vic3_state_region({{"x000001", "city"}, {"x000002", "port"}, {"x000003", "mine"}}, {});
5✔
658

659
   const auto province_definitions = vic3::ProvinceDefinitions({
660
       "x000001",
661
       "x000002",
662
       "x000003",
663
       "x000004",
664
       "x000005",
665
       "x000006",
666
       "x000007",
667
       "x000008",
668
       "x000009",
669
       "x000010",
670
       "x000011",
671
       "x000012",
672
   });
13✔
673

674
   const std::map<int, std::vector<vic3::Building>> buildings = {
675
       {1, {vic3::Building(vic3::kBuildingTypeNavalBase, 1, 0.0F, 5.0F, {})}},
×
676
   };
3✔
677

678
   const vic3::World source_world({.states =
679
                                       {
680
                                           {1,
×
681
                                               vic3::State({
1✔
682
                                                   .id = 1,
683
                                                   .owner_number = 1,
684
                                                   .owner_tag = "TAG",
685
                                                   .provinces = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12},
686
                                               })},
687
                                       },
688
       .state_regions =
689
           {
690
               {"state", vic3_state_region},
691
           },
692
       .province_definitions = province_definitions,
693
       .buildings = vic3::Buildings(buildings)});
3✔
694

695
   const mappers::WorldMapper world_mapper = mappers::WorldMapperBuilder::CreateNullMapper()
×
696
                                                 .AddProvinces({
38✔
697
                                                     {"x000001", {1}},
×
698
                                                     {"x000002", {2}},
×
699
                                                     {"x000003", {3}},
×
700
                                                     {"x000004", {4}},
×
701
                                                     {"x000005", {5}},
×
702
                                                     {"x000006", {6}},
×
703
                                                     {"x000007", {7}},
×
704
                                                     {"x000008", {8}},
×
705
                                                     {"x000009", {9}},
×
706
                                                     {"x000010", {10}},
×
707
                                                     {"x000011", {11}},
×
708
                                                     {"x000012", {12}},
×
709
                                                 })
710
                                                 .Build();
1✔
711

712
   const World world = ConvertWorld(commonItems::ModFilesystem("test_files/hoi4_world/RailwaysAreCreated", {}),
2✔
713
       source_world,
714
       world_mapper,
715
       std::async<>(std::launch::async, []() {
3✔
716
          return hoi4::WorldFrameworkBuilder::CreateDefaultWorldFramework(
2✔
717
              commonItems::ModFilesystem("test_files/hoi4_world/RailwaysAreCreated", {}))
2✔
718
              .Build();
2✔
719
       }));
1✔
720

721
   EXPECT_FALSE(world.GetRailways().railways.empty());
1✔
722
}
35✔
723

724

725
TEST(Hoi4worldWorldHoi4worldconverter, GreatPowersAreConverted)
4✔
726
{
727
   const vic3::World source_world({
728
       .countries =
729
           {
730
               {1, vic3::Country({})},
1✔
731
               {3, vic3::Country({})},
1✔
732
               {5, vic3::Country({})},
1✔
733
           },
734
       .country_rankings = {{1, 3, 5}, {}, {}},
735
   });
4✔
736
   const mappers::WorldMapper world_mapper = mappers::WorldMapperBuilder::CreateNullMapper()
×
737
                                                 .AddCountries({
5✔
738
                                                     {1, "ONE"},
×
739
                                                     {3, "THR"},
×
740
                                                     {5, "FIV"},
1✔
741
                                                 })
742
                                                 .Build();
1✔
743

744
   const World world = ConvertWorld(commonItems::ModFilesystem("test_files/hoi4_world/RailwaysAreCreated", {}),
2✔
745
       source_world,
746
       world_mapper,
747
       std::async<>(std::launch::async, []() {
3✔
748
          return hoi4::WorldFrameworkBuilder::CreateNullWorldFramework().Build();
2✔
749
       }));
1✔
750

751
   EXPECT_THAT(world.GetGreatPowers(), testing::UnorderedElementsAre("ONE", "THR", "FIV"));
1✔
752
}
7✔
753

754

755
TEST(Hoi4worldWorldHoi4worldconverter, MajorPowersAreConverted)
4✔
756
{
757
   const vic3::World source_world({
758
       .countries =
759
           {
760
               {1, vic3::Country({})},
1✔
761
               {3, vic3::Country({})},
1✔
762
               {5, vic3::Country({})},
1✔
763
           },
764
       .country_rankings = {{}, {1, 3, 5}, {}},
765
   });
4✔
766

767
   const mappers::WorldMapper world_mapper = mappers::WorldMapperBuilder::CreateNullMapper()
×
768
                                                 .AddCountries({
5✔
769
                                                     {1, "ONE"},
×
770
                                                     {3, "THR"},
×
771
                                                     {5, "FIV"},
1✔
772
                                                 })
773
                                                 .Build();
1✔
774

775
   const World world = ConvertWorld(commonItems::ModFilesystem("test_files/hoi4_world/RailwaysAreCreated", {}),
2✔
776
       source_world,
777
       world_mapper,
778
       std::async<>(std::launch::async, []() {
3✔
779
          return hoi4::WorldFrameworkBuilder::CreateDefaultWorldFramework(
2✔
780
              commonItems::ModFilesystem("test_files/hoi4_world/RailwaysAreCreated", {}))
2✔
781
              .Build();
2✔
782
       }));
1✔
783

784
   EXPECT_THAT(world.GetMajorPowers(), testing::UnorderedElementsAre("ONE", "THR", "FIV"));
1✔
785
}
7✔
786

787

788
TEST(Hoi4worldWorldHoi4worldconverter, LocalizationsAreConverted)
4✔
789
{
790
   const vic3::Country source_country_one({
791
       .number = 1,
792
       .tag = "TAG",
793
       .color = commonItems::Color{std::array{1, 2, 3}},
794
   });
2✔
795
   const vic3::Country source_country_two({
796
       .number = 3,
797
       .tag = "THR",
798
       .color = commonItems::Color{std::array{2, 4, 6}},
799
   });
1✔
800
   const std::map<int, vic3::Country> source_countries = {{1, source_country_one}, {3, source_country_two}};
3✔
801

802
   const std::map<int, vic3::State> source_states = {
803
       {1, vic3::State({.owner_number = 1, .owner_tag = "TAG", .provinces = {1, 2, 3}})},
1✔
804
       {2, vic3::State({.owner_number = 2, .owner_tag = "TAG", .provinces = {4, 5, 6}})},
1✔
805
   };
3✔
806

807
   const std::map<std::string, vic3::StateRegion> source_state_regions = {
808
       {"REGION_ONE", vic3::StateRegion({{"x000001", "city"}}, {"x000001", "x000002", "x000003"})},
7✔
809
       {"REGION_TWO", vic3::StateRegion({{"x000004", "mine"}}, {"x000004", "x000005", "x000006"})},
7✔
810
   };
3✔
811

812
   commonItems::LocalizationDatabase vic3_localizations("english", {"spanish"});
2✔
813
   commonItems::LocalizationBlock country_block_one("TAG", "english");
1✔
814
   country_block_one.ModifyLocalization("english", "test");
1✔
815
   country_block_one.ModifyLocalization("spanish", "prueba");
1✔
816
   vic3_localizations.AddOrModifyLocalizationBlock("TAG", country_block_one);
1✔
817
   commonItems::LocalizationBlock country_adj_block_one("TAG_ADJ", "english");
1✔
818
   country_adj_block_one.ModifyLocalization("english", "testy");
1✔
819
   country_adj_block_one.ModifyLocalization("spanish", "pruebamente");
1✔
820
   vic3_localizations.AddOrModifyLocalizationBlock("TAG_ADJ", country_adj_block_one);
1✔
821
   commonItems::LocalizationBlock country_block_two("THR", "english");
1✔
822
   country_block_two.ModifyLocalization("english", "test three");
1✔
823
   country_block_two.ModifyLocalization("spanish", "prueba tres");
1✔
824
   vic3_localizations.AddOrModifyLocalizationBlock("THR", country_block_two);
1✔
825
   commonItems::LocalizationBlock country_adj_block_two("THR_ADJ", "english");
1✔
826
   country_adj_block_two.ModifyLocalization("english", "testy three");
1✔
827
   country_adj_block_two.ModifyLocalization("spanish", "pruebamente tres");
1✔
828
   vic3_localizations.AddOrModifyLocalizationBlock("THR_ADJ", country_adj_block_two);
1✔
829
   commonItems::LocalizationBlock state_block_one("REGION_ONE", "english");
1✔
830
   state_block_one.ModifyLocalization("english", "test");
1✔
831
   state_block_one.ModifyLocalization("spanish", "prueba");
1✔
832
   vic3_localizations.AddOrModifyLocalizationBlock("REGION_ONE", state_block_one);
1✔
833
   commonItems::LocalizationBlock state_block_two("REGION_TWO", "english");
1✔
834
   state_block_two.ModifyLocalization("english", "test two");
1✔
835
   state_block_two.ModifyLocalization("spanish", "prueba dos");
1✔
836
   vic3_localizations.AddOrModifyLocalizationBlock("REGION_TWO", state_block_two);
1✔
837
   commonItems::LocalizationBlock victory_point_block_one("HUB_NAME_REGION_ONE_city", "english");
1✔
838
   victory_point_block_one.ModifyLocalization("english", "test");
1✔
839
   victory_point_block_one.ModifyLocalization("spanish", "prueba");
1✔
840
   vic3_localizations.AddOrModifyLocalizationBlock("HUB_NAME_REGION_ONE_city", victory_point_block_one);
1✔
841
   commonItems::LocalizationBlock victory_point_block_two("HUB_NAME_REGION_TWO_mine", "english");
1✔
842
   victory_point_block_two.ModifyLocalization("english", "test two");
1✔
843
   victory_point_block_two.ModifyLocalization("spanish", "prueba dos");
1✔
844
   vic3_localizations.AddOrModifyLocalizationBlock("HUB_NAME_REGION_TWO_mine", victory_point_block_two);
1✔
845

846
   vic3::ProvinceDefinitions province_definitions({"x000001", "x000002", "x000003", "x000004", "x000005", "x000006"});
7✔
847

848
   const vic3::World source_world({
849
       .countries = source_countries,
850
       .states = source_states,
851
       .state_regions = source_state_regions,
852
       .province_definitions = province_definitions,
853
       .localizations = vic3_localizations,
854
   });
1✔
855

856
   const mappers::WorldMapper world_mapper = mappers::WorldMapperBuilder::CreateNullMapper()
1✔
857
                                                 .AddCountries({{1, "TAG"}, {3, "THR"}})
4✔
858
                                                 .AddProvinces({
20✔
859
                                                     {"x000001", {10}},
×
860
                                                     {"x000002", {20}},
×
861
                                                     {"x000003", {30}},
×
862
                                                     {"x000004", {40}},
×
863
                                                     {"x000005", {50}},
×
864
                                                     {"x000006", {60}},
×
865
                                                 })
866
                                                 .DefaultCultureGraphicsMapper()
1✔
867
                                                 .Build();
1✔
868

869
   const World world = ConvertWorld(commonItems::ModFilesystem("test_files/hoi4_world", {}),
2✔
870
       source_world,
871
       world_mapper,
872
       std::async<>(std::launch::async, []() {
3✔
873
          return hoi4::WorldFrameworkBuilder::CreateDefaultWorldFramework(
2✔
874
              commonItems::ModFilesystem("test_files/hoi4_world", {}))
2✔
875
              .Build();
2✔
876
       }));
1✔
877

878
   const std::optional<commonItems::LocalizationBlock> hoi_country_localization_block =
879
       world.GetLocalizations().GetCountryLocalizations().GetLocalizationBlock("TAG");
1✔
880
   EXPECT_THAT(hoi_country_localization_block.value_or(commonItems::LocalizationBlock("", "")).GetLocalizations(),
1✔
881
       testing::UnorderedElementsAre(testing::Pair("english", "test"), testing::Pair("spanish", "prueba")));
1✔
882

883
   const std::optional<commonItems::LocalizationBlock> hoi_country_localization_block_two =
884
       world.GetLocalizations().GetCountryLocalizations().GetLocalizationBlock("THR");
2✔
885
   EXPECT_THAT(hoi_country_localization_block_two.value_or(commonItems::LocalizationBlock("", "")).GetLocalizations(),
1✔
886
       testing::UnorderedElementsAre(testing::Pair("english", "test three"), testing::Pair("spanish", "prueba tres")));
1✔
887

888
   const std::optional<commonItems::LocalizationBlock> hoi_state_localization_block =
889
       world.GetLocalizations().GetStateLocalizations().GetLocalizationBlock("STATE_1");
2✔
890
   EXPECT_THAT(hoi_state_localization_block.value_or(commonItems::LocalizationBlock("", "")).GetLocalizations(),
1✔
891
       testing::UnorderedElementsAre(testing::Pair("english", "test"), testing::Pair("spanish", "prueba")));
1✔
892

893
   const std::optional<commonItems::LocalizationBlock> hoi_state_localization_block_two =
894
       world.GetLocalizations().GetStateLocalizations().GetLocalizationBlock("STATE_2");
2✔
895
   EXPECT_THAT(hoi_state_localization_block_two.value_or(commonItems::LocalizationBlock("", "")).GetLocalizations(),
1✔
896
       testing::UnorderedElementsAre(testing::Pair("english", "test two"), testing::Pair("spanish", "prueba dos")));
1✔
897

898
   const std::optional<commonItems::LocalizationBlock> hoi_victory_point_localization_block =
899
       world.GetLocalizations().GetVictoryPointLocalizations().GetLocalizationBlock("VICTORY_POINTS_10");
2✔
900
   EXPECT_THAT(hoi_victory_point_localization_block.value_or(commonItems::LocalizationBlock("", "")).GetLocalizations(),
1✔
901
       testing::UnorderedElementsAre(testing::Pair("english", "test"), testing::Pair("spanish", "prueba")));
1✔
902

903
   const std::optional<commonItems::LocalizationBlock> hoi_victory_point_localization_block_two =
904
       world.GetLocalizations().GetVictoryPointLocalizations().GetLocalizationBlock("VICTORY_POINTS_40");
2✔
905
   EXPECT_THAT(
1✔
906
       hoi_victory_point_localization_block_two.value_or(commonItems::LocalizationBlock("", "")).GetLocalizations(),
907
       testing::UnorderedElementsAre(testing::Pair("english", "test two"), testing::Pair("spanish", "prueba dos")));
1✔
908
}
31✔
909

910

911
TEST(Hoi4worldWorldHoi4worldconverter, CharactersAreConverted)
4✔
912
{
913
   const vic3::Country source_country_one({
914
       .number = 1,
915
       .tag = "TAG",
916
       .color = commonItems::Color{std::array{1, 2, 3}},
917
       .head_of_state_id = 1,
918
       .character_ids = {1, 4, 5, 6},
919
   });
2✔
920
   const vic3::Country source_country_two({
921
       .number = 3,
922
       .tag = "TWO",
923
       .color = commonItems::Color{std::array{2, 4, 6}},
924
       .head_of_state_id = 3,
925
       .character_ids = {2, 3},
926
   });
1✔
927

928
   // Compiler was being weird about it directly in map
929
   vic3::Character character_one({.id = 1, .culture = "culture_2"});
1✔
930
   vic3::Character character_two({.id = 2, .culture = "culture_2", .roles = {"agitator"}, .origin_country_id = 1});
2✔
931
   vic3::Character character_three({.id = 3, .culture = "culture_2"});
1✔
932
   vic3::Character character_four({.id = 4, .culture = "culture_1", .roles = {"general"}});
2✔
933
   vic3::Character character_five({.id = 5, .culture = "culture_2", .roles = {"admiral"}});
2✔
934
   vic3::Character character_six({.id = 6, .culture = "culture_2", .roles = {"politician"}});
2✔
935
   const vic3::World source_world({
936
       .countries = {{1, source_country_one}, {3, source_country_two}},
×
937
       .states = {},
938
       .acquired_technologies =
939
           {
940
               {1, {"source_tech"}},
×
941
               {3, {"source_tech_two", "source_tech_three"}},
×
942
           },
943
       .culture_definitions =
944
           {
945
               {"culture_1", vic3::CultureDefinition{"culture_1", {}, {}, {}}},
3✔
946
               {"culture_2", vic3::CultureDefinition{"culture_2", {}, {}, {}}},
3✔
947
           },
948
       .characters =
949
           {
950
               {1, character_one},
×
951
               {2, character_two},
×
952
               {3, character_three},
×
953
               {4, character_four},
×
954
               {5, character_five},
×
955
               {6, character_six},
×
956
           },
957
   });
16✔
958
   const mappers::WorldMapper world_mapper = mappers::WorldMapperBuilder::CreateNullMapper()
×
959
                                                 .AddCountries({{1, "TAG"}, {3, "TWO"}})
4✔
960
                                                 .DefaultCultureGraphicsMapper()
1✔
961
                                                 .Build();
1✔
962

963
   const World world = ConvertWorld(commonItems::ModFilesystem("test_files/hoi4_world", {}),
2✔
964
       source_world,
965
       world_mapper,
966
       std::async<>(std::launch::async, []() {
3✔
967
          return hoi4::WorldFrameworkBuilder::CreateNullWorldFramework().Build();
2✔
968
       }));
1✔
969

970
   const auto expected_data_leader = std::optional<Leader>({.sub_ideology = "despotism"});
2✔
971
   const auto expected_data_spy = std::optional<Spy>({.nationalities = {"TAG", "TWO"}});
3✔
972
   const auto expected_data_general = std::optional<General>({.traits = {}});
1✔
973
   const auto expected_data_admiral = std::optional<Admiral>({.traits = {}});
1✔
974
   const auto expected_data_advisor = std::optional<Advisor>({.slot = "political_advisor"});
1✔
975

976

977
   EXPECT_THAT(world.GetCharacters(),
12✔
978
       testing::UnorderedElementsAre(testing::Pair(1,
979
                                         Character({
980
                                             .id = 1,
981
                                             .portrait_alias = "GFX_leader_2",
982
                                             .leader_data = expected_data_leader,
983
                                         })),
984
           testing::Pair(2,
985
               Character({
986
                   .id = 2,
987
                   .portrait_alias = "GFX_m_op_1",
988
                   .spy_data = expected_data_spy,
989
               })),
990
           testing::Pair(3,
991
               Character({
992
                   .id = 3,
993
                   .portrait_alias = "GFX_leader_1",
994
                   .leader_data = expected_data_leader,
995
               })),
996
           testing::Pair(4,
997
               Character({
998
                   .id = 4,
999
                   .portrait_alias = "GFX_general_1",
1000
                   .general_data = expected_data_general,
1001
               })),
1002
           testing::Pair(5,
1003
               Character({
1004
                   .id = 5,
1005
                   .portrait_alias = "GFX_admiral_1",
1006
                   .admiral_data = expected_data_admiral,
1007
               })),
1008
           testing::Pair(6,
1009
               Character({
1010
                   .id = 6,
1011
                   .portrait_alias = "GFX_minister_1",
1012
                   .advisor_data = expected_data_advisor,
1013
               }))));
1✔
1014
}
54✔
1015

1016

1017
TEST(Hoi4worldWorldHoi4worldconverter, WarsAreConverted)
4✔
1018
{
1019
   const vic3::Country source_country_one({
1020
       .number = 1,
1021
       .tag = "TAG",
1022
       .color = commonItems::Color{std::array{1, 2, 3}},
1023
       .head_of_state_id = 1,
1024
       .character_ids = {1, 4, 5, 6},
1025
   });
2✔
1026
   const vic3::Country source_country_two({
1027
       .number = 3,
1028
       .tag = "TWO",
1029
       .color = commonItems::Color{std::array{2, 4, 6}},
1030
       .head_of_state_id = 3,
1031
       .character_ids = {2, 3},
1032
   });
1✔
1033

1034
   const vic3::World source_world({
1035
       .countries = {{1, source_country_one}, {3, source_country_two}},
×
1036
       .states = {},
1037
       .wars = {vic3::War({.original_attacker = 1, .original_defender = 3})},
1038
   });
4✔
1039
   const mappers::WorldMapper world_mapper = mappers::WorldMapperBuilder::CreateNullMapper()
×
1040
                                                 .AddCountries({{1, "TAG"}, {3, "TWO"}})
4✔
1041
                                                 .DefaultCultureGraphicsMapper()
1✔
1042
                                                 .Build();
1✔
1043

1044
   const World world = ConvertWorld(commonItems::ModFilesystem("test_files/hoi4_world", {}),
2✔
1045
       source_world,
1046
       world_mapper,
1047
       std::async<>(std::launch::async, []() {
3✔
1048
          return hoi4::WorldFrameworkBuilder::CreateNullWorldFramework().Build();
2✔
1049
       }));
1✔
1050

1051
   EXPECT_THAT(world.GetCountries().find("TAG")->second.GetWars(),
3✔
1052
       testing::ElementsAre(War({.original_defender = "TWO", .original_attacker = "TAG"})));
1✔
1053
}
10✔
1054

1055
}  // namespace hoi4
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc