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

ParadoxGameConverters / Vic3ToHoI4 / 16089794323

22 Jun 2025 09:47PM UTC coverage: 94.151%. Remained the same
16089794323

push

github

web-flow
Update commons and simplify (#730)

* Update to draft commons.

* Build fixes.

* Strip redundant conversions to path

* Correct tests for on linux

* Try another folder that's blocked.

* Use draft fronter

* Update to merged

315 of 316 new or added lines in 40 files covered. (99.68%)

200 existing lines in 6 files now uncovered.

21826 of 23182 relevant lines covered (94.15%)

57153.31 hits per line

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

88.3
/src/hoi4_world/map/buildings_creator_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

4
#include "src/hoi4_world/map/buildings_creator.h"
5

6

7

8
namespace hoi4
9
{
10

11
TEST(Hoi4worldMapBuildingsCreatorTests, ExceptionForMissingBuildingsDotTxt)
4✔
12
{
13
   EXPECT_THROW(ImportBuildings(States(),
7✔
14
                    CoastalProvinces(),
15
                    maps::MapData(),
16
                    commonItems::ModFilesystem{"ExceptionForMissingBuildingsDotTxt", {}}),
17
       std::runtime_error);
1✔
18
}
1✔
19

20

21
TEST(Hoi4worldMapBuildingsCreatorTests, DefaultsToNoBuildings)
4✔
22
{
23
   const Buildings buildings = ImportBuildings(States(),
2✔
24
       CoastalProvinces(),
2✔
25
       maps::MapData(),
2✔
26
       commonItems::ModFilesystem{"test_files/Hoi4worldMapBuildingsCreatorTests/DefaultsToNoBuildings", {}});
3✔
27

28
   EXPECT_TRUE(buildings.GetBuildings().empty());
1✔
29
}
1✔
30

31

32
TEST(Hoi4worldMapBuildingsCreatorTests, AirportPlacedInCenterOfFirstProvinceOfState)
4✔
33
{
34
   const Buildings
35
       buildings =
36
           ImportBuildings(States({.states = {State(1, {.provinces = {1, 2, 3, 4, 5}})},
1✔
37
                               .province_to_state_id_map =
38
                                   {
39
                                       {1, 1},
40
                                       {2, 1},
41
                                       {3, 1},
42
                                       {4, 1},
43
                                       {5, 1},
44
                                   }}),
1✔
45
               CoastalProvinces(),
1✔
46
               maps::MapData(
1✔
47
                   {.the_province_points =
48
                           {
49
                               {"1",
50
                                   maps::ProvincePoints(
2✔
51
                                       {{1, 1}, {1, 2}, {1, 3}, {2, 1}, {2, 2}, {2, 3}, {3, 1}, {3, 2}, {3, 3}})},
52
                               {"2",
53
                                   maps::ProvincePoints(
2✔
54
                                       {{4, 1}, {4, 2}, {4, 3}, {5, 1}, {5, 2}, {5, 3}, {6, 1}, {6, 2}, {6, 3}})},
55
                           },
56
                       .points_to_provinces =
57
                           {
58
                               {maps::Point{1, 1}, "1"},
×
59
                               {maps::Point{1, 2}, "1"},
×
60
                               {maps::Point{1, 3}, "1"},
×
61
                               {maps::Point{2, 1}, "1"},
×
62
                               {maps::Point{2, 2}, "1"},
×
63
                               {maps::Point{2, 3}, "1"},
×
64
                               {maps::Point{3, 1}, "1"},
×
65
                               {maps::Point{3, 2}, "1"},
×
66
                               {maps::Point{3, 3}, "1"},
×
67
                               {maps::Point{4, 1}, "2"},
×
68
                               {maps::Point{4, 2}, "2"},
×
69
                               {maps::Point{4, 3}, "2"},
×
70
                               {maps::Point{5, 1}, "2"},
×
71
                               {maps::Point{5, 2}, "2"},
×
UNCOV
72
                               {maps::Point{5, 3}, "2"},
×
UNCOV
73
                               {maps::Point{6, 1}, "2"},
×
UNCOV
74
                               {maps::Point{6, 2}, "2"},
×
UNCOV
75
                               {maps::Point{6, 3}, "2"},
×
76
                           }}),
20✔
77
               commonItems::ModFilesystem{"test_files/Hoi4worldMapBuildingsCreatorTests/DefaultsToNoBuildings", {}});
2✔
78

79
   EXPECT_THAT(buildings.GetBuildings(),
3✔
80
       testing::IsSupersetOf({Building({.state_id = 1,
81
           .type = "air_base",
82
           .position = {.x_coordinate = 2.0, .y_coordinate = 11.0, .z_coordinate = 2.0, .rotation = 0.0}})}));
1✔
83
}
31✔
84

85

86
TEST(Hoi4worldMapBuildingsCreatorTests, NoAirportInStateWithNoProvinces)
4✔
87
{
88
   // clang-format off
89
   const Buildings
90
       buildings =
91
           ImportBuildings(States({
1✔
92
                               .states = {State(1, {})},
93
                               .province_to_state_id_map =
94
                                   {
95
                                       {1, 1},
96
                                       {2, 1},
97
                                       {3, 1},
98
                                       {4, 1},
99
                                       {5, 1},
100
                                   },
101
                           }),
1✔
102
               CoastalProvinces(),
1✔
103
               maps::MapData(
1✔
104
                   {
105
                       .the_province_points =
106
                           {
107
                               {"1",
108
                                   maps::ProvincePoints({
2✔
109
                                       {1, 1},
110
                                       {1, 2},
111
                                       {1, 3},
112
                                       {2, 1},
113
                                       {2, 2},
114
                                       {2, 3},
115
                                       {3, 1},
116
                                       {3, 2},
117
                                       {3, 3},
118
                                   })},
119
                               {"2",
120
                                   maps::ProvincePoints({
2✔
121
                                       {4, 1},
122
                                       {4, 2},
123
                                       {4, 3},
124
                                       {5, 1},
125
                                       {5, 2},
126
                                       {5, 3},
127
                                       {6, 1},
128
                                       {6, 2},
129
                                       {6, 3},
130
                                   })},
131
                           },
132
                       .points_to_provinces =
133
                           {
UNCOV
134
                               {maps::Point{2, 2}, "1"},
×
135
                           },
136
                   }),
3✔
137
               commonItems::ModFilesystem{"test_files/Hoi4worldMapBuildingsCreatorTests/DefaultsToNoBuildings", {}});
2✔
138
   // clang-format on
139

140
   EXPECT_TRUE(buildings.GetBuildings().empty());
1✔
141
}
12✔
142

143

144
TEST(Hoi4worldMapBuildingsCreatorTests, AirportNotPlacedInProvinceWithNoPoints)
4✔
145
{
146
   std::stringstream log;
1✔
147
   std::streambuf* cout_buffer = std::cout.rdbuf();
1✔
148
   std::cout.rdbuf(log.rdbuf());
1✔
149

150
   const Buildings buildings = ImportBuildings(States({.states = {State(1, {.provinces = {1, 2, 3, 4, 5}})},
1✔
151
                                                   .province_to_state_id_map =
152
                                                       {
153
                                                           {1, 1},
154
                                                           {2, 1},
155
                                                           {3, 1},
156
                                                           {4, 1},
157
                                                           {5, 1},
158
                                                       }}),
1✔
159
       CoastalProvinces(),
1✔
160
       maps::MapData(),
2✔
161
       commonItems::ModFilesystem{"test_files/Hoi4worldMapBuildingsCreatorTests/DefaultsToNoBuildings", {}});
2✔
162

163
   std::cout.rdbuf(cout_buffer);
1✔
164

165
   EXPECT_TRUE(buildings.GetBuildings().empty());
1✔
166
   EXPECT_THAT(log.str(),
1✔
167
       testing::HasSubstr("[WARNING] Province 1 did not have any points. air_base not fully set in state 1."));
1✔
168
}
4✔
169

170

171
TEST(Hoi4worldMapBuildingsCreatorTests, AirportPlacementOverridenByDefaultLocation)
4✔
172
{
173
   const Buildings
174
       buildings =
175
           ImportBuildings(States({.states = {State(1, {.provinces = {1, 2, 3, 4, 5}})},
1✔
176
                               .province_to_state_id_map =
177
                                   {
178
                                       {1, 1},
179
                                       {2, 1},
180
                                       {3, 1},
181
                                       {4, 1},
182
                                       {5, 1},
183
                                   }}),
1✔
184
               CoastalProvinces(),
1✔
185
               maps::MapData(
1✔
186
                   {.the_province_points =
187
                           {
188
                               {"1",
189
                                   maps::ProvincePoints(
2✔
190
                                       {{1, 1}, {1, 2}, {1, 3}, {2, 1}, {2, 2}, {2, 3}, {3, 1}, {3, 2}, {3, 3}})},
191
                               {"2",
192
                                   maps::ProvincePoints(
2✔
193
                                       {{4, 1}, {4, 2}, {4, 3}, {5, 1}, {5, 2}, {5, 3}, {6, 1}, {6, 2}, {6, 3}})},
194
                           },
195
                       .points_to_provinces =
196
                           {
197
                               {maps::Point{1, 1}, "1"},
×
198
                               {maps::Point{1, 2}, "1"},
×
199
                               {maps::Point{1, 3}, "1"},
×
200
                               {maps::Point{2, 1}, "1"},
×
201
                               {maps::Point{2, 2}, "1"},
×
202
                               {maps::Point{2, 3}, "1"},
×
203
                               {maps::Point{3, 1}, "1"},
×
204
                               {maps::Point{3, 2}, "1"},
×
205
                               {maps::Point{3, 3}, "1"},
×
206
                               {maps::Point{4, 1}, "2"},
×
207
                               {maps::Point{4, 2}, "2"},
×
208
                               {maps::Point{4, 3}, "2"},
×
209
                               {maps::Point{5, 1}, "2"},
×
UNCOV
210
                               {maps::Point{5, 2}, "2"},
×
UNCOV
211
                               {maps::Point{5, 3}, "2"},
×
UNCOV
212
                               {maps::Point{6, 1}, "2"},
×
UNCOV
213
                               {maps::Point{6, 2}, "2"},
×
UNCOV
214
                               {maps::Point{6, 3}, "2"},
×
215
                           }}),
20✔
216
               commonItems::ModFilesystem{"test_files/Hoi4worldMapBuildingsCreatorTests/DefaultsExist", {}});
2✔
217

218
   EXPECT_THAT(buildings.GetBuildings(),
3✔
219
       testing::IsSupersetOf({Building({.state_id = 1,
220
           .type = "air_base",
221
           .position = {.x_coordinate = 4.0, .y_coordinate = 6.0, .z_coordinate = 1.0, .rotation = 90.0}})}));
1✔
222
}
31✔
223

224

225
TEST(Hoi4worldMapBuildingsCreatorTests, AirportPlacedInCenterOfFirstProvinceOfStateIfDefaultNotInState)
4✔
226
{
227
   const Buildings
228
       buildings =
229
           ImportBuildings(States({.states = {State(1, {.provinces = {1, 3, 4, 5}})},
1✔
230
                               .province_to_state_id_map =
231
                                   {
232
                                       {1, 1},
233
                                       {2, 1},
234
                                       {3, 1},
235
                                       {4, 1},
236
                                       {5, 1},
237
                                   }}),
1✔
238
               CoastalProvinces(),
1✔
239
               maps::MapData(
1✔
240
                   {.the_province_points =
241
                           {
242
                               {"1",
243
                                   maps::ProvincePoints(
2✔
244
                                       {{1, 1}, {1, 2}, {1, 3}, {2, 1}, {2, 2}, {2, 3}, {3, 1}, {3, 2}, {3, 3}})},
245
                               {"2",
246
                                   maps::ProvincePoints(
2✔
247
                                       {{4, 1}, {4, 2}, {4, 3}, {5, 1}, {5, 2}, {5, 3}, {6, 1}, {6, 2}, {6, 3}})},
248
                           },
249
                       .points_to_provinces =
250
                           {
251
                               {maps::Point{1, 1}, "1"},
×
252
                               {maps::Point{1, 2}, "1"},
×
253
                               {maps::Point{1, 3}, "1"},
×
254
                               {maps::Point{2, 1}, "1"},
×
255
                               {maps::Point{2, 2}, "1"},
×
256
                               {maps::Point{2, 3}, "1"},
×
257
                               {maps::Point{3, 1}, "1"},
×
258
                               {maps::Point{3, 2}, "1"},
×
259
                               {maps::Point{3, 3}, "1"},
×
260
                               {maps::Point{4, 1}, "2"},
×
261
                               {maps::Point{4, 2}, "2"},
×
262
                               {maps::Point{4, 3}, "2"},
×
263
                               {maps::Point{5, 1}, "2"},
×
UNCOV
264
                               {maps::Point{5, 2}, "2"},
×
UNCOV
265
                               {maps::Point{5, 3}, "2"},
×
UNCOV
266
                               {maps::Point{6, 1}, "2"},
×
UNCOV
267
                               {maps::Point{6, 2}, "2"},
×
UNCOV
268
                               {maps::Point{6, 3}, "2"},
×
269
                           }}),
20✔
270
               commonItems::ModFilesystem{"test_files/Hoi4worldMapBuildingsCreatorTests/DefaultsExist", {}});
2✔
271

272
   EXPECT_THAT(buildings.GetBuildings(),
3✔
273
       testing::IsSupersetOf({Building({.state_id = 1,
274
           .type = "air_base",
275
           .position = {.x_coordinate = 2.0, .y_coordinate = 11.0, .z_coordinate = 2.0, .rotation = 0.0}})}));
1✔
276
}
31✔
277

278

279
TEST(Hoi4worldMapBuildingsCreatorTests, AntiAirPlacedInCenterOfFirstThreeProvincesOfState)
4✔
280
{
281
   const Buildings buildings = ImportBuildings(States({.states = {State(1, {.provinces = {1, 2, 3, 4, 5}})},
1✔
282
                                                   .province_to_state_id_map =
283
                                                       {
284
                                                           {1, 1},
285
                                                           {2, 1},
286
                                                           {3, 1},
287
                                                           {4, 1},
288
                                                           {5, 1},
289
                                                       }}),
1✔
290
       CoastalProvinces(),
1✔
291
       maps::MapData(
1✔
292
           {.the_province_points =
293
                   {
294
                       {"1",
295
                           maps::ProvincePoints(
2✔
296
                               {{1, 1}, {1, 2}, {1, 3}, {2, 1}, {2, 2}, {2, 3}, {3, 1}, {3, 2}, {3, 3}})},
297
                       {"2",
298
                           maps::ProvincePoints(
2✔
299
                               {{4, 1}, {4, 2}, {4, 3}, {5, 1}, {5, 2}, {5, 3}, {6, 1}, {6, 2}, {6, 3}})},
300
                       {"3",
301
                           maps::ProvincePoints(
2✔
302
                               {{1, 4}, {1, 5}, {1, 6}, {2, 4}, {2, 5}, {2, 6}, {3, 4}, {3, 5}, {3, 6}})},
303
                       {"4",
304
                           maps::ProvincePoints(
2✔
305
                               {{4, 4}, {4, 5}, {4, 6}, {5, 4}, {5, 5}, {5, 6}, {6, 4}, {6, 5}, {6, 6}})},
306
                   }}),
4✔
307
       commonItems::ModFilesystem{"test_files/Hoi4worldMapBuildingsCreatorTests/DefaultsToNoBuildings", {}});
2✔
308

309
   EXPECT_THAT(buildings.GetBuildings(),
5✔
310
       testing::IsSupersetOf(
311
           {Building({.state_id = 1,
312
                .type = "anti_air_building",
313
                .position = {.x_coordinate = 2.0, .y_coordinate = 11.0, .z_coordinate = 2.0, .rotation = 0.0}}),
314
               Building({.state_id = 1,
315
                   .type = "anti_air_building",
316
                   .position = {.x_coordinate = 5.0, .y_coordinate = 11.0, .z_coordinate = 2.0, .rotation = 0.0}}),
317
               Building({.state_id = 1,
318
                   .type = "anti_air_building",
319
                   .position = {.x_coordinate = 2.0, .y_coordinate = 11.0, .z_coordinate = 5.0, .rotation = 0.0}})}));
1✔
320
}
17✔
321

322

323
TEST(Hoi4worldMapBuildingsCreatorTests, NoAntiAirInStateWithNoProvinces)
4✔
324
{
325
   const Buildings buildings = ImportBuildings(States({.states = {State(1, {})},
1✔
326
                                                   .province_to_state_id_map =
327
                                                       {
328
                                                           {1, 1},
329
                                                           {2, 1},
330
                                                           {3, 1},
331
                                                           {4, 1},
332
                                                           {5, 1},
333
                                                       }}),
1✔
334
       CoastalProvinces(),
1✔
335
       maps::MapData(
1✔
336
           {.the_province_points =
337
                   {
338
                       {"1",
339
                           maps::ProvincePoints(
2✔
340
                               {{1, 1}, {1, 2}, {1, 3}, {2, 1}, {2, 2}, {2, 3}, {3, 1}, {3, 2}, {3, 3}})},
341
                       {"2",
342
                           maps::ProvincePoints(
2✔
343
                               {{4, 1}, {4, 2}, {4, 3}, {5, 1}, {5, 2}, {5, 3}, {6, 1}, {6, 2}, {6, 3}})},
344
                       {"3",
345
                           maps::ProvincePoints(
2✔
346
                               {{1, 4}, {1, 5}, {1, 6}, {2, 4}, {2, 5}, {2, 6}, {3, 4}, {3, 5}, {3, 6}})},
347
                       {"4",
348
                           maps::ProvincePoints(
2✔
349
                               {{4, 4}, {4, 5}, {4, 6}, {5, 4}, {5, 5}, {5, 6}, {6, 4}, {6, 5}, {6, 6}})},
350
                   }}),
4✔
351
       commonItems::ModFilesystem{"test_files/Hoi4worldMapBuildingsCreatorTests/DefaultsToNoBuildings", {}});
2✔
352

353
   EXPECT_TRUE(buildings.GetBuildings().empty());
1✔
354
}
15✔
355

356

357
TEST(Hoi4worldMapBuildingsCreatorTests, AntiAirNotPlacedInProvincesWithNoPoints)
4✔
358
{
359
   std::stringstream log;
1✔
360
   std::streambuf* cout_buffer = std::cout.rdbuf();
1✔
361
   std::cout.rdbuf(log.rdbuf());
1✔
362

363
   const Buildings buildings = ImportBuildings(States({.states = {State(1, {.provinces = {1, 2, 3, 4, 5}})},
1✔
364
                                                   .province_to_state_id_map =
365
                                                       {
366
                                                           {1, 1},
367
                                                           {2, 1},
368
                                                           {3, 1},
369
                                                           {4, 1},
370
                                                           {5, 1},
371
                                                       }}),
1✔
372
       CoastalProvinces(),
1✔
373
       maps::MapData(),
2✔
374
       commonItems::ModFilesystem{"test_files/Hoi4worldMapBuildingsCreatorTests/DefaultsToNoBuildings", {}});
2✔
375

376
   std::cout.rdbuf(cout_buffer);
1✔
377

378
   EXPECT_TRUE(buildings.GetBuildings().empty());
1✔
379
   EXPECT_THAT(log.str(),
1✔
380
       testing::HasSubstr("[WARNING] Province 1 did not have any points. anti_air_building not fully set in state 1."));
1✔
381
   EXPECT_THAT(log.str(),
1✔
382
       testing::HasSubstr("[WARNING] Province 2 did not have any points. anti_air_building not fully set in state 1."));
1✔
383
   EXPECT_THAT(log.str(),
1✔
384
       testing::HasSubstr("[WARNING] Province 3 did not have any points. anti_air_building not fully set in state 1."));
1✔
385
   EXPECT_THAT(log.str(),
1✔
386
       testing::HasSubstr("[WARNING] Province 4 did not have any points. anti_air_building not fully set in state 1."));
1✔
387
}
4✔
388

389

390
TEST(Hoi4worldMapBuildingsCreatorTests, AntiAirPlacementOverridenByDefaultLocations)
4✔
391
{
392
   const Buildings
393
       buildings =
394
           ImportBuildings(States({.states = {State(1, {.provinces = {1, 2, 3, 4, 5}})},
1✔
395
                               .province_to_state_id_map =
396
                                   {
397
                                       {1, 1},
398
                                       {2, 1},
399
                                       {3, 1},
400
                                       {4, 1},
401
                                       {5, 1},
402
                                   }}),
1✔
403
               CoastalProvinces(),
1✔
404
               maps::MapData(
1✔
405
                   {.the_province_points =
406
                           {
407
                               {"1",
408
                                   maps::ProvincePoints(
2✔
409
                                       {{1, 1}, {1, 2}, {1, 3}, {2, 1}, {2, 2}, {2, 3}, {3, 1}, {3, 2}, {3, 3}})},
410
                               {"2",
411
                                   maps::ProvincePoints(
2✔
412
                                       {{4, 1}, {4, 2}, {4, 3}, {5, 1}, {5, 2}, {5, 3}, {6, 1}, {6, 2}, {6, 3}})},
413
                               {"3",
414
                                   maps::ProvincePoints(
2✔
415
                                       {{1, 4}, {1, 5}, {1, 6}, {2, 4}, {2, 5}, {2, 6}, {3, 4}, {3, 5}, {3, 6}})},
416
                               {"4",
417
                                   maps::ProvincePoints(
2✔
418
                                       {{4, 4}, {4, 5}, {4, 6}, {5, 4}, {5, 5}, {5, 6}, {6, 4}, {6, 5}, {6, 6}})},
419
                           },
420
                       .points_to_provinces =
421
                           {
422
                               {{4, 1}, "2"},
423
                               {{1, 4}, "3"},
424
                               {{4, 4}, "4"},
425
                           }}),
13✔
426
               commonItems::ModFilesystem{"test_files/Hoi4worldMapBuildingsCreatorTests/DefaultsExist", {}});
2✔
427

428
   EXPECT_THAT(buildings.GetBuildings(),
5✔
429
       testing::IsSupersetOf(
430
           {Building({.state_id = 1,
431
                .type = "anti_air_building",
432
                .position = {.x_coordinate = 4.0, .y_coordinate = 6.0, .z_coordinate = 1.0, .rotation = 90.0}}),
433
               Building({.state_id = 1,
434
                   .type = "anti_air_building",
435
                   .position = {.x_coordinate = 1.0, .y_coordinate = 6.0, .z_coordinate = 4.0, .rotation = 180.0}}),
436
               Building({.state_id = 1,
437
                   .type = "anti_air_building",
438
                   .position = {.x_coordinate = 4.0, .y_coordinate = 6.0, .z_coordinate = 4.0, .rotation = 270.0}})}));
1✔
439
}
26✔
440

441

442
TEST(Hoi4worldMapBuildingsCreatorTests, AntiAirPlacedInCenterOfFirstThreeProvincesOfStateIfDefaultNotInState)
4✔
443
{
444
   const Buildings buildings = ImportBuildings(States({.states = {State(1, {.provinces = {1, 2, 3, 4, 5}})},
1✔
445
                                                   .province_to_state_id_map =
446
                                                       {
447
                                                           {1, 1},
448
                                                           {2, 1},
449
                                                           {3, 1},
450
                                                           {4, 1},
451
                                                           {5, 1},
452
                                                       }}),
1✔
453
       CoastalProvinces(),
1✔
454
       maps::MapData(
1✔
455
           {.the_province_points =
456
                   {
457
                       {"1",
458
                           maps::ProvincePoints(
2✔
459
                               {{1, 1}, {1, 2}, {1, 3}, {2, 1}, {2, 2}, {2, 3}, {3, 1}, {3, 2}, {3, 3}})},
460
                       {"2",
461
                           maps::ProvincePoints(
2✔
462
                               {{4, 1}, {4, 2}, {4, 3}, {5, 1}, {5, 2}, {5, 3}, {6, 1}, {6, 2}, {6, 3}})},
463
                       {"3",
464
                           maps::ProvincePoints(
2✔
465
                               {{1, 4}, {1, 5}, {1, 6}, {2, 4}, {2, 5}, {2, 6}, {3, 4}, {3, 5}, {3, 6}})},
466
                       {"4",
467
                           maps::ProvincePoints(
2✔
468
                               {{4, 4}, {4, 5}, {4, 6}, {5, 4}, {5, 5}, {5, 6}, {6, 4}, {6, 5}, {6, 6}})},
469
                   }}),
4✔
470
       commonItems::ModFilesystem{"test_files/Hoi4worldMapBuildingsCreatorTests/DefaultsExist", {}});
2✔
471

472
   EXPECT_THAT(buildings.GetBuildings(),
5✔
473
       testing::IsSupersetOf(
474
           {Building({.state_id = 1,
475
                .type = "anti_air_building",
476
                .position = {.x_coordinate = 2.0, .y_coordinate = 11.0, .z_coordinate = 2.0, .rotation = 0.0}}),
477
               Building({.state_id = 1,
478
                   .type = "anti_air_building",
479
                   .position = {.x_coordinate = 5.0, .y_coordinate = 11.0, .z_coordinate = 2.0, .rotation = 0.0}}),
480
               Building({.state_id = 1,
481
                   .type = "anti_air_building",
482
                   .position = {.x_coordinate = 2.0, .y_coordinate = 11.0, .z_coordinate = 5.0, .rotation = 0.0}})}));
1✔
483
}
17✔
484

485

486
TEST(Hoi4worldMapBuildingsCreatorTests, ArmsFactoriesPlacedInCenterOfFirstSixProvincesOfState)
4✔
487
{
488
   const Buildings buildings = ImportBuildings(States({.states = {State(1, {.provinces = {1, 2, 3, 4, 5, 6, 7}})},
1✔
489
                                                   .province_to_state_id_map =
490
                                                       {
491
                                                           {1, 1},
492
                                                           {2, 1},
493
                                                           {3, 1},
494
                                                           {4, 1},
495
                                                           {5, 1},
496
                                                           {6, 1},
497
                                                           {7, 1},
498
                                                       }}),
1✔
499
       CoastalProvinces(),
1✔
500
       maps::MapData(
1✔
501
           {.the_province_points =
502
                   {
503
                       {"1",
504
                           maps::ProvincePoints(
2✔
505
                               {{1, 1}, {1, 2}, {1, 3}, {2, 1}, {2, 2}, {2, 3}, {3, 1}, {3, 2}, {3, 3}})},
506
                       {"2",
507
                           maps::ProvincePoints(
2✔
508
                               {{4, 1}, {4, 2}, {4, 3}, {5, 1}, {5, 2}, {5, 3}, {6, 1}, {6, 2}, {6, 3}})},
509
                       {"3",
510
                           maps::ProvincePoints(
2✔
511
                               {{1, 4}, {1, 5}, {1, 6}, {2, 4}, {2, 5}, {2, 6}, {3, 4}, {3, 5}, {3, 6}})},
512
                       {"4",
513
                           maps::ProvincePoints(
2✔
514
                               {{4, 4}, {4, 5}, {4, 6}, {5, 4}, {5, 5}, {5, 6}, {6, 4}, {6, 5}, {6, 6}})},
515
                       {"5",
516
                           maps::ProvincePoints(
2✔
517
                               {{7, 1}, {7, 2}, {7, 3}, {8, 1}, {8, 2}, {8, 3}, {9, 1}, {9, 2}, {9, 3}})},
518
                       {"6",
519
                           maps::ProvincePoints(
2✔
520
                               {{7, 4}, {7, 5}, {7, 6}, {8, 4}, {8, 5}, {8, 6}, {9, 4}, {9, 5}, {9, 6}})},
521
                       {"7",
522
                           maps::ProvincePoints(
2✔
523
                               {{1, 7}, {1, 8}, {1, 9}, {2, 7}, {2, 8}, {2, 9}, {3, 7}, {3, 8}, {3, 9}})},
524
                   }}),
7✔
525
       commonItems::ModFilesystem{"test_files/Hoi4worldMapBuildingsCreatorTests/DefaultsToNoBuildings", {}});
2✔
526

527
   EXPECT_THAT(buildings.GetBuildings(),
8✔
528
       testing::IsSupersetOf(
529
           {Building({.state_id = 1,
530
                .type = "arms_factory",
531
                .position = {.x_coordinate = 2.0, .y_coordinate = 11.0, .z_coordinate = 2.0, .rotation = 0.0}}),
532
               Building({.state_id = 1,
533
                   .type = "arms_factory",
534
                   .position = {.x_coordinate = 5.0, .y_coordinate = 11.0, .z_coordinate = 2.0, .rotation = 0.0}}),
535
               Building({.state_id = 1,
536
                   .type = "arms_factory",
537
                   .position = {.x_coordinate = 2.0, .y_coordinate = 11.0, .z_coordinate = 5.0, .rotation = 0.0}}),
538
               Building({.state_id = 1,
539
                   .type = "arms_factory",
540
                   .position = {.x_coordinate = 5.0, .y_coordinate = 11.0, .z_coordinate = 5.0, .rotation = 0.0}}),
541
               Building({.state_id = 1,
542
                   .type = "arms_factory",
543
                   .position = {.x_coordinate = 8.0, .y_coordinate = 11.0, .z_coordinate = 2.0, .rotation = 0.0}}),
544
               Building({.state_id = 1,
545
                   .type = "arms_factory",
546
                   .position = {.x_coordinate = 8.0, .y_coordinate = 11.0, .z_coordinate = 5.0, .rotation = 0.0}})}));
1✔
547
}
23✔
548

549

550
TEST(Hoi4worldMapBuildingsCreatorTests, NoArmsFactoriesInStateWithNoProvinces)
4✔
551
{
552
   const Buildings buildings = ImportBuildings(States({.states = {State(1, {})},
1✔
553
                                                   .province_to_state_id_map =
554
                                                       {
555
                                                           {1, 1},
556
                                                           {2, 1},
557
                                                           {3, 1},
558
                                                           {4, 1},
559
                                                           {5, 1},
560
                                                           {6, 1},
561
                                                           {7, 1},
562
                                                       }}),
1✔
563
       CoastalProvinces(),
1✔
564
       maps::MapData(
1✔
565
           {.the_province_points =
566
                   {
567
                       {"1",
568
                           maps::ProvincePoints(
2✔
569
                               {{1, 1}, {1, 2}, {1, 3}, {2, 1}, {2, 2}, {2, 3}, {3, 1}, {3, 2}, {3, 3}})},
570
                       {"2",
571
                           maps::ProvincePoints(
2✔
572
                               {{4, 1}, {4, 2}, {4, 3}, {5, 1}, {5, 2}, {5, 3}, {6, 1}, {6, 2}, {6, 3}})},
573
                       {"3",
574
                           maps::ProvincePoints(
2✔
575
                               {{1, 4}, {1, 5}, {1, 6}, {2, 4}, {2, 5}, {2, 6}, {3, 4}, {3, 5}, {3, 6}})},
576
                       {"4",
577
                           maps::ProvincePoints(
2✔
578
                               {{4, 4}, {4, 5}, {4, 6}, {5, 4}, {5, 5}, {5, 6}, {6, 4}, {6, 5}, {6, 6}})},
579
                       {"5",
580
                           maps::ProvincePoints(
2✔
581
                               {{7, 1}, {7, 2}, {7, 3}, {8, 1}, {8, 2}, {8, 3}, {9, 1}, {9, 2}, {9, 3}})},
582
                       {"6",
583
                           maps::ProvincePoints(
2✔
584
                               {{7, 4}, {7, 5}, {7, 6}, {8, 4}, {8, 5}, {8, 6}, {9, 4}, {9, 5}, {9, 6}})},
585
                       {"7",
586
                           maps::ProvincePoints(
2✔
587
                               {{1, 7}, {1, 8}, {1, 9}, {2, 7}, {2, 8}, {2, 9}, {3, 7}, {3, 8}, {3, 9}})},
588
                   }}),
7✔
589
       commonItems::ModFilesystem{"test_files/Hoi4worldMapBuildingsCreatorTests/DefaultsToNoBuildings", {}});
2✔
590

591
   EXPECT_TRUE(buildings.GetBuildings().empty());
1✔
592
}
21✔
593

594

595
TEST(Hoi4worldMapBuildingsCreatorTests, ArmsFactoriesNotPlacedInProvincesWithNoPoints)
4✔
596
{
597
   std::stringstream log;
1✔
598
   std::streambuf* cout_buffer = std::cout.rdbuf();
1✔
599
   std::cout.rdbuf(log.rdbuf());
1✔
600

601
   const Buildings buildings = ImportBuildings(States({.states = {State(1, {.provinces = {1, 2, 3, 4, 5, 6, 7}})},
1✔
602
                                                   .province_to_state_id_map =
603
                                                       {
604
                                                           {1, 1},
605
                                                           {2, 1},
606
                                                           {3, 1},
607
                                                           {4, 1},
608
                                                           {5, 1},
609
                                                           {6, 1},
610
                                                           {7, 1},
611
                                                       }}),
1✔
612
       CoastalProvinces(),
1✔
613
       maps::MapData(),
2✔
614
       commonItems::ModFilesystem{"test_files/Hoi4worldMapBuildingsCreatorTests/DefaultsToNoBuildings", {}});
2✔
615

616
   std::cout.rdbuf(cout_buffer);
1✔
617

618
   EXPECT_TRUE(buildings.GetBuildings().empty());
1✔
619
   EXPECT_THAT(log.str(),
1✔
620
       testing::HasSubstr("[WARNING] Province 1 did not have any points. arms_factory not fully set in state 1."));
1✔
621
   EXPECT_THAT(log.str(),
1✔
622
       testing::HasSubstr("[WARNING] Province 2 did not have any points. arms_factory not fully set in state 1."));
1✔
623
   EXPECT_THAT(log.str(),
1✔
624
       testing::HasSubstr("[WARNING] Province 3 did not have any points. arms_factory not fully set in state 1."));
1✔
625
   EXPECT_THAT(log.str(),
1✔
626
       testing::HasSubstr("[WARNING] Province 4 did not have any points. arms_factory not fully set in state 1."));
1✔
627
}
4✔
628

629

630
TEST(Hoi4worldMapBuildingsCreatorTests, ArmsFactoriesPlacementOverridenByDefaultLocations)
4✔
631
{
632
   const Buildings
633
       buildings =
634
           ImportBuildings(States({.states = {State(1, {.provinces = {1, 2, 3, 4, 5, 6, 7}})},
1✔
635
                               .province_to_state_id_map =
636
                                   {
637
                                       {1, 1},
638
                                       {2, 1},
639
                                       {3, 1},
640
                                       {4, 1},
641
                                       {5, 1},
642
                                       {6, 1},
643
                                       {7, 1},
644
                                   }}),
1✔
645
               CoastalProvinces(),
1✔
646
               maps::MapData(
1✔
647
                   {.the_province_points =
648
                           {
649
                               {"1",
650
                                   maps::ProvincePoints(
2✔
651
                                       {{1, 1}, {1, 2}, {1, 3}, {2, 1}, {2, 2}, {2, 3}, {3, 1}, {3, 2}, {3, 3}})},
652
                               {"2",
653
                                   maps::ProvincePoints(
2✔
654
                                       {{4, 1}, {4, 2}, {4, 3}, {5, 1}, {5, 2}, {5, 3}, {6, 1}, {6, 2}, {6, 3}})},
655
                               {"3",
656
                                   maps::ProvincePoints(
2✔
657
                                       {{1, 4}, {1, 5}, {1, 6}, {2, 4}, {2, 5}, {2, 6}, {3, 4}, {3, 5}, {3, 6}})},
658
                               {"4",
659
                                   maps::ProvincePoints(
2✔
660
                                       {{4, 4}, {4, 5}, {4, 6}, {5, 4}, {5, 5}, {5, 6}, {6, 4}, {6, 5}, {6, 6}})},
661
                               {"5",
662
                                   maps::ProvincePoints(
2✔
663
                                       {{7, 1}, {7, 2}, {7, 3}, {8, 1}, {8, 2}, {8, 3}, {9, 1}, {9, 2}, {9, 3}})},
664
                               {"6",
665
                                   maps::ProvincePoints(
2✔
666
                                       {{7, 4}, {7, 5}, {7, 6}, {8, 4}, {8, 5}, {8, 6}, {9, 4}, {9, 5}, {9, 6}})},
667
                               {"7",
668
                                   maps::ProvincePoints(
2✔
669
                                       {{1, 7}, {1, 8}, {1, 9}, {2, 7}, {2, 8}, {2, 9}, {3, 7}, {3, 8}, {3, 9}})},
670
                           },
671
                       .points_to_provinces =
672
                           {
673
                               {{4, 1}, "2"},
674
                               {{1, 4}, "3"},
675
                               {{4, 4}, "4"},
676
                               {{7, 1}, "5"},
677
                               {{7, 4}, "6"},
678
                               {{1, 7}, "7"},
679
                           }}),
25✔
680
               commonItems::ModFilesystem{"test_files/Hoi4worldMapBuildingsCreatorTests/DefaultsExist", {}});
2✔
681

682
   EXPECT_THAT(buildings.GetBuildings(),
8✔
683
       testing::IsSupersetOf(
684
           {Building({.state_id = 1,
685
                .type = "arms_factory",
686
                .position = {.x_coordinate = 4.0, .y_coordinate = 6.0, .z_coordinate = 1.0, .rotation = 45.0}}),
687
               Building({.state_id = 1,
688
                   .type = "arms_factory",
689
                   .position = {.x_coordinate = 1.0, .y_coordinate = 6.0, .z_coordinate = 4.0, .rotation = 90.0}}),
690
               Building({.state_id = 1,
691
                   .type = "arms_factory",
692
                   .position = {.x_coordinate = 4.0, .y_coordinate = 6.0, .z_coordinate = 4.0, .rotation = 135.0}}),
693
               Building({.state_id = 1,
694
                   .type = "arms_factory",
695
                   .position = {.x_coordinate = 7.0, .y_coordinate = 6.0, .z_coordinate = 1.0, .rotation = 180.0}}),
696
               Building({.state_id = 1,
697
                   .type = "arms_factory",
698
                   .position = {.x_coordinate = 7.0, .y_coordinate = 6.0, .z_coordinate = 4.0, .rotation = 225.0}}),
699
               Building({.state_id = 1,
700
                   .type = "arms_factory",
701
                   .position = {.x_coordinate = 1.0, .y_coordinate = 6.0, .z_coordinate = 7.0, .rotation = 270.0}})}));
1✔
702
}
41✔
703

704

705
TEST(Hoi4worldMapBuildingsCreatorTests, ArmsFactoriesPlacedInCenterOfFirstSixProvincesOfStateIfDefaultNotInState)
4✔
706
{
707
   const Buildings buildings = ImportBuildings(States({.states = {State(1, {.provinces = {1, 2, 3, 4, 5, 6, 7}})},
1✔
708
                                                   .province_to_state_id_map =
709
                                                       {
710
                                                           {1, 1},
711
                                                           {2, 1},
712
                                                           {3, 1},
713
                                                           {4, 1},
714
                                                           {5, 1},
715
                                                           {6, 1},
716
                                                           {7, 1},
717
                                                       }}),
1✔
718
       CoastalProvinces(),
1✔
719
       maps::MapData(
1✔
720
           {.the_province_points =
721
                   {
722
                       {"1",
723
                           maps::ProvincePoints(
2✔
724
                               {{1, 1}, {1, 2}, {1, 3}, {2, 1}, {2, 2}, {2, 3}, {3, 1}, {3, 2}, {3, 3}})},
725
                       {"2",
726
                           maps::ProvincePoints(
2✔
727
                               {{4, 1}, {4, 2}, {4, 3}, {5, 1}, {5, 2}, {5, 3}, {6, 1}, {6, 2}, {6, 3}})},
728
                       {"3",
729
                           maps::ProvincePoints(
2✔
730
                               {{1, 4}, {1, 5}, {1, 6}, {2, 4}, {2, 5}, {2, 6}, {3, 4}, {3, 5}, {3, 6}})},
731
                       {"4",
732
                           maps::ProvincePoints(
2✔
733
                               {{4, 4}, {4, 5}, {4, 6}, {5, 4}, {5, 5}, {5, 6}, {6, 4}, {6, 5}, {6, 6}})},
734
                       {"5",
735
                           maps::ProvincePoints(
2✔
736
                               {{7, 1}, {7, 2}, {7, 3}, {8, 1}, {8, 2}, {8, 3}, {9, 1}, {9, 2}, {9, 3}})},
737
                       {"6",
738
                           maps::ProvincePoints(
2✔
739
                               {{7, 4}, {7, 5}, {7, 6}, {8, 4}, {8, 5}, {8, 6}, {9, 4}, {9, 5}, {9, 6}})},
740
                       {"7",
741
                           maps::ProvincePoints(
2✔
742
                               {{1, 7}, {1, 8}, {1, 9}, {2, 7}, {2, 8}, {2, 9}, {3, 7}, {3, 8}, {3, 9}})},
743
                   }}),
7✔
744
       commonItems::ModFilesystem{"test_files/Hoi4worldMapBuildingsCreatorTests/DefaultsExist", {}});
2✔
745

746
   EXPECT_THAT(buildings.GetBuildings(),
8✔
747
       testing::IsSupersetOf(
748
           {Building({.state_id = 1,
749
                .type = "arms_factory",
750
                .position = {.x_coordinate = 2.0, .y_coordinate = 11.0, .z_coordinate = 2.0, .rotation = 0.0}}),
751
               Building({.state_id = 1,
752
                   .type = "arms_factory",
753
                   .position = {.x_coordinate = 5.0, .y_coordinate = 11.0, .z_coordinate = 2.0, .rotation = 0.0}}),
754
               Building({.state_id = 1,
755
                   .type = "arms_factory",
756
                   .position = {.x_coordinate = 2.0, .y_coordinate = 11.0, .z_coordinate = 5.0, .rotation = 0.0}}),
757
               Building({.state_id = 1,
758
                   .type = "arms_factory",
759
                   .position = {.x_coordinate = 5.0, .y_coordinate = 11.0, .z_coordinate = 5.0, .rotation = 0.0}}),
760
               Building({.state_id = 1,
761
                   .type = "arms_factory",
762
                   .position = {.x_coordinate = 8.0, .y_coordinate = 11.0, .z_coordinate = 2.0, .rotation = 0.0}}),
763
               Building({.state_id = 1,
764
                   .type = "arms_factory",
765
                   .position = {.x_coordinate = 8.0, .y_coordinate = 11.0, .z_coordinate = 5.0, .rotation = 0.0}})}));
1✔
766
}
23✔
767

768

769
TEST(Hoi4worldMapBuildingsCreatorTests, BunkerPlacedInCenterOfABorderForAllProvincesOfState)
4✔
770
{
771
   const States states = {.states = {State(1, {.provinces = {1, 2, 3, 4}})},
772
       .province_to_state_id_map = {
773
           {1, 1},
774
           {2, 1},
775
           {3, 1},
776
           {4, 1},
777
       }};
2✔
778

779
   const std::map<std::string, maps::BordersWith> borders = {
780
       {"1",
781
           maps::BordersWith{
5✔
782
               {"2",
UNCOV
783
                   maps::BorderPoints{
×
784
                       {3, 1},
785
                       {3, 2},
786
                       {3, 3},
787
                   }},
788
               {"3",
789
                   maps::BorderPoints{
1✔
790
                       {1, 3},
791
                       {2, 3},
792
                       {3, 3},
793
                   }},
794
           }},
6✔
795
       {"2",
796
           maps::BordersWith{
5✔
797
               {"1",
UNCOV
798
                   maps::BorderPoints{
×
799
                       {4, 1},
800
                       {4, 2},
801
                       {4, 3},
802
                   }},
803
               {"4",
804
                   maps::BorderPoints{
1✔
805
                       {4, 3},
806
                       {5, 3},
807
                       {6, 3},
808
                   }},
809
           }},
6✔
810
       {"3",
811
           maps::BordersWith{
5✔
812
               {"1",
UNCOV
813
                   maps::BorderPoints{
×
814
                       {1, 4},
815
                       {2, 4},
816
                       {3, 4},
817
                   }},
818
               {"4",
819
                   maps::BorderPoints{
1✔
820
                       {3, 4},
821
                       {3, 5},
822
                       {3, 6},
823
                   }},
824
           }},
6✔
825
       {"4",
826
           maps::BordersWith{
5✔
827
               {"2",
UNCOV
828
                   maps::BorderPoints{
×
829
                       {4, 4},
830
                       {5, 4},
831
                       {6, 4},
832
                   }},
833
               {"3",
834
                   maps::BorderPoints{
1✔
835
                       {4, 4},
836
                       {4, 5},
837
                       {4, 6},
838
                   }},
839
           }},
6✔
840
   };
5✔
841

842
   const Buildings buildings = ImportBuildings(states,
843
       CoastalProvinces(),
2✔
844
       maps::MapData({.borders = borders}),
1✔
845
       commonItems::ModFilesystem{"test_files/Hoi4worldMapBuildingsCreatorTests/DefaultsToNoBuildings", {}});
3✔
846

847
   EXPECT_THAT(buildings.GetBuildings(),
6✔
848
       testing::IsSupersetOf(
849
           {Building({.state_id = 1,
850
                .type = "bunker",
851
                .position = {.x_coordinate = 3.0, .y_coordinate = 11.0, .z_coordinate = 2.0, .rotation = 0.0}}),
852
               Building({.state_id = 1,
853
                   .type = "bunker",
854
                   .position = {.x_coordinate = 4.0, .y_coordinate = 11.0, .z_coordinate = 2.0, .rotation = 0.0}}),
855
               Building({.state_id = 1,
856
                   .type = "bunker",
857
                   .position = {.x_coordinate = 2.0, .y_coordinate = 11.0, .z_coordinate = 4.0, .rotation = 0.0}}),
858
               Building({.state_id = 1,
859
                   .type = "bunker",
860
                   .position = {.x_coordinate = 5.0, .y_coordinate = 11.0, .z_coordinate = 4.0, .rotation = 0.0}})}));
1✔
861
}
18✔
862

863

864
TEST(Hoi4worldMapBuildingsCreatorTests, NoBunkersInStateWithNoProvinces)
4✔
865
{
866
   const States states({.states = {State(1, {})},
867
       .province_to_state_id_map = {
868
           {1, 1},
869
           {2, 1},
870
           {3, 1},
871
           {4, 1},
872
       }});
2✔
873

874
   const std::map<std::string, maps::BordersWith> borders = {
875
       {"1",
876
           maps::BordersWith{
5✔
877
               {"2",
UNCOV
878
                   maps::BorderPoints{
×
879
                       {3, 1},
880
                       {3, 2},
881
                       {3, 3},
882
                   }},
883
               {"3",
884
                   maps::BorderPoints{
1✔
885
                       {1, 3},
886
                       {2, 3},
887
                       {3, 3},
888
                   }},
889
           }},
6✔
890
       {"2",
891
           maps::BordersWith{
5✔
892
               {"1",
UNCOV
893
                   maps::BorderPoints{
×
894
                       {4, 1},
895
                       {4, 2},
896
                       {4, 3},
897
                   }},
898
               {"4",
899
                   maps::BorderPoints{
1✔
900
                       {4, 3},
901
                       {5, 3},
902
                       {6, 3},
903
                   }},
904
           }},
6✔
905
       {"3",
906
           maps::BordersWith{
5✔
907
               {"1",
UNCOV
908
                   maps::BorderPoints{
×
909
                       {1, 4},
910
                       {2, 4},
911
                       {3, 4},
912
                   }},
913
               {"4",
914
                   maps::BorderPoints{
1✔
915
                       {3, 4},
916
                       {3, 5},
917
                       {3, 6},
918
                   }},
919
           }},
6✔
920
       {"4",
921
           maps::BordersWith{
5✔
922
               {"2",
UNCOV
923
                   maps::BorderPoints{
×
924
                       {4, 4},
925
                       {5, 4},
926
                       {6, 4},
927
                   }},
928
               {"3",
929
                   maps::BorderPoints{
1✔
930
                       {4, 4},
931
                       {4, 5},
932
                       {4, 6},
933
                   }},
934
           }},
6✔
935
   };
5✔
936

937
   const maps::MapData map_data({.borders = borders});
1✔
938

939
   const Buildings buildings = ImportBuildings(states,
940
       CoastalProvinces(),
2✔
941
       map_data,
942
       commonItems::ModFilesystem{"test_files/Hoi4worldMapBuildingsCreatorTests/DefaultsToNoBuildings", {}});
3✔
943

944
   for (const auto& building: buildings.GetBuildings())
5✔
945
   {
946
      EXPECT_NE(building.GetType(), "bunker");
4✔
947
   }
948
}
16✔
949

950

951
TEST(Hoi4worldMapBuildingsCreatorTests, BunkersNotPlacedInProvincesWithNoBorders)
4✔
952
{
953
   std::stringstream log;
1✔
954
   std::streambuf* cout_buffer = std::cout.rdbuf();
1✔
955
   std::cout.rdbuf(log.rdbuf());
1✔
956

957
   const Buildings buildings = ImportBuildings(States({.states = {State(1, {.provinces = {1, 2, 3, 4}})},
1✔
958
                                                   .province_to_state_id_map =
959
                                                       {
960
                                                           {1, 1},
961
                                                           {2, 1},
962
                                                           {3, 1},
963
                                                           {4, 1},
964
                                                       }}),
1✔
965
       CoastalProvinces(),
1✔
966
       maps::MapData(),
2✔
967
       commonItems::ModFilesystem{"test_files/Hoi4worldMapBuildingsCreatorTests/DefaultsToNoBuildings", {}});
2✔
968

969
   std::cout.rdbuf(cout_buffer);
1✔
970

971
   EXPECT_TRUE(buildings.GetBuildings().empty());
1✔
972
   EXPECT_THAT(log.str(),
1✔
973
       testing::HasSubstr("[WARNING] Province 1 did not have any border points. Bunkers not fully set in state 1."));
1✔
974
   EXPECT_THAT(log.str(),
1✔
975
       testing::HasSubstr("[WARNING] Province 2 did not have any border points. Bunkers not fully set in state 1."));
1✔
976
   EXPECT_THAT(log.str(),
1✔
977
       testing::HasSubstr("[WARNING] Province 3 did not have any border points. Bunkers not fully set in state 1."));
1✔
978
   EXPECT_THAT(log.str(),
1✔
979
       testing::HasSubstr("[WARNING] Province 4 did not have any border points. Bunkers not fully set in state 1."));
1✔
980
}
4✔
981

982

983
TEST(Hoi4worldMapBuildingsCreatorTests, BunkerPlacementOverridenByDefaultLocations)
4✔
984
{
985
   const States states({.states = {State(1, {.provinces = {1, 2, 3, 4, 5}})},
986
       .province_to_state_id_map = {
987
           {1, 1},
988
           {2, 1},
989
           {3, 1},
990
           {4, 1},
991
           {5, 1},
992
       }});
2✔
993

994
   const std::map<std::string, maps::BordersWith> borders = {
995
       {"1",
996
           maps::BordersWith{
5✔
997
               {"2",
UNCOV
998
                   maps::BorderPoints{
×
999
                       {3, 1},
1000
                       {3, 2},
1001
                       {3, 3},
1002
                   }},
1003
               {"3",
1004
                   maps::BorderPoints{
1✔
1005
                       {1, 3},
1006
                       {2, 3},
1007
                       {3, 3},
1008
                   }},
1009
           }},
6✔
1010
       {"2",
1011
           maps::BordersWith{
5✔
1012
               {"1",
UNCOV
1013
                   maps::BorderPoints{
×
1014
                       {4, 1},
1015
                       {4, 2},
1016
                       {4, 3},
1017
                   }},
1018
               {"4",
1019
                   maps::BorderPoints{
1✔
1020
                       {4, 3},
1021
                       {5, 3},
1022
                       {6, 3},
1023
                   }},
1024
           }},
6✔
1025
       {"3",
1026
           maps::BordersWith{
5✔
1027
               {"1",
UNCOV
1028
                   maps::BorderPoints{
×
1029
                       {1, 4},
1030
                       {2, 4},
1031
                       {3, 4},
1032
                   }},
1033
               {"4",
1034
                   maps::BorderPoints{
1✔
1035
                       {3, 4},
1036
                       {3, 5},
1037
                       {3, 6},
1038
                   }},
1039
           }},
6✔
1040
       {"4",
1041
           maps::BordersWith{
5✔
1042
               {"2",
UNCOV
1043
                   maps::BorderPoints{
×
1044
                       {4, 4},
1045
                       {5, 4},
1046
                       {6, 4},
1047
                   }},
1048
               {"3",
1049
                   maps::BorderPoints{
1✔
1050
                       {4, 4},
1051
                       {4, 5},
1052
                       {4, 6},
1053
                   }},
1054
           }},
6✔
1055
   };
5✔
1056

1057
   const maps::MapData map_data({.borders = borders,
1058
       .points_to_provinces = {
1059
           {{3, 2}, "1"},
1060
           {{4, 2}, "2"},
1061
           {{2, 4}, "3"},
1062
           {{5, 4}, "4"},
1063
       }});
13✔
1064

1065
   const Buildings buildings = ImportBuildings(states,
1066
       CoastalProvinces(),
2✔
1067
       map_data,
1068
       commonItems::ModFilesystem{"test_files/Hoi4worldMapBuildingsCreatorTests/DefaultsExist", {}});
3✔
1069

1070
   EXPECT_THAT(buildings.GetBuildings(),
6✔
1071
       testing::IsSupersetOf(
1072
           {Building({.state_id = 1,
1073
                .type = "bunker",
1074
                .position = {.x_coordinate = 3.0, .y_coordinate = 6.0, .z_coordinate = 2.0, .rotation = 90.0}}),
1075
               Building({.state_id = 1,
1076
                   .type = "bunker",
1077
                   .position = {.x_coordinate = 4.0, .y_coordinate = 6.0, .z_coordinate = 2.0, .rotation = 180.0}}),
1078
               Building({.state_id = 1,
1079
                   .type = "bunker",
1080
                   .position = {.x_coordinate = 2.0, .y_coordinate = 6.0, .z_coordinate = 4.0, .rotation = 270.0}}),
1081
               Building({.state_id = 1,
1082
                   .type = "bunker",
1083
                   .position = {.x_coordinate = 5.0, .y_coordinate = 6.0, .z_coordinate = 4.0, .rotation = 359.0}})}));
1✔
1084
}
31✔
1085

1086

1087
TEST(Hoi4worldMapBuildingsCreatorTests, BunkerPlacedInCenterOfABorderForAllProvincesOfStateIfDefaultsNotInState)
4✔
1088
{
1089
   const States states({.states = {State(1, {.provinces = {1, 2, 3, 4, 5}})},
1090
       .province_to_state_id_map = {
1091
           {1, 1},
1092
           {2, 1},
1093
           {3, 1},
1094
           {4, 1},
1095
           {5, 1},
1096
       }});
2✔
1097

1098
   const std::map<std::string, maps::BordersWith> borders = {
1099
       {"1",
1100
           maps::BordersWith{
5✔
1101
               {"2",
UNCOV
1102
                   maps::BorderPoints{
×
1103
                       {3, 1},
1104
                       {3, 2},
1105
                       {3, 3},
1106
                   }},
1107
               {"3",
1108
                   maps::BorderPoints{
1✔
1109
                       {1, 3},
1110
                       {2, 3},
1111
                       {3, 3},
1112
                   }},
1113
           }},
6✔
1114
       {"2",
1115
           maps::BordersWith{
5✔
1116
               {"1",
UNCOV
1117
                   maps::BorderPoints{
×
1118
                       {4, 1},
1119
                       {4, 2},
1120
                       {4, 3},
1121
                   }},
1122
               {"4",
1123
                   maps::BorderPoints{
1✔
1124
                       {4, 3},
1125
                       {5, 3},
1126
                       {6, 3},
1127
                   }},
1128
           }},
6✔
1129
       {"3",
1130
           maps::BordersWith{
5✔
1131
               {"1",
UNCOV
1132
                   maps::BorderPoints{
×
1133
                       {1, 4},
1134
                       {2, 4},
1135
                       {3, 4},
1136
                   }},
1137
               {"4",
1138
                   maps::BorderPoints{
1✔
1139
                       {3, 4},
1140
                       {3, 5},
1141
                       {3, 6},
1142
                   }},
1143
           }},
6✔
1144
       {"4",
1145
           maps::BordersWith{
5✔
1146
               {"2",
UNCOV
1147
                   maps::BorderPoints{
×
1148
                       {4, 4},
1149
                       {5, 4},
1150
                       {6, 4},
1151
                   }},
1152
               {"3",
1153
                   maps::BorderPoints{
1✔
1154
                       {4, 4},
1155
                       {4, 5},
1156
                       {4, 6},
1157
                   }},
1158
           }},
6✔
1159
   };
5✔
1160

1161
   const maps::MapData map_data({.borders = borders});
1✔
1162

1163
   const Buildings buildings = ImportBuildings(states,
1164
       CoastalProvinces(),
2✔
1165
       map_data,
1166
       commonItems::ModFilesystem{"test_files/Hoi4worldMapBuildingsCreatorTests/DefaultsExist", {}});
3✔
1167

1168
   EXPECT_THAT(buildings.GetBuildings(),
6✔
1169
       testing::IsSupersetOf(
1170
           {Building({.state_id = 1,
1171
                .type = "bunker",
1172
                .position = {.x_coordinate = 3.0, .y_coordinate = 11.0, .z_coordinate = 2.0, .rotation = 0.0}}),
1173
               Building({.state_id = 1,
1174
                   .type = "bunker",
1175
                   .position = {.x_coordinate = 4.0, .y_coordinate = 11.0, .z_coordinate = 2.0, .rotation = 0.0}}),
1176
               Building({.state_id = 1,
1177
                   .type = "bunker",
1178
                   .position = {.x_coordinate = 2.0, .y_coordinate = 11.0, .z_coordinate = 4.0, .rotation = 0.0}}),
1179
               Building({.state_id = 1,
1180
                   .type = "bunker",
1181
                   .position = {.x_coordinate = 5.0, .y_coordinate = 11.0, .z_coordinate = 4.0, .rotation = 0.0}})}));
1✔
1182
}
18✔
1183

1184

1185
TEST(Hoi4worldMapBuildingsCreatorTests, CoastalBunkerPlacedInCenterOfSeaBorderForAllProvincesOfState)
4✔
1186
{
1187
   const States states({.states = {State(1, {.provinces = {1, 2, 3, 4}})},
1188
       .province_to_state_id_map = {
1189
           {1, 1},
1190
           {2, 1},
1191
           {3, 1},
1192
           {4, 1},
1193
       }});
2✔
1194

1195
   const CoastalProvinces coastal_provinces({{1, {5}}, {2, {6}}, {3, {7}}, {4, {8}}});
13✔
1196

1197
   const std::map<std::string, maps::BordersWith> borders = {
1198
       {"1",
1199
           maps::BordersWith{
6✔
1200
               {"2",
UNCOV
1201
                   maps::BorderPoints{
×
1202
                       {3, 1},
1203
                       {3, 2},
1204
                       {3, 3},
1205
                   }},
1206
               {"3",
UNCOV
1207
                   maps::BorderPoints{
×
1208
                       {1, 3},
1209
                       {2, 3},
1210
                       {3, 3},
1211
                   }},
1212
               {"5",
1213
                   maps::BorderPoints{
1✔
1214
                       {1, 1},
1215
                       {2, 1},
1216
                       {3, 1},
1217
                   }},
1218
           }},
8✔
1219
       {"2",
1220
           maps::BordersWith{
6✔
1221
               {"1",
UNCOV
1222
                   maps::BorderPoints{
×
1223
                       {4, 1},
1224
                       {4, 2},
1225
                       {4, 3},
1226
                   }},
1227
               {"4",
UNCOV
1228
                   maps::BorderPoints{
×
1229
                       {4, 3},
1230
                       {5, 3},
1231
                       {6, 3},
1232
                   }},
1233
               {"6",
1234
                   maps::BorderPoints{
1✔
1235
                       {4, 1},
1236
                       {5, 1},
1237
                       {6, 1},
1238
                   }},
1239
           }},
8✔
1240
       {"3",
1241
           maps::BordersWith{
6✔
1242
               {"1",
UNCOV
1243
                   maps::BorderPoints{
×
1244
                       {1, 4},
1245
                       {2, 4},
1246
                       {3, 4},
1247
                   }},
1248
               {"4",
UNCOV
1249
                   maps::BorderPoints{
×
1250
                       {3, 4},
1251
                       {3, 5},
1252
                       {3, 6},
1253
                   }},
1254
               {"7",
1255
                   maps::BorderPoints{
1✔
1256
                       {1, 6},
1257
                       {2, 6},
1258
                       {3, 6},
1259
                   }},
1260
           }},
8✔
1261
       {"4",
1262
           maps::BordersWith{
6✔
1263
               {"2",
UNCOV
1264
                   maps::BorderPoints{
×
1265
                       {4, 4},
1266
                       {5, 4},
1267
                       {6, 4},
1268
                   }},
1269
               {"3",
UNCOV
1270
                   maps::BorderPoints{
×
1271
                       {4, 4},
1272
                       {4, 5},
1273
                       {4, 6},
1274
                   }},
1275
               {"8",
1276
                   maps::BorderPoints{
1✔
1277
                       {4, 6},
1278
                       {5, 6},
1279
                       {6, 6},
1280
                   }},
1281
           }},
8✔
1282
   };
5✔
1283

1284
   const maps::MapData map_data({.borders = borders});
1✔
1285

1286
   const Buildings buildings = ImportBuildings(states,
1287
       coastal_provinces,
1288
       map_data,
1289
       commonItems::ModFilesystem{"test_files/Hoi4worldMapBuildingsCreatorTests/DefaultsToNoBuildings", {}});
1✔
1290

1291
   EXPECT_THAT(buildings.GetBuildings(),
6✔
1292
       testing::IsSupersetOf(
1293
           {Building({.state_id = 1,
1294
                .type = "coastal_bunker",
1295
                .position = {.x_coordinate = 2.0, .y_coordinate = 11.0, .z_coordinate = 1.0, .rotation = 0.0}}),
1296
               Building({.state_id = 1,
1297
                   .type = "coastal_bunker",
1298
                   .position = {.x_coordinate = 5.0, .y_coordinate = 11.0, .z_coordinate = 1.0, .rotation = 0.0}}),
1299
               Building({.state_id = 1,
1300
                   .type = "coastal_bunker",
1301
                   .position = {.x_coordinate = 2.0, .y_coordinate = 11.0, .z_coordinate = 6.0, .rotation = 0.0}}),
1302
               Building({.state_id = 1,
1303
                   .type = "coastal_bunker",
1304
                   .position = {.x_coordinate = 5.0, .y_coordinate = 11.0, .z_coordinate = 6.0, .rotation = 0.0}})}));
1✔
1305
}
31✔
1306

1307

1308
TEST(Hoi4worldMapBuildingsCreatorTests, NoCoastalBunkersWhenNoCoastalProvinces)
4✔
1309
{
1310
   const States states({.states = {State(1, {})},
1311
       .province_to_state_id_map = {
1312
           {1, 1},
1313
           {2, 1},
1314
           {3, 1},
1315
           {4, 1},
1316
       }});
2✔
1317

1318
   const std::map<std::string, maps::BordersWith> borders = {
1319
       {"1",
1320
           maps::BordersWith{
6✔
1321
               {"2",
UNCOV
1322
                   maps::BorderPoints{
×
1323
                       {3, 1},
1324
                       {3, 2},
1325
                       {3, 3},
1326
                   }},
1327
               {"3",
UNCOV
1328
                   maps::BorderPoints{
×
1329
                       {1, 3},
1330
                       {2, 3},
1331
                       {3, 3},
1332
                   }},
1333
               {"5",
1334
                   maps::BorderPoints{
1✔
1335
                       {1, 0},
1336
                       {2, 0},
1337
                       {3, 0},
1338
                   }},
1339
           }},
8✔
1340
       {"2",
1341
           maps::BordersWith{
6✔
1342
               {"1",
UNCOV
1343
                   maps::BorderPoints{
×
1344
                       {4, 1},
1345
                       {4, 2},
1346
                       {4, 3},
1347
                   }},
1348
               {"4",
UNCOV
1349
                   maps::BorderPoints{
×
1350
                       {4, 3},
1351
                       {5, 3},
1352
                       {6, 3},
1353
                   }},
1354
               {"6",
1355
                   maps::BorderPoints{
1✔
1356
                       {4, 0},
1357
                       {5, 0},
1358
                       {6, 0},
1359
                   }},
1360
           }},
8✔
1361
       {"3",
1362
           maps::BordersWith{
6✔
1363
               {"1",
UNCOV
1364
                   maps::BorderPoints{
×
1365
                       {1, 4},
1366
                       {2, 4},
1367
                       {3, 4},
1368
                   }},
1369
               {"4",
UNCOV
1370
                   maps::BorderPoints{
×
1371
                       {3, 4},
1372
                       {3, 5},
1373
                       {3, 6},
1374
                   }},
1375
               {"7",
1376
                   maps::BorderPoints{
1✔
1377
                       {1, 7},
1378
                       {2, 7},
1379
                       {3, 7},
1380
                   }},
1381
           }},
8✔
1382
       {"4",
1383
           maps::BordersWith{
6✔
1384
               {"2",
UNCOV
1385
                   maps::BorderPoints{
×
1386
                       {4, 4},
1387
                       {5, 4},
1388
                       {6, 4},
1389
                   }},
1390
               {"3",
UNCOV
1391
                   maps::BorderPoints{
×
1392
                       {4, 4},
1393
                       {4, 5},
1394
                       {4, 6},
1395
                   }},
1396
               {"8",
1397
                   maps::BorderPoints{
1✔
1398
                       {4, 7},
1399
                       {5, 7},
1400
                       {6, 7},
1401
                   }},
1402
           }},
8✔
1403
   };
5✔
1404

1405
   const maps::MapData map_data({.borders = borders});
1✔
1406

1407
   const Buildings buildings = ImportBuildings(states,
1408
       CoastalProvinces(),
2✔
1409
       map_data,
1410
       commonItems::ModFilesystem{"test_files/Hoi4worldMapBuildingsCreatorTests/DefaultsToNoBuildings", {}});
3✔
1411

1412
   for (const auto& building: buildings.GetBuildings())
5✔
1413
   {
1414
      EXPECT_NE(building.GetType(), "coastal_bunker");
4✔
1415
   }
1416
}
20✔
1417

1418

1419
TEST(Hoi4worldMapBuildingsCreatorTests, NoCoastalBunkersWhenCoastalProvincesNotInStates)
4✔
1420
{
1421
   std::stringstream log;
1✔
1422
   std::streambuf* cout_buffer = std::cout.rdbuf();
1✔
1423
   std::cout.rdbuf(log.rdbuf());
1✔
1424

1425
   const States states({.states = {State(1, {})}, .province_to_state_id_map = {}});
2✔
1426

1427
   const CoastalProvinces coastal_provinces({{1, {5}}, {2, {6}}, {3, {7}}, {4, {8}}});
13✔
1428

1429
   const std::map<std::string, maps::BordersWith> borders = {
1430
       {"1",
1431
           maps::BordersWith{
6✔
1432
               {"2",
UNCOV
1433
                   maps::BorderPoints{
×
1434
                       {3, 1},
1435
                       {3, 2},
1436
                       {3, 3},
1437
                   }},
1438
               {"3",
UNCOV
1439
                   maps::BorderPoints{
×
1440
                       {1, 3},
1441
                       {2, 3},
1442
                       {3, 3},
1443
                   }},
1444
               {"5",
1445
                   maps::BorderPoints{
1✔
1446
                       {1, 0},
1447
                       {2, 0},
1448
                       {3, 0},
1449
                   }},
1450
           }},
8✔
1451
       {"2",
1452
           maps::BordersWith{
6✔
1453
               {"1",
UNCOV
1454
                   maps::BorderPoints{
×
1455
                       {4, 1},
1456
                       {4, 2},
1457
                       {4, 3},
1458
                   }},
1459
               {"4",
UNCOV
1460
                   maps::BorderPoints{
×
1461
                       {4, 3},
1462
                       {5, 3},
1463
                       {6, 3},
1464
                   }},
1465
               {"6",
1466
                   maps::BorderPoints{
1✔
1467
                       {4, 0},
1468
                       {5, 0},
1469
                       {6, 0},
1470
                   }},
1471
           }},
8✔
1472
       {"3",
1473
           maps::BordersWith{
6✔
1474
               {"1",
UNCOV
1475
                   maps::BorderPoints{
×
1476
                       {1, 4},
1477
                       {2, 4},
1478
                       {3, 4},
1479
                   }},
1480
               {"4",
UNCOV
1481
                   maps::BorderPoints{
×
1482
                       {3, 4},
1483
                       {3, 5},
1484
                       {3, 6},
1485
                   }},
1486
               {"7",
1487
                   maps::BorderPoints{
1✔
1488
                       {1, 7},
1489
                       {2, 7},
1490
                       {3, 7},
1491
                   }},
1492
           }},
8✔
1493
       {"4",
1494
           maps::BordersWith{
6✔
1495
               {"2",
UNCOV
1496
                   maps::BorderPoints{
×
1497
                       {4, 4},
1498
                       {5, 4},
1499
                       {6, 4},
1500
                   }},
1501
               {"3",
UNCOV
1502
                   maps::BorderPoints{
×
1503
                       {4, 4},
1504
                       {4, 5},
1505
                       {4, 6},
1506
                   }},
1507
               {"8",
1508
                   maps::BorderPoints{
1✔
1509
                       {4, 7},
1510
                       {5, 7},
1511
                       {6, 7},
1512
                   }},
1513
           }},
8✔
1514
   };
5✔
1515

1516
   const maps::MapData map_data({.borders = borders});
1✔
1517

1518
   const Buildings buildings = ImportBuildings(states,
1519
       coastal_provinces,
1520
       map_data,
1521
       commonItems::ModFilesystem{"test_files/Hoi4worldMapBuildingsCreatorTests/DefaultsToNoBuildings", {}});
1✔
1522

1523
   std::cout.rdbuf(cout_buffer);
1✔
1524

1525
   EXPECT_TRUE(buildings.GetBuildings().empty());
1✔
1526
   EXPECT_THAT(log.str(), testing::HasSubstr("[WARNING] Could not find state for province 1. Coastal bunker not set."));
1✔
1527
   EXPECT_THAT(log.str(), testing::HasSubstr("[WARNING] Could not find state for province 2. Coastal bunker not set."));
1✔
1528
   EXPECT_THAT(log.str(), testing::HasSubstr("[WARNING] Could not find state for province 3. Coastal bunker not set."));
1✔
1529
   EXPECT_THAT(log.str(), testing::HasSubstr("[WARNING] Could not find state for province 4. Coastal bunker not set."));
1✔
1530
}
29✔
1531

1532

1533
TEST(Hoi4worldMapBuildingsCreatorTests, CoastalBunkersNotPlacedInProvincesWithNoBorders)
4✔
1534
{
1535
   std::stringstream log;
1✔
1536
   std::streambuf* cout_buffer = std::cout.rdbuf();
1✔
1537
   std::cout.rdbuf(log.rdbuf());
1✔
1538

1539
   const Buildings buildings = ImportBuildings(States({.states = {State(1, {.provinces = {1, 2, 3, 4}})},
1✔
1540
                                                   .province_to_state_id_map =
1541
                                                       {
1542
                                                           {1, 1},
1543
                                                           {2, 1},
1544
                                                           {3, 1},
1545
                                                           {4, 1},
1546
                                                       }}),
1✔
1547
       CoastalProvinces({{1, {5}}, {2, {6}}, {3, {7}}, {4, {8}}}),
14✔
1548
       maps::MapData(),
1✔
1549
       commonItems::ModFilesystem{"test_files/Hoi4worldMapBuildingsCreatorTests/DefaultsToNoBuildings", {}});
2✔
1550

1551
   std::cout.rdbuf(cout_buffer);
1✔
1552

1553
   EXPECT_TRUE(buildings.GetBuildings().empty());
1✔
1554
   EXPECT_THAT(log.str(),
1✔
1555
       testing::HasSubstr(
1556
           "[WARNING] Province 1 did not have any border points. Coastal bunkers not fully set in state 1."));
1✔
1557
   EXPECT_THAT(log.str(),
1✔
1558
       testing::HasSubstr(
1559
           "[WARNING] Province 2 did not have any border points. Coastal bunkers not fully set in state 1."));
1✔
1560
   EXPECT_THAT(log.str(),
1✔
1561
       testing::HasSubstr(
1562
           "[WARNING] Province 3 did not have any border points. Coastal bunkers not fully set in state 1."));
1✔
1563
   EXPECT_THAT(log.str(),
1✔
1564
       testing::HasSubstr(
1565
           "[WARNING] Province 4 did not have any border points. Coastal bunkers not fully set in state 1."));
1✔
1566
}
14✔
1567

1568

1569
TEST(Hoi4worldMapBuildingsCreatorTests, CoastalBunkerPlacementOverridenByDefaultLocations)
4✔
1570
{
1571
   const States states({.states = {State(1, {.provinces = {1, 2, 3, 4, 5}})},
1572
       .province_to_state_id_map = {
1573
           {1, 1},
1574
           {2, 1},
1575
           {3, 1},
1576
           {4, 1},
1577
           {5, 1},
1578
       }});
2✔
1579

1580
   const CoastalProvinces coastal_provinces({{1, {5}}, {2, {6}}, {3, {7}}, {4, {8}}});
13✔
1581

1582
   const std::map<std::string, maps::BordersWith> borders = {
1583
       {"1",
1584
           maps::BordersWith{
6✔
1585
               {"2",
UNCOV
1586
                   maps::BorderPoints{
×
1587
                       {3, 1},
1588
                       {3, 2},
1589
                       {3, 3},
1590
                   }},
1591
               {"3",
UNCOV
1592
                   maps::BorderPoints{
×
1593
                       {1, 3},
1594
                       {2, 3},
1595
                       {3, 3},
1596
                   }},
1597
               {"5",
1598
                   maps::BorderPoints{
1✔
1599
                       {1, 1},
1600
                       {2, 1},
1601
                       {3, 1},
1602
                   }},
1603
           }},
8✔
1604
       {"2",
1605
           maps::BordersWith{
6✔
1606
               {"1",
UNCOV
1607
                   maps::BorderPoints{
×
1608
                       {4, 1},
1609
                       {4, 2},
1610
                       {4, 3},
1611
                   }},
1612
               {"4",
UNCOV
1613
                   maps::BorderPoints{
×
1614
                       {4, 3},
1615
                       {5, 3},
1616
                       {6, 3},
1617
                   }},
1618
               {"6",
1619
                   maps::BorderPoints{
1✔
1620
                       {4, 1},
1621
                       {5, 1},
1622
                       {6, 1},
1623
                   }},
1624
           }},
8✔
1625
       {"3",
1626
           maps::BordersWith{
6✔
1627
               {"1",
UNCOV
1628
                   maps::BorderPoints{
×
1629
                       {1, 4},
1630
                       {2, 4},
1631
                       {3, 4},
1632
                   }},
1633
               {"4",
UNCOV
1634
                   maps::BorderPoints{
×
1635
                       {3, 4},
1636
                       {3, 5},
1637
                       {3, 6},
1638
                   }},
1639
               {"7",
1640
                   maps::BorderPoints{
1✔
1641
                       {1, 6},
1642
                       {2, 6},
1643
                       {3, 6},
1644
                   }},
1645
           }},
8✔
1646
       {"4",
1647
           maps::BordersWith{
6✔
1648
               {"2",
UNCOV
1649
                   maps::BorderPoints{
×
1650
                       {4, 4},
1651
                       {5, 4},
1652
                       {6, 4},
1653
                   }},
1654
               {"3",
UNCOV
1655
                   maps::BorderPoints{
×
1656
                       {4, 4},
1657
                       {4, 5},
1658
                       {4, 6},
1659
                   }},
1660
               {"8",
1661
                   maps::BorderPoints{
1✔
1662
                       {4, 6},
1663
                       {5, 6},
1664
                       {6, 6},
1665
                   }},
1666
           }},
8✔
1667
   };
5✔
1668

1669
   const maps::MapData map_data({.borders = borders,
1670
       .points_to_provinces = {
1671
           {{2, 1}, "1"},
1672
           {{5, 1}, "2"},
1673
           {{2, 6}, "3"},
1674
           {{5, 6}, "4"},
1675
       }});
13✔
1676

1677
   const Buildings buildings = ImportBuildings(states,
1678
       coastal_provinces,
1679
       map_data,
1680
       commonItems::ModFilesystem{"test_files/Hoi4worldMapBuildingsCreatorTests/DefaultsExist", {}});
1✔
1681

1682
   EXPECT_THAT(buildings.GetBuildings(),
6✔
1683
       testing::IsSupersetOf(
1684
           {Building({.state_id = 1,
1685
                .type = "coastal_bunker",
1686
                .position = {.x_coordinate = 2.0, .y_coordinate = 6.0, .z_coordinate = 1.0, .rotation = 90.0}}),
1687
               Building({.state_id = 1,
1688
                   .type = "coastal_bunker",
1689
                   .position = {.x_coordinate = 5.0, .y_coordinate = 6.0, .z_coordinate = 1.0, .rotation = 180.0}}),
1690
               Building({.state_id = 1,
1691
                   .type = "coastal_bunker",
1692
                   .position = {.x_coordinate = 2.0, .y_coordinate = 6.0, .z_coordinate = 6.0, .rotation = 270.0}}),
1693
               Building({.state_id = 1,
1694
                   .type = "coastal_bunker",
1695
                   .position = {.x_coordinate = 5.0, .y_coordinate = 6.0, .z_coordinate = 6.0, .rotation = 359.0}})}));
1✔
1696
}
44✔
1697

1698

1699
TEST(Hoi4worldMapBuildingsCreatorTests, CoastalBunkerPlacedInCenterOfSeaBorderForAllProvincesOfStateIfDefaultNotInState)
4✔
1700
{
1701
   const States states({.states = {State(1, {.provinces = {1, 2, 3, 4, 5}})},
1702
       .province_to_state_id_map = {
1703
           {1, 1},
1704
           {2, 1},
1705
           {3, 1},
1706
           {4, 1},
1707
           {5, 1},
1708
       }});
2✔
1709

1710
   const CoastalProvinces coastal_provinces({{1, {5}}, {2, {6}}, {3, {7}}, {4, {8}}});
13✔
1711

1712
   const std::map<std::string, maps::BordersWith> borders = {
1713
       {"1",
1714
           maps::BordersWith{
6✔
1715
               {"2",
UNCOV
1716
                   maps::BorderPoints{
×
1717
                       {3, 1},
1718
                       {3, 2},
1719
                       {3, 3},
1720
                   }},
1721
               {"3",
UNCOV
1722
                   maps::BorderPoints{
×
1723
                       {1, 3},
1724
                       {2, 3},
1725
                       {3, 3},
1726
                   }},
1727
               {"5",
1728
                   maps::BorderPoints{
1✔
1729
                       {1, 1},
1730
                       {2, 1},
1731
                       {3, 1},
1732
                   }},
1733
           }},
8✔
1734
       {"2",
1735
           maps::BordersWith{
6✔
1736
               {"1",
UNCOV
1737
                   maps::BorderPoints{
×
1738
                       {4, 1},
1739
                       {4, 2},
1740
                       {4, 3},
1741
                   }},
1742
               {"4",
UNCOV
1743
                   maps::BorderPoints{
×
1744
                       {4, 3},
1745
                       {5, 3},
1746
                       {6, 3},
1747
                   }},
1748
               {"6",
1749
                   maps::BorderPoints{
1✔
1750
                       {4, 1},
1751
                       {5, 1},
1752
                       {6, 1},
1753
                   }},
1754
           }},
8✔
1755
       {"3",
1756
           maps::BordersWith{
6✔
1757
               {"1",
UNCOV
1758
                   maps::BorderPoints{
×
1759
                       {1, 4},
1760
                       {2, 4},
1761
                       {3, 4},
1762
                   }},
1763
               {"4",
UNCOV
1764
                   maps::BorderPoints{
×
1765
                       {3, 4},
1766
                       {3, 5},
1767
                       {3, 6},
1768
                   }},
1769
               {"7",
1770
                   maps::BorderPoints{
1✔
1771
                       {1, 6},
1772
                       {2, 6},
1773
                       {3, 6},
1774
                   }},
1775
           }},
8✔
1776
       {"4",
1777
           maps::BordersWith{
6✔
1778
               {"2",
UNCOV
1779
                   maps::BorderPoints{
×
1780
                       {4, 4},
1781
                       {5, 4},
1782
                       {6, 4},
1783
                   }},
1784
               {"3",
UNCOV
1785
                   maps::BorderPoints{
×
1786
                       {4, 4},
1787
                       {4, 5},
1788
                       {4, 6},
1789
                   }},
1790
               {"8",
1791
                   maps::BorderPoints{
1✔
1792
                       {4, 6},
1793
                       {5, 6},
1794
                       {6, 6},
1795
                   }},
1796
           }},
8✔
1797
   };
5✔
1798

1799
   const maps::MapData map_data({.borders = borders});
1✔
1800

1801
   const Buildings buildings = ImportBuildings(states,
1802
       coastal_provinces,
1803
       map_data,
1804
       commonItems::ModFilesystem{"test_files/Hoi4worldMapBuildingsCreatorTests/DefaultsExist", {}});
1✔
1805

1806
   EXPECT_THAT(buildings.GetBuildings(),
6✔
1807
       testing::IsSupersetOf(
1808
           {Building({.state_id = 1,
1809
                .type = "coastal_bunker",
1810
                .position = {.x_coordinate = 2.0, .y_coordinate = 11.0, .z_coordinate = 1.0, .rotation = 0.0}}),
1811
               Building({.state_id = 1,
1812
                   .type = "coastal_bunker",
1813
                   .position = {.x_coordinate = 5.0, .y_coordinate = 11.0, .z_coordinate = 1.0, .rotation = 0.0}}),
1814
               Building({.state_id = 1,
1815
                   .type = "coastal_bunker",
1816
                   .position = {.x_coordinate = 2.0, .y_coordinate = 11.0, .z_coordinate = 6.0, .rotation = 0.0}}),
1817
               Building({.state_id = 1,
1818
                   .type = "coastal_bunker",
1819
                   .position = {.x_coordinate = 5.0, .y_coordinate = 11.0, .z_coordinate = 6.0, .rotation = 0.0}})}));
1✔
1820
}
31✔
1821

1822

1823
TEST(Hoi4worldMapBuildingsCreatorTests, DockyardPlacedInSeaBorderCenterOfFirstCoastalProvinceOfState)
4✔
1824
{
1825
   const States states({.states = {State(1, {.provinces = {1, 2, 3, 4}})},
1826
       .province_to_state_id_map = {
1827
           {1, 1},
1828
           {2, 1},
1829
           {3, 1},
1830
           {4, 1},
1831
       }});
2✔
1832

1833
   const CoastalProvinces coastal_provinces({{1, {5}}, {2, {6}}, {3, {7}}, {4, {8}}});
13✔
1834

1835
   const std::map<std::string, maps::BordersWith> borders{
1836
       {"1",
1837
           maps::BordersWith{
6✔
1838
               {"2",
UNCOV
1839
                   maps::BorderPoints{
×
1840
                       {3, 1},
1841
                       {3, 2},
1842
                       {3, 3},
1843
                   }},
1844
               {"3",
UNCOV
1845
                   maps::BorderPoints{
×
1846
                       {1, 3},
1847
                       {2, 3},
1848
                       {3, 3},
1849
                   }},
1850
               {"5",
1851
                   maps::BorderPoints{
1✔
1852
                       {1, 0},
1853
                       {2, 0},
1854
                       {3, 0},
1855
                   }},
1856
           }},
8✔
1857
       {"2",
1858
           maps::BordersWith{
6✔
1859
               {"1",
UNCOV
1860
                   maps::BorderPoints{
×
1861
                       {4, 1},
1862
                       {4, 2},
1863
                       {4, 3},
1864
                   }},
1865
               {"4",
UNCOV
1866
                   maps::BorderPoints{
×
1867
                       {4, 3},
1868
                       {5, 3},
1869
                       {6, 3},
1870
                   }},
1871
               {"6",
1872
                   maps::BorderPoints{
1✔
1873
                       {4, 0},
1874
                       {5, 0},
1875
                       {6, 0},
1876
                   }},
1877
           }},
8✔
1878
       {"3",
1879
           maps::BordersWith{
6✔
1880
               {"1",
UNCOV
1881
                   maps::BorderPoints{
×
1882
                       {1, 4},
1883
                       {2, 4},
1884
                       {3, 4},
1885
                   }},
1886
               {"4",
UNCOV
1887
                   maps::BorderPoints{
×
1888
                       {3, 4},
1889
                       {3, 5},
1890
                       {3, 6},
1891
                   }},
1892
               {"7",
1893
                   maps::BorderPoints{
1✔
1894
                       {1, 7},
1895
                       {2, 7},
1896
                       {3, 7},
1897
                   }},
1898
           }},
8✔
1899
       {"4",
1900
           maps::BordersWith{
6✔
1901
               {"2",
UNCOV
1902
                   maps::BorderPoints{
×
1903
                       {4, 4},
1904
                       {5, 4},
1905
                       {6, 4},
1906
                   }},
1907
               {"3",
UNCOV
1908
                   maps::BorderPoints{
×
1909
                       {4, 4},
1910
                       {4, 5},
1911
                       {4, 6},
1912
                   }},
1913
               {"8",
1914
                   maps::BorderPoints{
1✔
1915
                       {4, 7},
1916
                       {5, 7},
1917
                       {6, 7},
1918
                   }},
1919
           }},
8✔
1920
   };
5✔
1921

1922
   const maps::MapData map_data({.borders = borders});
1✔
1923

1924
   const Buildings buildings = ImportBuildings(states,
1925
       coastal_provinces,
1926
       map_data,
1927
       commonItems::ModFilesystem{"test_files/Hoi4worldMapBuildingsCreatorTests/DefaultsToNoBuildings", {}});
1✔
1928

1929
   EXPECT_THAT(buildings.GetBuildings(),
3✔
1930
       testing::IsSupersetOf({Building({.state_id = 1,
1931
           .type = "dockyard",
1932
           .position = {.x_coordinate = 2.0, .y_coordinate = 11.0, .z_coordinate = 0.0, .rotation = 0.0}})}));
1✔
1933
}
31✔
1934

1935

1936
TEST(Hoi4worldMapBuildingsCreatorTests, NoDockyardInStateWithNoCoastalProvinces)
4✔
1937
{
1938
   const States states({.states = {State(1, {.provinces = {1, 2, 3, 4}})},
1939
       .province_to_state_id_map = {
1940
           {1, 1},
1941
           {2, 1},
1942
           {3, 1},
1943
           {4, 1},
1944
       }});
2✔
1945

1946
   const std::map<std::string, maps::BordersWith> borders = {
1947
       {"1",
1948
           maps::BordersWith{
6✔
1949
               {"2",
UNCOV
1950
                   maps::BorderPoints{
×
1951
                       {3, 1},
1952
                       {3, 2},
1953
                       {3, 3},
1954
                   }},
1955
               {"3",
UNCOV
1956
                   maps::BorderPoints{
×
1957
                       {1, 3},
1958
                       {2, 3},
1959
                       {3, 3},
1960
                   }},
1961
               {"5",
1962
                   maps::BorderPoints{
1✔
1963
                       {1, 0},
1964
                       {2, 0},
1965
                       {3, 0},
1966
                   }},
1967
           }},
8✔
1968
       {"2",
1969
           maps::BordersWith{
6✔
1970
               {"1",
UNCOV
1971
                   maps::BorderPoints{
×
1972
                       {4, 1},
1973
                       {4, 2},
1974
                       {4, 3},
1975
                   }},
1976
               {"4",
UNCOV
1977
                   maps::BorderPoints{
×
1978
                       {4, 3},
1979
                       {5, 3},
1980
                       {6, 3},
1981
                   }},
1982
               {"6",
1983
                   maps::BorderPoints{
1✔
1984
                       {4, 0},
1985
                       {5, 0},
1986
                       {6, 0},
1987
                   }},
1988
           }},
8✔
1989
       {"3",
1990
           maps::BordersWith{
6✔
1991
               {"1",
UNCOV
1992
                   maps::BorderPoints{
×
1993
                       {1, 4},
1994
                       {2, 4},
1995
                       {3, 4},
1996
                   }},
1997
               {"4",
UNCOV
1998
                   maps::BorderPoints{
×
1999
                       {3, 4},
2000
                       {3, 5},
2001
                       {3, 6},
2002
                   }},
2003
               {"7",
2004
                   maps::BorderPoints{
1✔
2005
                       {1, 7},
2006
                       {2, 7},
2007
                       {3, 7},
2008
                   }},
2009
           }},
8✔
2010
       {"4",
2011
           maps::BordersWith{
6✔
2012
               {"2",
UNCOV
2013
                   maps::BorderPoints{
×
2014
                       {4, 4},
2015
                       {5, 4},
2016
                       {6, 4},
2017
                   }},
2018
               {"3",
UNCOV
2019
                   maps::BorderPoints{
×
2020
                       {4, 4},
2021
                       {4, 5},
2022
                       {4, 6},
2023
                   }},
2024
               {"8",
2025
                   maps::BorderPoints{
1✔
2026
                       {4, 7},
2027
                       {5, 7},
2028
                       {6, 7},
2029
                   }},
2030
           }},
8✔
2031
   };
5✔
2032

2033
   const maps::MapData map_data({.borders = borders});
1✔
2034

2035
   const Buildings buildings = ImportBuildings(states,
2036
       CoastalProvinces(),
2✔
2037
       map_data,
2038
       commonItems::ModFilesystem{"test_files/Hoi4worldMapBuildingsCreatorTests/DefaultsToNoBuildings", {}});
3✔
2039

2040
   for (const auto& building: buildings.GetBuildings())
9✔
2041
   {
2042
      EXPECT_NE(building.GetType(), "dockyard");
8✔
2043
   }
2044
}
20✔
2045

2046

2047
TEST(Hoi4worldMapBuildingsCreatorTests, DockyardNotPlacedInProvincesWithNoBorderPoints)
4✔
2048
{
2049
   std::stringstream log;
1✔
2050
   std::streambuf* cout_buffer = std::cout.rdbuf();
1✔
2051
   std::cout.rdbuf(log.rdbuf());
1✔
2052

2053
   const CoastalProvinces coastal_provinces({{1, {5}}, {2, {6}}, {3, {7}}, {4, {8}}});
13✔
2054

2055
   const State state(1, {.provinces = {1, 2, 3, 4}});
1✔
2056

2057
   const std::map<int, int> province_to_state_id_map = {
2058
       {1, 1},
2059
       {2, 1},
2060
       {3, 1},
2061
       {4, 1},
2062
   };
1✔
2063
   const States states({.states = {state}, .province_to_state_id_map = province_to_state_id_map});
2✔
2064

2065
   const std::map<std::string, maps::BordersWith> borders = {
2066
       {"1",
2067
           maps::BordersWith{
5✔
2068
               {"2",
UNCOV
2069
                   maps::BorderPoints{
×
2070
                       {3, 1},
2071
                       {3, 2},
2072
                       {3, 3},
2073
                   }},
2074
               {"3",
2075
                   maps::BorderPoints{
1✔
2076
                       {1, 3},
2077
                       {2, 3},
2078
                       {3, 3},
2079
                   }},
2080
           }},
6✔
2081
       {"2",
2082
           maps::BordersWith{
5✔
2083
               {"1",
UNCOV
2084
                   maps::BorderPoints{
×
2085
                       {4, 1},
2086
                       {4, 2},
2087
                       {4, 3},
2088
                   }},
2089
               {"4",
2090
                   maps::BorderPoints{
1✔
2091
                       {4, 3},
2092
                       {5, 3},
2093
                       {6, 3},
2094
                   }},
2095
           }},
6✔
2096
       {"3",
2097
           maps::BordersWith{
5✔
2098
               {"1",
UNCOV
2099
                   maps::BorderPoints{
×
2100
                       {1, 4},
2101
                       {2, 4},
2102
                       {3, 4},
2103
                   }},
2104
               {"4",
2105
                   maps::BorderPoints{
1✔
2106
                       {3, 4},
2107
                       {3, 5},
2108
                       {3, 6},
2109
                   }},
2110
           }},
6✔
2111
       {"4",
2112
           maps::BordersWith{
5✔
2113
               {"2",
UNCOV
2114
                   maps::BorderPoints{
×
2115
                       {4, 4},
2116
                       {5, 4},
2117
                       {6, 4},
2118
                   }},
2119
               {"3",
2120
                   maps::BorderPoints{
1✔
2121
                       {4, 4},
2122
                       {4, 5},
2123
                       {4, 6},
2124
                   }},
2125
           }},
6✔
2126
   };
5✔
2127

2128
   const maps::MapData map_data({.borders = borders});
1✔
2129

2130
   const commonItems::ModFilesystem mod_filesystem("test_files/Hoi4worldMapBuildingsCreatorTests/DefaultsToNoBuildings",
2131
       {});
1✔
2132

2133
   const Buildings buildings = ImportBuildings(states, coastal_provinces, map_data, mod_filesystem);
1✔
2134

2135
   std::cout.rdbuf(cout_buffer);
1✔
2136

2137
   for (const auto& building: buildings.GetBuildings())
9✔
2138
   {
2139
      EXPECT_NE(building.GetType(), "dockyard");
8✔
2140
   }
2141
   EXPECT_THAT(log.str(),
1✔
2142
       testing::HasSubstr("[WARNING] Province 1 did not have any points. Dockyard may not be set in state 1."));
1✔
2143
   EXPECT_THAT(log.str(),
1✔
2144
       testing::HasSubstr("[WARNING] Province 2 did not have any points. Dockyard may not be set in state 1."));
1✔
2145
   EXPECT_THAT(log.str(),
1✔
2146
       testing::HasSubstr("[WARNING] Province 3 did not have any points. Dockyard may not be set in state 1."));
1✔
2147
   EXPECT_THAT(log.str(),
1✔
2148
       testing::HasSubstr("[WARNING] Province 4 did not have any points. Dockyard may not be set in state 1."));
1✔
2149
}
27✔
2150

2151

2152
TEST(Hoi4worldMapBuildingsCreatorTests, DockyardPlacementOverridenByDefaultLocations)
4✔
2153
{
2154
   const States states({.states = {State(1, {.provinces = {1, 2, 3, 4}})},
2155
       .province_to_state_id_map = {
2156
           {1, 1},
2157
           {2, 1},
2158
           {3, 1},
2159
           {4, 1},
2160
       }});
2✔
2161

2162
   const CoastalProvinces coastal_provinces({{1, {5}}, {2, {6}}, {3, {7}}, {4, {8}}});
13✔
2163

2164
   const std::map<std::string, maps::BordersWith> borders = {
2165
       {"1",
2166
           maps::BordersWith{
6✔
2167
               {"2",
2168
                   maps::BorderPoints{
×
2169
                       {3, 1},
2170
                       {3, 2},
2171
                       {3, 3},
2172
                   }},
2173
               {"3",
UNCOV
2174
                   maps::BorderPoints{
×
2175
                       {1, 3},
2176
                       {2, 3},
2177
                       {3, 3},
2178
                   }},
2179
               {"5",
2180
                   maps::BorderPoints{
1✔
2181
                       {1, 0},
2182
                       {2, 0},
2183
                       {3, 0},
2184
                   }},
2185
           }},
8✔
2186
       {"2",
2187
           maps::BordersWith{
6✔
2188
               {"1",
2189
                   maps::BorderPoints{
×
2190
                       {4, 1},
2191
                       {4, 2},
2192
                       {4, 3},
2193
                   }},
2194
               {"4",
UNCOV
2195
                   maps::BorderPoints{
×
2196
                       {4, 3},
2197
                       {5, 3},
2198
                       {6, 3},
2199
                   }},
2200
               {"6",
2201
                   maps::BorderPoints{
1✔
2202
                       {4, 0},
2203
                       {5, 0},
2204
                       {6, 0},
2205
                   }},
2206
           }},
8✔
2207
       {"3",
2208
           maps::BordersWith{
6✔
2209
               {"1",
2210
                   maps::BorderPoints{
×
2211
                       {1, 4},
2212
                       {2, 4},
2213
                       {3, 4},
2214
                   }},
2215
               {"4",
UNCOV
2216
                   maps::BorderPoints{
×
2217
                       {3, 4},
2218
                       {3, 5},
2219
                       {3, 6},
2220
                   }},
2221
               {"7",
2222
                   maps::BorderPoints{
1✔
2223
                       {1, 7},
2224
                       {2, 7},
2225
                       {3, 7},
2226
                   }},
2227
           }},
8✔
2228
       {"4",
2229
           maps::BordersWith{
6✔
2230
               {"2",
2231
                   maps::BorderPoints{
×
2232
                       {4, 4},
2233
                       {5, 4},
2234
                       {6, 4},
2235
                   }},
2236
               {"3",
UNCOV
2237
                   maps::BorderPoints{
×
2238
                       {4, 4},
2239
                       {4, 5},
2240
                       {4, 6},
2241
                   }},
2242
               {"8",
2243
                   maps::BorderPoints{
1✔
2244
                       {4, 7},
2245
                       {5, 7},
2246
                       {6, 7},
2247
                   }},
2248
           }},
8✔
2249
   };
5✔
2250

2251
   const maps::MapData map_data({.borders = borders,
2252
       .points_to_provinces = {
2253
           {{2, 1}, "1"},
2254
       }});
4✔
2255

2256
   const Buildings buildings = ImportBuildings(states,
2257
       coastal_provinces,
2258
       map_data,
2259
       commonItems::ModFilesystem{"test_files/Hoi4worldMapBuildingsCreatorTests/DefaultsExist", {}});
1✔
2260

2261
   EXPECT_THAT(buildings.GetBuildings(),
3✔
2262
       testing::IsSupersetOf({Building({.state_id = 1,
2263
           .type = "dockyard",
2264
           .position = {.x_coordinate = 2.0, .y_coordinate = 6.0, .z_coordinate = 1.0, .rotation = 90.0}})}));
1✔
2265
}
35✔
2266

2267

2268
TEST(Hoi4worldMapBuildingsCreatorTests, DockyardPlacedInSeaBorderCenterOfFirstCoastalProvinceOfStateIfDefaultNotInState)
4✔
2269
{
2270
   States states({.states = {State(1, {.provinces = {1, 2, 3, 4}})},
2271
       .province_to_state_id_map = {
2272
           {1, 1},
2273
           {2, 1},
2274
           {3, 1},
2275
           {4, 1},
2276
       }});
2✔
2277

2278
   CoastalProvinces coastal_provinces({{1, {5}}, {2, {6}}, {3, {7}}, {4, {8}}});
13✔
2279

2280
   std::map<std::string, maps::BordersWith> borders = {
2281
       {"1",
2282
           maps::BordersWith{
6✔
2283
               {"2",
2284
                   maps::BorderPoints{
×
2285
                       {3, 1},
2286
                       {3, 2},
2287
                       {3, 3},
2288
                   }},
2289
               {"3",
UNCOV
2290
                   maps::BorderPoints{
×
2291
                       {1, 3},
2292
                       {2, 3},
2293
                       {3, 3},
2294
                   }},
2295
               {"5",
2296
                   maps::BorderPoints{
1✔
2297
                       {1, 0},
2298
                       {2, 0},
2299
                       {3, 0},
2300
                   }},
2301
           }},
8✔
2302
       {"2",
2303
           maps::BordersWith{
6✔
2304
               {"1",
2305
                   maps::BorderPoints{
×
2306
                       {4, 1},
2307
                       {4, 2},
2308
                       {4, 3},
2309
                   }},
2310
               {"4",
UNCOV
2311
                   maps::BorderPoints{
×
2312
                       {4, 3},
2313
                       {5, 3},
2314
                       {6, 3},
2315
                   }},
2316
               {"6",
2317
                   maps::BorderPoints{
1✔
2318
                       {4, 0},
2319
                       {5, 0},
2320
                       {6, 0},
2321
                   }},
2322
           }},
8✔
2323
       {"3",
2324
           maps::BordersWith{
6✔
2325
               {"1",
2326
                   maps::BorderPoints{
×
2327
                       {1, 4},
2328
                       {2, 4},
2329
                       {3, 4},
2330
                   }},
2331
               {"4",
UNCOV
2332
                   maps::BorderPoints{
×
2333
                       {3, 4},
2334
                       {3, 5},
2335
                       {3, 6},
2336
                   }},
2337
               {"7",
2338
                   maps::BorderPoints{
1✔
2339
                       {1, 7},
2340
                       {2, 7},
2341
                       {3, 7},
2342
                   }},
2343
           }},
8✔
2344
       {"4",
2345
           maps::BordersWith{
6✔
2346
               {"2",
2347
                   maps::BorderPoints{
×
2348
                       {4, 4},
2349
                       {5, 4},
2350
                       {6, 4},
2351
                   }},
2352
               {"3",
UNCOV
2353
                   maps::BorderPoints{
×
2354
                       {4, 4},
2355
                       {4, 5},
2356
                       {4, 6},
2357
                   }},
2358
               {"8",
2359
                   maps::BorderPoints{
1✔
2360
                       {4, 7},
2361
                       {5, 7},
2362
                       {6, 7},
2363
                   }},
2364
           }},
8✔
2365
   };
5✔
2366

2367
   const maps::MapData map_data({.borders = borders});
1✔
2368

2369
   const Buildings buildings = ImportBuildings(states,
2370
       coastal_provinces,
2371
       map_data,
2372
       commonItems::ModFilesystem{"test_files/Hoi4worldMapBuildingsCreatorTests/DefaultsToNoBuildings", {}});
1✔
2373

2374
   EXPECT_THAT(buildings.GetBuildings(),
3✔
2375
       testing::IsSupersetOf({Building({.state_id = 1,
2376
           .type = "dockyard",
2377
           .position = {.x_coordinate = 2.0, .y_coordinate = 11.0, .z_coordinate = 0.0, .rotation = 0.0}})}));
1✔
2378
}
31✔
2379

2380

2381
TEST(Hoi4worldMapBuildingsCreatorTests, FloatingHarborsPlacedInSeaBorderCenterOfFirstCoastalProvinceOfState)
4✔
2382
{
2383
   const States states({.states = {State(1, {.provinces = {1, 2, 3, 4}})},
2384
       .province_to_state_id_map = {
2385
           {1, 1},
2386
           {2, 1},
2387
           {3, 1},
2388
           {4, 1},
2389
       }});
2✔
2390

2391
   const CoastalProvinces coastal_provinces({{1, {5}}, {2, {6}}, {3, {7}}, {4, {8}}});
13✔
2392

2393
   const std::map<std::string, maps::BordersWith> borders = {
2394
       {"5",
2395
           maps::BordersWith{
4✔
2396
               {"1",
2397
                   maps::BorderPoints{
1✔
2398
                       {1, 0},
2399
                       {2, 0},
2400
                       {3, 0},
2401
                   }},
2402
           }},
4✔
2403
       {"6",
2404
           maps::BordersWith{
4✔
2405
               {"1",
2406
                   maps::BorderPoints{
1✔
2407
                       {4, 0},
2408
                       {5, 0},
2409
                       {6, 0},
2410
                   }},
2411
           }},
4✔
2412
       {"7",
2413
           maps::BordersWith{
4✔
2414
               {"1",
2415
                   maps::BorderPoints{
1✔
2416
                       {1, 7},
2417
                       {2, 7},
2418
                       {3, 7},
2419
                   }},
2420
           }},
4✔
2421
       {"8",
2422
           maps::BordersWith{
4✔
2423
               {"1",
2424
                   maps::BorderPoints{
1✔
2425
                       {4, 7},
2426
                       {5, 7},
2427
                       {6, 7},
2428
                   }},
2429
           }},
4✔
2430
   };
5✔
2431

2432
   const maps::MapData map_data({.borders = borders});
1✔
2433

2434
   const Buildings buildings = ImportBuildings(states,
2435
       coastal_provinces,
2436
       map_data,
2437
       commonItems::ModFilesystem{"test_files/Hoi4worldMapBuildingsCreatorTests/DefaultsToNoBuildings", {}});
1✔
2438

2439
   EXPECT_THAT(buildings.GetBuildings(),
3✔
2440
       testing::IsSupersetOf({Building({.state_id = 1,
2441
           .type = "floating_harbor",
2442
           .position = {.x_coordinate = 2.0, .y_coordinate = 11.0, .z_coordinate = 0.0, .rotation = 0.0},
2443
           .connecting_sea_province = 1})}));
1✔
2444
}
23✔
2445

2446

2447
TEST(Hoi4worldMapBuildingsCreatorTests, NoFloatingHarborsInStateWithNoCoastalProvinces)
4✔
2448
{
2449
   const States states({.states = {State(1, {.provinces = {1, 2, 3, 4}})},
2450
       .province_to_state_id_map = {
2451
           {1, 1},
2452
           {2, 1},
2453
           {3, 1},
2454
           {4, 1},
2455
       }});
2✔
2456

2457
   const std::map<std::string, maps::BordersWith> borders = {
2458
       {"5",
2459
           maps::BordersWith{
4✔
2460
               {"1",
2461
                   maps::BorderPoints{
1✔
2462
                       {1, 0},
2463
                       {2, 0},
2464
                       {3, 0},
2465
                   }},
2466
           }},
4✔
2467
       {"6",
2468
           maps::BordersWith{
4✔
2469
               {"1",
2470
                   maps::BorderPoints{
1✔
2471
                       {4, 0},
2472
                       {5, 0},
2473
                       {6, 0},
2474
                   }},
2475
           }},
4✔
2476
       {"7",
2477
           maps::BordersWith{
4✔
2478
               {"1",
2479
                   maps::BorderPoints{
1✔
2480
                       {1, 7},
2481
                       {2, 7},
2482
                       {3, 7},
2483
                   }},
2484
           }},
4✔
2485
       {"8",
2486
           maps::BordersWith{
4✔
2487
               {"1",
2488
                   maps::BorderPoints{
1✔
2489
                       {4, 7},
2490
                       {5, 7},
2491
                       {6, 7},
2492
                   }},
2493
           }},
4✔
2494
   };
5✔
2495

2496
   const maps::MapData map_data({.borders = borders});
1✔
2497

2498
   const Buildings buildings = ImportBuildings(states,
2499
       CoastalProvinces(),
2✔
2500
       map_data,
2501
       commonItems::ModFilesystem{"test_files/Hoi4worldMapBuildingsCreatorTests/DefaultsToNoBuildings", {}});
3✔
2502

2503
   EXPECT_TRUE(buildings.GetBuildings().empty());
1✔
2504
}
12✔
2505

2506

2507
TEST(Hoi4worldMapBuildingsCreatorTests, FloatingHarborsNotPlacedInProvincesWithNoSeaBorders)
4✔
2508
{
2509
   std::stringstream log;
1✔
2510
   std::streambuf* cout_buffer = std::cout.rdbuf();
1✔
2511
   std::cout.rdbuf(log.rdbuf());
1✔
2512

2513
   const Buildings buildings = ImportBuildings(States({.states = {State(1, {.provinces = {1, 2, 3, 4}})},
1✔
2514
                                                   .province_to_state_id_map =
2515
                                                       {
2516
                                                           {1, 1},
2517
                                                           {2, 1},
2518
                                                           {3, 1},
2519
                                                           {4, 1},
2520
                                                       }}),
1✔
2521
       CoastalProvinces({{1, {5}}, {2, {6}}, {3, {7}}, {4, {8}}}),
14✔
2522
       maps::MapData(),
1✔
2523
       commonItems::ModFilesystem{"test_files/Hoi4worldMapBuildingsCreatorTests/DefaultsToNoBuildings", {}});
2✔
2524

2525
   std::cout.rdbuf(cout_buffer);
1✔
2526

2527
   EXPECT_TRUE(buildings.GetBuildings().empty());
1✔
2528
   EXPECT_THAT(log.str(),
1✔
2529
       testing::HasSubstr("[WARNING] Could not find position for province 1. Floating Harbor not set."));
1✔
2530
   EXPECT_THAT(log.str(),
1✔
2531
       testing::HasSubstr("[WARNING] Could not find position for province 2. Floating Harbor not set."));
1✔
2532
   EXPECT_THAT(log.str(),
1✔
2533
       testing::HasSubstr("[WARNING] Could not find position for province 3. Floating Harbor not set."));
1✔
2534
   EXPECT_THAT(log.str(),
1✔
2535
       testing::HasSubstr("[WARNING] Could not find position for province 4. Floating Harbor not set."));
1✔
2536
}
14✔
2537

2538

2539
TEST(Hoi4worldMapBuildingsCreatorTests, FloatingHarborsPlacementOverridenByDefaultLocations)
4✔
2540
{
2541
   const States states({.states = {State(1, {.provinces = {1, 2, 3, 4}})},
2542
       .province_to_state_id_map = {
2543
           {1, 1},
2544
           {2, 1},
2545
           {3, 1},
2546
           {4, 1},
2547
       }});
2✔
2548

2549
   const CoastalProvinces coastal_provinces({{1, {5}}, {2, {6}}, {3, {7}}, {4, {8}}});
13✔
2550

2551
   const std::map<std::string, maps::BordersWith> borders = {
2552
       {"5",
2553
           maps::BordersWith{
4✔
2554
               {"1",
2555
                   maps::BorderPoints{
1✔
2556
                       {1, 0},
2557
                       {2, 0},
2558
                       {3, 0},
2559
                   }},
2560
           }},
4✔
2561
       {"6",
2562
           maps::BordersWith{
4✔
2563
               {"1",
2564
                   maps::BorderPoints{
1✔
2565
                       {4, 0},
2566
                       {5, 0},
2567
                       {6, 0},
2568
                   }},
2569
           }},
4✔
2570
       {"7",
2571
           maps::BordersWith{
4✔
2572
               {"1",
2573
                   maps::BorderPoints{
1✔
2574
                       {1, 7},
2575
                       {2, 7},
2576
                       {3, 7},
2577
                   }},
2578
           }},
4✔
2579
       {"8",
2580
           maps::BordersWith{
4✔
2581
               {"1",
2582
                   maps::BorderPoints{
1✔
2583
                       {4, 7},
2584
                       {5, 7},
2585
                       {6, 7},
2586
                   }},
2587
           }},
4✔
2588
   };
5✔
2589

2590
   const maps::MapData map_data({.borders = borders, .points_to_provinces = {{{2, 0}, "5"}}});
4✔
2591

2592
   const Buildings buildings = ImportBuildings(states,
2593
       coastal_provinces,
2594
       map_data,
2595
       commonItems::ModFilesystem{"test_files/Hoi4worldMapBuildingsCreatorTests/DefaultsExist", {}});
1✔
2596

2597
   EXPECT_THAT(buildings.GetBuildings(),
3✔
2598
       testing::IsSupersetOf({Building({.state_id = 1,
2599
           .type = "floating_harbor",
2600
           .position = {.x_coordinate = 2.0, .y_coordinate = 6.0, .z_coordinate = 0.0, .rotation = 90.0},
2601
           .connecting_sea_province = 1})}));
1✔
2602
}
27✔
2603

2604

2605
TEST(Hoi4worldMapBuildingsCreatorTests,
4✔
2606
    FloatingHarborsPlacedInSeaBorderCenterOfFirstCoastalProvinceOfStateIfDefaultNotInActualProvince)
2607
{
2608
   const States states({.states = {State(1, {.provinces = {1, 2, 3, 4}})},
2609
       .province_to_state_id_map = {
2610
           {1, 1},
2611
           {2, 1},
2612
           {3, 1},
2613
           {4, 1},
2614
       }});
2✔
2615

2616
   const CoastalProvinces coastal_provinces({{1, {5}}, {2, {6}}, {3, {7}}, {4, {8}}});
13✔
2617

2618
   const std::map<std::string, maps::BordersWith> borders = {
2619
       {"5",
2620
           maps::BordersWith{
4✔
2621
               {"1",
2622
                   maps::BorderPoints{
1✔
2623
                       {1, 0},
2624
                       {2, 0},
2625
                       {3, 0},
2626
                   }},
2627
           }},
4✔
2628
       {"6",
2629
           maps::BordersWith{
4✔
2630
               {"1",
2631
                   maps::BorderPoints{
1✔
2632
                       {4, 0},
2633
                       {5, 0},
2634
                       {6, 0},
2635
                   }},
2636
           }},
4✔
2637
       {"7",
2638
           maps::BordersWith{
4✔
2639
               {"1",
2640
                   maps::BorderPoints{
1✔
2641
                       {1, 7},
2642
                       {2, 7},
2643
                       {3, 7},
2644
                   }},
2645
           }},
4✔
2646
       {"8",
2647
           maps::BordersWith{
4✔
2648
               {"1",
2649
                   maps::BorderPoints{
1✔
2650
                       {4, 7},
2651
                       {5, 7},
2652
                       {6, 7},
2653
                   }},
2654
           }},
4✔
2655
   };
5✔
2656

2657
   const Buildings buildings = ImportBuildings(states,
2658
       coastal_provinces,
2659
       maps::MapData({.borders = borders}),
1✔
2660
       commonItems::ModFilesystem{"test_files/Hoi4worldMapBuildingsCreatorTests/DefaultsExist", {}});
3✔
2661

2662
   EXPECT_THAT(buildings.GetBuildings(),
3✔
2663
       testing::IsSupersetOf({Building({.state_id = 1,
2664
           .type = "floating_harbor",
2665
           .position = {.x_coordinate = 2.0, .y_coordinate = 11.0, .z_coordinate = 0.0, .rotation = 0.0},
2666
           .connecting_sea_province = 1})}));
1✔
2667
}
23✔
2668

2669

2670
TEST(Hoi4worldMapBuildingsCreatorTests, IndustrialComplexesPlacedInCenterOfFirstSixProvincesOfState)
4✔
2671
{
2672
   const States states({.states = {State(1, {.provinces = {1, 2, 3, 4, 5, 6, 7}})},
2673
       .province_to_state_id_map = {
2674
           {1, 1},
2675
           {2, 1},
2676
           {3, 1},
2677
           {4, 1},
2678
           {5, 1},
2679
           {6, 1},
2680
           {7, 1},
2681
       }});
2✔
2682

2683
   const std::unordered_map<std::string, maps::ProvincePoints> the_province_points = {
2684
       {"1", maps::ProvincePoints({{1, 1}, {1, 2}, {1, 3}, {2, 1}, {2, 2}, {2, 3}, {3, 1}, {3, 2}, {3, 3}})},
2✔
2685
       {"2", maps::ProvincePoints({{4, 1}, {4, 2}, {4, 3}, {5, 1}, {5, 2}, {5, 3}, {6, 1}, {6, 2}, {6, 3}})},
2✔
2686
       {"3", maps::ProvincePoints({{1, 4}, {1, 5}, {1, 6}, {2, 4}, {2, 5}, {2, 6}, {3, 4}, {3, 5}, {3, 6}})},
2✔
2687
       {"4", maps::ProvincePoints({{4, 4}, {4, 5}, {4, 6}, {5, 4}, {5, 5}, {5, 6}, {6, 4}, {6, 5}, {6, 6}})},
2✔
2688
       {"5", maps::ProvincePoints({{7, 1}, {7, 2}, {7, 3}, {8, 1}, {8, 2}, {8, 3}, {9, 1}, {9, 2}, {9, 3}})},
2✔
2689
       {"6", maps::ProvincePoints({{7, 4}, {7, 5}, {7, 6}, {8, 4}, {8, 5}, {8, 6}, {9, 4}, {9, 5}, {9, 6}})},
2✔
2690
       {"7", maps::ProvincePoints({{1, 7}, {1, 8}, {1, 9}, {2, 7}, {2, 8}, {2, 9}, {3, 7}, {3, 8}, {3, 9}})},
2✔
2691
   };
8✔
2692

2693
   const Buildings buildings = ImportBuildings(states,
2694
       CoastalProvinces(),
2✔
2695
       maps::MapData({.the_province_points = the_province_points}),
1✔
2696
       commonItems::ModFilesystem{"test_files/Hoi4worldMapBuildingsCreatorTests/DefaultsToNoBuildings", {}});
3✔
2697

2698
   EXPECT_THAT(buildings.GetBuildings(),
8✔
2699
       testing::IsSupersetOf(
2700
           {Building({.state_id = 1,
2701
                .type = "industrial_complex",
2702
                .position = {.x_coordinate = 2.0, .y_coordinate = 11.0, .z_coordinate = 2.0, .rotation = 0.0}}),
2703
               Building({.state_id = 1,
2704
                   .type = "industrial_complex",
2705
                   .position = {.x_coordinate = 5.0, .y_coordinate = 11.0, .z_coordinate = 2.0, .rotation = 0.0}}),
2706
               Building({.state_id = 1,
2707
                   .type = "industrial_complex",
2708
                   .position = {.x_coordinate = 2.0, .y_coordinate = 11.0, .z_coordinate = 5.0, .rotation = 0.0}}),
2709
               Building({.state_id = 1,
2710
                   .type = "industrial_complex",
2711
                   .position = {.x_coordinate = 5.0, .y_coordinate = 11.0, .z_coordinate = 5.0, .rotation = 0.0}}),
2712
               Building({.state_id = 1,
2713
                   .type = "industrial_complex",
2714
                   .position = {.x_coordinate = 8.0, .y_coordinate = 11.0, .z_coordinate = 2.0, .rotation = 0.0}}),
2715
               Building({.state_id = 1,
2716
                   .type = "industrial_complex",
2717
                   .position = {.x_coordinate = 8.0, .y_coordinate = 11.0, .z_coordinate = 5.0, .rotation = 0.0}})}));
1✔
2718
}
13✔
2719

2720

2721
TEST(Hoi4worldMapBuildingsCreatorTests, NoIndustrialComplexesInStateWithNoProvinces)
4✔
2722
{
2723
   const Buildings buildings = ImportBuildings(States({.states = {State(1, {})},
1✔
2724
                                                   .province_to_state_id_map =
2725
                                                       {
2726
                                                           {1, 1},
2727
                                                           {2, 1},
2728
                                                           {3, 1},
2729
                                                           {4, 1},
2730
                                                           {5, 1},
2731
                                                           {6, 1},
2732
                                                           {7, 1},
2733
                                                       }}),
1✔
2734
       CoastalProvinces(),
1✔
2735
       maps::MapData(
1✔
2736
           {.the_province_points =
2737
                   {
2738
                       {"1",
2739
                           maps::ProvincePoints(
2✔
2740
                               {{1, 1}, {1, 2}, {1, 3}, {2, 1}, {2, 2}, {2, 3}, {3, 1}, {3, 2}, {3, 3}})},
2741
                       {"2",
2742
                           maps::ProvincePoints(
2✔
2743
                               {{4, 1}, {4, 2}, {4, 3}, {5, 1}, {5, 2}, {5, 3}, {6, 1}, {6, 2}, {6, 3}})},
2744
                       {"3",
2745
                           maps::ProvincePoints(
2✔
2746
                               {{1, 4}, {1, 5}, {1, 6}, {2, 4}, {2, 5}, {2, 6}, {3, 4}, {3, 5}, {3, 6}})},
2747
                       {"4",
2748
                           maps::ProvincePoints(
2✔
2749
                               {{4, 4}, {4, 5}, {4, 6}, {5, 4}, {5, 5}, {5, 6}, {6, 4}, {6, 5}, {6, 6}})},
2750
                       {"5",
2751
                           maps::ProvincePoints(
2✔
2752
                               {{7, 1}, {7, 2}, {7, 3}, {8, 1}, {8, 2}, {8, 3}, {9, 1}, {9, 2}, {9, 3}})},
2753
                       {"6",
2754
                           maps::ProvincePoints(
2✔
2755
                               {{7, 4}, {7, 5}, {7, 6}, {8, 4}, {8, 5}, {8, 6}, {9, 4}, {9, 5}, {9, 6}})},
2756
                       {"7",
2757
                           maps::ProvincePoints(
2✔
2758
                               {{1, 7}, {1, 8}, {1, 9}, {2, 7}, {2, 8}, {2, 9}, {3, 7}, {3, 8}, {3, 9}})},
2759
                   }}),
7✔
2760
       commonItems::ModFilesystem{"test_files/Hoi4worldMapBuildingsCreatorTests/DefaultsToNoBuildings", {}});
2✔
2761

2762
   EXPECT_TRUE(buildings.GetBuildings().empty());
1✔
2763
}
21✔
2764

2765

2766
TEST(Hoi4worldMapBuildingsCreatorTests, IndustrialComplexesNotPlacedInProvincesWithNoPoints)
4✔
2767
{
2768
   std::stringstream log;
1✔
2769
   std::streambuf* cout_buffer = std::cout.rdbuf();
1✔
2770
   std::cout.rdbuf(log.rdbuf());
1✔
2771

2772
   const Buildings buildings = ImportBuildings(States({.states = {State(1, {.provinces = {1, 2, 3, 4, 5, 6, 7}})},
1✔
2773
                                                   .province_to_state_id_map =
2774
                                                       {
2775
                                                           {1, 1},
2776
                                                           {2, 1},
2777
                                                           {3, 1},
2778
                                                           {4, 1},
2779
                                                           {5, 1},
2780
                                                           {6, 1},
2781
                                                           {7, 1},
2782
                                                       }}),
1✔
2783
       CoastalProvinces(),
1✔
2784
       maps::MapData(),
2✔
2785
       commonItems::ModFilesystem{"test_files/Hoi4worldMapBuildingsCreatorTests/DefaultsToNoBuildings", {}});
2✔
2786

2787
   std::cout.rdbuf(cout_buffer);
1✔
2788

2789
   EXPECT_TRUE(buildings.GetBuildings().empty());
1✔
2790
   EXPECT_THAT(log.str(),
1✔
2791
       testing::HasSubstr(
2792
           "[WARNING] Province 1 did not have any points. industrial_complex not fully set in state 1."));
1✔
2793
   EXPECT_THAT(log.str(),
1✔
2794
       testing::HasSubstr(
2795
           "[WARNING] Province 2 did not have any points. industrial_complex not fully set in state 1."));
1✔
2796
   EXPECT_THAT(log.str(),
1✔
2797
       testing::HasSubstr(
2798
           "[WARNING] Province 3 did not have any points. industrial_complex not fully set in state 1."));
1✔
2799
   EXPECT_THAT(log.str(),
1✔
2800
       testing::HasSubstr(
2801
           "[WARNING] Province 4 did not have any points. industrial_complex not fully set in state 1."));
1✔
2802
}
4✔
2803

2804

2805
TEST(Hoi4worldMapBuildingsCreatorTests, IndustrialComplexesPlacementOverridenByDefaultLocations)
4✔
2806
{
2807
   const Buildings
2808
       buildings =
2809
           ImportBuildings(States({.states = {State(1, {.provinces = {1, 2, 3, 4, 5, 6, 7}})},
1✔
2810
                               .province_to_state_id_map =
2811
                                   {
2812
                                       {1, 1},
2813
                                       {2, 1},
2814
                                       {3, 1},
2815
                                       {4, 1},
2816
                                       {5, 1},
2817
                                       {6, 1},
2818
                                       {7, 1},
2819
                                   }}),
1✔
2820
               CoastalProvinces(),
1✔
2821
               maps::MapData(
1✔
2822
                   {.the_province_points =
2823
                           {
2824
                               {"1",
2825
                                   maps::ProvincePoints(
2✔
2826
                                       {{1, 1}, {1, 2}, {1, 3}, {2, 1}, {2, 2}, {2, 3}, {3, 1}, {3, 2}, {3, 3}})},
2827
                               {"2",
2828
                                   maps::ProvincePoints(
2✔
2829
                                       {{4, 1}, {4, 2}, {4, 3}, {5, 1}, {5, 2}, {5, 3}, {6, 1}, {6, 2}, {6, 3}})},
2830
                               {"3",
2831
                                   maps::ProvincePoints(
2✔
2832
                                       {{1, 4}, {1, 5}, {1, 6}, {2, 4}, {2, 5}, {2, 6}, {3, 4}, {3, 5}, {3, 6}})},
2833
                               {"4",
2834
                                   maps::ProvincePoints(
2✔
2835
                                       {{4, 4}, {4, 5}, {4, 6}, {5, 4}, {5, 5}, {5, 6}, {6, 4}, {6, 5}, {6, 6}})},
2836
                               {"5",
2837
                                   maps::ProvincePoints(
2✔
2838
                                       {{7, 1}, {7, 2}, {7, 3}, {8, 1}, {8, 2}, {8, 3}, {9, 1}, {9, 2}, {9, 3}})},
2839
                               {"6",
2840
                                   maps::ProvincePoints(
2✔
2841
                                       {{7, 4}, {7, 5}, {7, 6}, {8, 4}, {8, 5}, {8, 6}, {9, 4}, {9, 5}, {9, 6}})},
2842
                               {"7",
2843
                                   maps::ProvincePoints(
2✔
2844
                                       {{1, 7}, {1, 8}, {1, 9}, {2, 7}, {2, 8}, {2, 9}, {3, 7}, {3, 8}, {3, 9}})},
2845
                           },
2846
                       .points_to_provinces =
2847
                           {
2848
                               {{4, 1}, "2"},
2849
                               {{1, 4}, "3"},
2850
                               {{4, 4}, "4"},
2851
                               {{7, 1}, "5"},
2852
                               {{7, 4}, "6"},
2853
                               {{1, 7}, "7"},
2854
                           }}),
25✔
2855
               commonItems::ModFilesystem{"test_files/Hoi4worldMapBuildingsCreatorTests/DefaultsExist", {}});
2✔
2856

2857
   EXPECT_THAT(buildings.GetBuildings(),
8✔
2858
       testing::IsSupersetOf(
2859
           {Building({.state_id = 1,
2860
                .type = "industrial_complex",
2861
                .position = {.x_coordinate = 4.0, .y_coordinate = 6.0, .z_coordinate = 1.0, .rotation = 45.0}}),
2862
               Building({.state_id = 1,
2863
                   .type = "industrial_complex",
2864
                   .position = {.x_coordinate = 1.0, .y_coordinate = 6.0, .z_coordinate = 4.0, .rotation = 90.0}}),
2865
               Building({.state_id = 1,
2866
                   .type = "industrial_complex",
2867
                   .position = {.x_coordinate = 4.0, .y_coordinate = 6.0, .z_coordinate = 4.0, .rotation = 135.0}}),
2868
               Building({.state_id = 1,
2869
                   .type = "industrial_complex",
2870
                   .position = {.x_coordinate = 7.0, .y_coordinate = 6.0, .z_coordinate = 1.0, .rotation = 180.0}}),
2871
               Building({.state_id = 1,
2872
                   .type = "industrial_complex",
2873
                   .position = {.x_coordinate = 7.0, .y_coordinate = 6.0, .z_coordinate = 4.0, .rotation = 225.0}}),
2874
               Building({.state_id = 1,
2875
                   .type = "industrial_complex",
2876
                   .position = {.x_coordinate = 1.0, .y_coordinate = 6.0, .z_coordinate = 7.0, .rotation = 270.0}})}));
1✔
2877
}
41✔
2878

2879

2880
TEST(Hoi4worldMapBuildingsCreatorTests, IndustrialComplexesPlacedInCenterOfFirstSixProvincesOfStateIfDefaultNotInState)
4✔
2881
{
2882
   const Buildings buildings = ImportBuildings(States({.states = {State(1, {.provinces = {1, 2, 3, 4, 5, 6, 7}})},
1✔
2883
                                                   .province_to_state_id_map =
2884
                                                       {
2885
                                                           {1, 1},
2886
                                                           {2, 1},
2887
                                                           {3, 1},
2888
                                                           {4, 1},
2889
                                                           {5, 1},
2890
                                                           {6, 1},
2891
                                                           {7, 1},
2892
                                                       }}),
1✔
2893
       CoastalProvinces(),
1✔
2894
       maps::MapData(
1✔
2895
           {.the_province_points =
2896
                   {
2897
                       {"1",
2898
                           maps::ProvincePoints(
2✔
2899
                               {{1, 1}, {1, 2}, {1, 3}, {2, 1}, {2, 2}, {2, 3}, {3, 1}, {3, 2}, {3, 3}})},
2900
                       {"2",
2901
                           maps::ProvincePoints(
2✔
2902
                               {{4, 1}, {4, 2}, {4, 3}, {5, 1}, {5, 2}, {5, 3}, {6, 1}, {6, 2}, {6, 3}})},
2903
                       {"3",
2904
                           maps::ProvincePoints(
2✔
2905
                               {{1, 4}, {1, 5}, {1, 6}, {2, 4}, {2, 5}, {2, 6}, {3, 4}, {3, 5}, {3, 6}})},
2906
                       {"4",
2907
                           maps::ProvincePoints(
2✔
2908
                               {{4, 4}, {4, 5}, {4, 6}, {5, 4}, {5, 5}, {5, 6}, {6, 4}, {6, 5}, {6, 6}})},
2909
                       {"5",
2910
                           maps::ProvincePoints(
2✔
2911
                               {{7, 1}, {7, 2}, {7, 3}, {8, 1}, {8, 2}, {8, 3}, {9, 1}, {9, 2}, {9, 3}})},
2912
                       {"6",
2913
                           maps::ProvincePoints(
2✔
2914
                               {{7, 4}, {7, 5}, {7, 6}, {8, 4}, {8, 5}, {8, 6}, {9, 4}, {9, 5}, {9, 6}})},
2915
                       {"7",
2916
                           maps::ProvincePoints(
2✔
2917
                               {{1, 7}, {1, 8}, {1, 9}, {2, 7}, {2, 8}, {2, 9}, {3, 7}, {3, 8}, {3, 9}})},
2918
                   }}),
7✔
2919
       commonItems::ModFilesystem{"test_files/Hoi4worldMapBuildingsCreatorTests/DefaultsExist", {}});
2✔
2920

2921
   EXPECT_THAT(buildings.GetBuildings(),
8✔
2922
       testing::IsSupersetOf(
2923
           {Building({.state_id = 1,
2924
                .type = "arms_factory",
2925
                .position = {.x_coordinate = 2.0, .y_coordinate = 11.0, .z_coordinate = 2.0, .rotation = 0.0}}),
2926
               Building({.state_id = 1,
2927
                   .type = "industrial_complex",
2928
                   .position = {.x_coordinate = 5.0, .y_coordinate = 11.0, .z_coordinate = 2.0, .rotation = 0.0}}),
2929
               Building({.state_id = 1,
2930
                   .type = "industrial_complex",
2931
                   .position = {.x_coordinate = 2.0, .y_coordinate = 11.0, .z_coordinate = 5.0, .rotation = 0.0}}),
2932
               Building({.state_id = 1,
2933
                   .type = "industrial_complex",
2934
                   .position = {.x_coordinate = 5.0, .y_coordinate = 11.0, .z_coordinate = 5.0, .rotation = 0.0}}),
2935
               Building({.state_id = 1,
2936
                   .type = "industrial_complex",
2937
                   .position = {.x_coordinate = 8.0, .y_coordinate = 11.0, .z_coordinate = 2.0, .rotation = 0.0}}),
2938
               Building({.state_id = 1,
2939
                   .type = "industrial_complex",
2940
                   .position = {.x_coordinate = 8.0, .y_coordinate = 11.0, .z_coordinate = 5.0, .rotation = 0.0}})}));
1✔
2941
}
23✔
2942

2943

2944
TEST(Hoi4worldMapBuildingsCreatorTests, NavalBasesPlacedInCenterOfSeaBorderForAllProvincesOfState)
4✔
2945
{
2946
   const States states({.states = {State(1, {.provinces = {1, 2, 3, 4}})},
2947
       .province_to_state_id_map = {
2948
           {1, 1},
2949
           {2, 1},
2950
           {3, 1},
2951
           {4, 1},
2952
       }});
2✔
2953

2954
   const CoastalProvinces coastal_provinces({{1, {5}}, {2, {6}}, {3, {7}}, {4, {8}}});
13✔
2955

2956
   const std::map<std::string, maps::BordersWith> borders = {
2957
       {"1",
2958
           maps::BordersWith{
6✔
2959
               {"2",
2960
                   maps::BorderPoints{
×
2961
                       {3, 1},
2962
                       {3, 2},
2963
                       {3, 3},
2964
                   }},
2965
               {"3",
UNCOV
2966
                   maps::BorderPoints{
×
2967
                       {1, 3},
2968
                       {2, 3},
2969
                       {3, 3},
2970
                   }},
2971
               {"5",
2972
                   maps::BorderPoints{
1✔
2973
                       {1, 1},
2974
                       {2, 1},
2975
                       {3, 1},
2976
                   }},
2977
           }},
8✔
2978
       {"2",
2979
           maps::BordersWith{
6✔
2980
               {"1",
2981
                   maps::BorderPoints{
×
2982
                       {4, 1},
2983
                       {4, 2},
2984
                       {4, 3},
2985
                   }},
2986
               {"4",
UNCOV
2987
                   maps::BorderPoints{
×
2988
                       {4, 3},
2989
                       {5, 3},
2990
                       {6, 3},
2991
                   }},
2992
               {"6",
2993
                   maps::BorderPoints{
1✔
2994
                       {4, 1},
2995
                       {5, 1},
2996
                       {6, 1},
2997
                   }},
2998
           }},
8✔
2999
       {"3",
3000
           maps::BordersWith{
6✔
3001
               {"1",
3002
                   maps::BorderPoints{
×
3003
                       {1, 4},
3004
                       {2, 4},
3005
                       {3, 4},
3006
                   }},
3007
               {"4",
UNCOV
3008
                   maps::BorderPoints{
×
3009
                       {3, 4},
3010
                       {3, 5},
3011
                       {3, 6},
3012
                   }},
3013
               {"7",
3014
                   maps::BorderPoints{
1✔
3015
                       {1, 6},
3016
                       {2, 6},
3017
                       {3, 6},
3018
                   }},
3019
           }},
8✔
3020
       {"4",
3021
           maps::BordersWith{
6✔
3022
               {"2",
3023
                   maps::BorderPoints{
×
3024
                       {4, 4},
3025
                       {5, 4},
3026
                       {6, 4},
3027
                   }},
3028
               {"3",
UNCOV
3029
                   maps::BorderPoints{
×
3030
                       {4, 4},
3031
                       {4, 5},
3032
                       {4, 6},
3033
                   }},
3034
               {"8",
3035
                   maps::BorderPoints{
1✔
3036
                       {4, 6},
3037
                       {5, 6},
3038
                       {6, 6},
3039
                   }},
3040
           }},
8✔
3041
   };
5✔
3042

3043
   const Buildings buildings = ImportBuildings(states,
3044
       coastal_provinces,
3045
       maps::MapData({.borders = borders}),
1✔
3046
       commonItems::ModFilesystem{"test_files/Hoi4worldMapBuildingsCreatorTests/DefaultsToNoBuildings", {}});
3✔
3047

3048
   EXPECT_THAT(buildings.GetBuildings(),
6✔
3049
       testing::IsSupersetOf(
3050
           {Building({.state_id = 1,
3051
                .type = "naval_base",
3052
                .position = {.x_coordinate = 2.0, .y_coordinate = 11.0, .z_coordinate = 1.0, .rotation = 0.0},
3053
                .connecting_sea_province = 5}),
3054
               Building({.state_id = 1,
3055
                   .type = "naval_base",
3056
                   .position = {.x_coordinate = 5.0, .y_coordinate = 11.0, .z_coordinate = 1.0, .rotation = 0.0},
3057
                   .connecting_sea_province = 6}),
3058
               Building({.state_id = 1,
3059
                   .type = "naval_base",
3060
                   .position = {.x_coordinate = 2.0, .y_coordinate = 11.0, .z_coordinate = 6.0, .rotation = 0.0},
3061
                   .connecting_sea_province = 7}),
3062
               Building({.state_id = 1,
3063
                   .type = "naval_base",
3064
                   .position = {.x_coordinate = 5.0, .y_coordinate = 11.0, .z_coordinate = 6.0, .rotation = 0.0},
3065
                   .connecting_sea_province = 8})}));
1✔
3066
}
31✔
3067

3068

3069
TEST(Hoi4worldMapBuildingsCreatorTests, NoNavalBasesWhenNoCoastalProvinces)
4✔
3070
{
3071
   const States states({.states = {State(1, {})},
3072
       .province_to_state_id_map = {
3073
           {1, 1},
3074
           {2, 1},
3075
           {3, 1},
3076
           {4, 1},
3077
       }});
2✔
3078

3079
   const std::map<std::string, maps::BordersWith> borders = {
3080
       {"1",
3081
           maps::BordersWith{
6✔
3082
               {"2",
3083
                   maps::BorderPoints{
×
3084
                       {3, 1},
3085
                       {3, 2},
3086
                       {3, 3},
3087
                   }},
3088
               {"3",
UNCOV
3089
                   maps::BorderPoints{
×
3090
                       {1, 3},
3091
                       {2, 3},
3092
                       {3, 3},
3093
                   }},
3094
               {"5",
3095
                   maps::BorderPoints{
1✔
3096
                       {1, 0},
3097
                       {2, 0},
3098
                       {3, 0},
3099
                   }},
3100
           }},
8✔
3101
       {"2",
3102
           maps::BordersWith{
6✔
3103
               {"1",
3104
                   maps::BorderPoints{
×
3105
                       {4, 1},
3106
                       {4, 2},
3107
                       {4, 3},
3108
                   }},
3109
               {"4",
UNCOV
3110
                   maps::BorderPoints{
×
3111
                       {4, 3},
3112
                       {5, 3},
3113
                       {6, 3},
3114
                   }},
3115
               {"6",
3116
                   maps::BorderPoints{
1✔
3117
                       {4, 0},
3118
                       {5, 0},
3119
                       {6, 0},
3120
                   }},
3121
           }},
8✔
3122
       {"3",
3123
           maps::BordersWith{
6✔
3124
               {"1",
3125
                   maps::BorderPoints{
×
3126
                       {1, 4},
3127
                       {2, 4},
3128
                       {3, 4},
3129
                   }},
3130
               {"4",
UNCOV
3131
                   maps::BorderPoints{
×
3132
                       {3, 4},
3133
                       {3, 5},
3134
                       {3, 6},
3135
                   }},
3136
               {"7",
3137
                   maps::BorderPoints{
1✔
3138
                       {1, 7},
3139
                       {2, 7},
3140
                       {3, 7},
3141
                   }},
3142
           }},
8✔
3143
       {"4",
3144
           maps::BordersWith{
6✔
3145
               {"2",
3146
                   maps::BorderPoints{
×
3147
                       {4, 4},
3148
                       {5, 4},
3149
                       {6, 4},
3150
                   }},
3151
               {"3",
UNCOV
3152
                   maps::BorderPoints{
×
3153
                       {4, 4},
3154
                       {4, 5},
3155
                       {4, 6},
3156
                   }},
3157
               {"8",
3158
                   maps::BorderPoints{
1✔
3159
                       {4, 7},
3160
                       {5, 7},
3161
                       {6, 7},
3162
                   }},
3163
           }},
8✔
3164
   };
5✔
3165

3166
   const maps::MapData map_data({.borders = borders});
1✔
3167

3168
   const Buildings buildings = ImportBuildings(states,
3169
       CoastalProvinces(),
2✔
3170
       map_data,
3171
       commonItems::ModFilesystem{"test_files/Hoi4worldMapBuildingsCreatorTests/DefaultsToNoBuildings", {}});
3✔
3172

3173
   for (const auto& building: buildings.GetBuildings())
5✔
3174
   {
3175
      EXPECT_NE(building.GetType(), "naval_base");
4✔
3176
   }
3177
}
20✔
3178

3179

3180
TEST(Hoi4worldMapBuildingsCreatorTests, NavalBasesNotPlacedInProvincesWithNoBorders)
4✔
3181
{
3182
   std::stringstream log;
1✔
3183
   std::streambuf* cout_buffer = std::cout.rdbuf();
1✔
3184
   std::cout.rdbuf(log.rdbuf());
1✔
3185

3186
   const Buildings buildings = ImportBuildings(States({.states = {State(1, {.provinces = {1, 2, 3, 4}})},
1✔
3187
                                                   .province_to_state_id_map =
3188
                                                       {
3189
                                                           {1, 1},
3190
                                                           {2, 1},
3191
                                                           {3, 1},
3192
                                                           {4, 1},
3193
                                                       }}),
1✔
3194
       CoastalProvinces({{1, {5}}, {2, {6}}, {3, {7}}, {4, {8}}}),
14✔
3195
       maps::MapData(),
1✔
3196
       commonItems::ModFilesystem{"test_files/Hoi4worldMapBuildingsCreatorTests/DefaultsToNoBuildings", {}});
2✔
3197

3198
   std::cout.rdbuf(cout_buffer);
1✔
3199

3200
   EXPECT_TRUE(buildings.GetBuildings().empty());
1✔
3201
   EXPECT_THAT(log.str(),
1✔
3202
       testing::HasSubstr(
3203
           "[WARNING] Province 1 did not have any border points. Naval bases not fully set in state 1."));
1✔
3204
   EXPECT_THAT(log.str(),
1✔
3205
       testing::HasSubstr(
3206
           "[WARNING] Province 2 did not have any border points. Naval bases not fully set in state 1."));
1✔
3207
   EXPECT_THAT(log.str(),
1✔
3208
       testing::HasSubstr(
3209
           "[WARNING] Province 3 did not have any border points. Naval bases not fully set in state 1."));
1✔
3210
   EXPECT_THAT(log.str(),
1✔
3211
       testing::HasSubstr(
3212
           "[WARNING] Province 4 did not have any border points. Naval bases not fully set in state 1."));
1✔
3213
}
14✔
3214

3215

3216
TEST(Hoi4worldMapBuildingsCreatorTests, NavalBasesPlacementOverridenByDefaultLocations)
4✔
3217
{
3218
   const States states({.states = {State(1, {.provinces = {1, 2, 3, 4, 5}})},
3219
       .province_to_state_id_map = {
3220
           {1, 1},
3221
           {2, 1},
3222
           {3, 1},
3223
           {4, 1},
3224
           {5, 1},
3225
       }});
2✔
3226

3227

3228
   const std::map<std::string, maps::BordersWith> borders = {
3229
       {"1",
3230
           maps::BordersWith{
6✔
3231
               {"2",
3232
                   maps::BorderPoints{
×
3233
                       {3, 1},
3234
                       {3, 2},
3235
                       {3, 3},
3236
                   }},
3237
               {"3",
UNCOV
3238
                   maps::BorderPoints{
×
3239
                       {1, 3},
3240
                       {2, 3},
3241
                       {3, 3},
3242
                   }},
3243
               {"5",
3244
                   maps::BorderPoints{
1✔
3245
                       {1, 1},
3246
                       {2, 1},
3247
                       {3, 1},
3248
                   }},
3249
           }},
8✔
3250
       {"2",
3251
           maps::BordersWith{
6✔
3252
               {"1",
3253
                   maps::BorderPoints{
×
3254
                       {4, 1},
3255
                       {4, 2},
3256
                       {4, 3},
3257
                   }},
3258
               {"4",
UNCOV
3259
                   maps::BorderPoints{
×
3260
                       {4, 3},
3261
                       {5, 3},
3262
                       {6, 3},
3263
                   }},
3264
               {"6",
3265
                   maps::BorderPoints{
1✔
3266
                       {4, 1},
3267
                       {5, 1},
3268
                       {6, 1},
3269
                   }},
3270
           }},
8✔
3271
       {"3",
3272
           maps::BordersWith{
6✔
3273
               {"1",
3274
                   maps::BorderPoints{
×
3275
                       {1, 4},
3276
                       {2, 4},
3277
                       {3, 4},
3278
                   }},
3279
               {"4",
UNCOV
3280
                   maps::BorderPoints{
×
3281
                       {3, 4},
3282
                       {3, 5},
3283
                       {3, 6},
3284
                   }},
3285
               {"7",
3286
                   maps::BorderPoints{
1✔
3287
                       {1, 6},
3288
                       {2, 6},
3289
                       {3, 6},
3290
                   }},
3291
           }},
8✔
3292
       {"4",
3293
           maps::BordersWith{
6✔
3294
               {"2",
3295
                   maps::BorderPoints{
×
3296
                       {4, 4},
3297
                       {5, 4},
3298
                       {6, 4},
3299
                   }},
3300
               {"3",
UNCOV
3301
                   maps::BorderPoints{
×
3302
                       {4, 4},
3303
                       {4, 5},
3304
                       {4, 6},
3305
                   }},
3306
               {"8",
3307
                   maps::BorderPoints{
1✔
3308
                       {4, 6},
3309
                       {5, 6},
3310
                       {6, 6},
3311
                   }},
3312
           }},
8✔
3313
   };
5✔
3314

3315
   const maps::MapData map_data({.borders = borders,
3316
       .points_to_provinces = {
3317
           {{2, 1}, "1"},
3318
           {{5, 1}, "2"},
3319
           {{2, 6}, "3"},
3320
           {{5, 6}, "4"},
3321
       }});
13✔
3322

3323
   const Buildings buildings = ImportBuildings(states,
3324
       CoastalProvinces({{1, {5}}, {2, {6}}, {3, {7}}, {4, {8}}}),
14✔
3325
       map_data,
3326
       commonItems::ModFilesystem{"test_files/Hoi4worldMapBuildingsCreatorTests/DefaultsExist", {}});
3✔
3327

3328
   EXPECT_THAT(buildings.GetBuildings(),
6✔
3329
       testing::IsSupersetOf(
3330
           {Building({.state_id = 1,
3331
                .type = "naval_base",
3332
                .position = {.x_coordinate = 2.0, .y_coordinate = 6.0, .z_coordinate = 1.0, .rotation = 90.0},
3333
                .connecting_sea_province = 5}),
3334
               Building({.state_id = 1,
3335
                   .type = "naval_base",
3336
                   .position = {.x_coordinate = 5.0, .y_coordinate = 6.0, .z_coordinate = 1.0, .rotation = 180.0},
3337
                   .connecting_sea_province = 6}),
3338
               Building({.state_id = 1,
3339
                   .type = "naval_base",
3340
                   .position = {.x_coordinate = 2.0, .y_coordinate = 6.0, .z_coordinate = 6.0, .rotation = 270.0},
3341
                   .connecting_sea_province = 7}),
3342
               Building({.state_id = 1,
3343
                   .type = "naval_base",
3344
                   .position = {.x_coordinate = 5.0, .y_coordinate = 6.0, .z_coordinate = 6.0, .rotation = 359.0},
3345
                   .connecting_sea_province = 8})}));
1✔
3346
}
45✔
3347

3348

3349
TEST(Hoi4worldMapBuildingsCreatorTests, NavalBasesPlacedInCenterOfSeaBorderForAllProvincesOfStateIfDefaultNotInState)
4✔
3350
{
3351
   const States states({.states = {State(1, {.provinces = {1, 2, 3, 4, 5}})},
3352
       .province_to_state_id_map = {
3353
           {1, 1},
3354
           {2, 1},
3355
           {3, 1},
3356
           {4, 1},
3357
           {5, 1},
3358
       }});
2✔
3359

3360
   const CoastalProvinces coastal_provinces({{1, {5}}, {2, {6}}, {3, {7}}, {4, {8}}});
13✔
3361

3362
   const std::map<std::string, maps::BordersWith> borders = {{"1",
3363
                                                                 maps::BordersWith{
6✔
3364
                                                                     {"2",
3365
                                                                         maps::BorderPoints{
×
3366
                                                                             {3, 1},
3367
                                                                             {3, 2},
3368
                                                                             {3, 3},
3369
                                                                         }},
3370
                                                                     {"3",
UNCOV
3371
                                                                         maps::BorderPoints{
×
3372
                                                                             {1, 3},
3373
                                                                             {2, 3},
3374
                                                                             {3, 3},
3375
                                                                         }},
3376
                                                                     {"5",
3377
                                                                         maps::BorderPoints{
1✔
3378
                                                                             {1, 1},
3379
                                                                             {2, 1},
3380
                                                                             {3, 1},
3381
                                                                         }},
3382
                                                                 }},
8✔
3383
       {"2",
3384
           maps::BordersWith{
6✔
3385
               {"1",
3386
                   maps::BorderPoints{
×
3387
                       {4, 1},
3388
                       {4, 2},
3389
                       {4, 3},
3390
                   }},
3391
               {"4",
UNCOV
3392
                   maps::BorderPoints{
×
3393
                       {4, 3},
3394
                       {5, 3},
3395
                       {6, 3},
3396
                   }},
3397
               {"6",
3398
                   maps::BorderPoints{
1✔
3399
                       {4, 1},
3400
                       {5, 1},
3401
                       {6, 1},
3402
                   }},
3403
           }},
8✔
3404
       {"3",
3405
           maps::BordersWith{
6✔
3406
               {"1",
3407
                   maps::BorderPoints{
×
3408
                       {1, 4},
3409
                       {2, 4},
3410
                       {3, 4},
3411
                   }},
3412
               {"4",
UNCOV
3413
                   maps::BorderPoints{
×
3414
                       {3, 4},
3415
                       {3, 5},
3416
                       {3, 6},
3417
                   }},
3418
               {"7",
3419
                   maps::BorderPoints{
1✔
3420
                       {1, 6},
3421
                       {2, 6},
3422
                       {3, 6},
3423
                   }},
3424
           }},
8✔
3425
       {"4",
3426
           maps::BordersWith{
6✔
3427
               {"2",
3428
                   maps::BorderPoints{
×
3429
                       {4, 4},
3430
                       {5, 4},
3431
                       {6, 4},
3432
                   }},
3433
               {"3",
UNCOV
3434
                   maps::BorderPoints{
×
3435
                       {4, 4},
3436
                       {4, 5},
3437
                       {4, 6},
3438
                   }},
3439
               {"8",
3440
                   maps::BorderPoints{
1✔
3441
                       {4, 6},
3442
                       {5, 6},
3443
                       {6, 6},
3444
                   }},
3445
           }}};
13✔
3446

3447
   const Buildings buildings = ImportBuildings(states,
3448
       coastal_provinces,
3449
       maps::MapData({.borders = borders}),
1✔
3450
       commonItems::ModFilesystem{"test_files/Hoi4worldMapBuildingsCreatorTests/DefaultsExist", {}});
3✔
3451

3452
   EXPECT_THAT(buildings.GetBuildings(),
6✔
3453
       testing::IsSupersetOf(
3454
           {Building({.state_id = 1,
3455
                .type = "naval_base",
3456
                .position = {.x_coordinate = 2.0, .y_coordinate = 11.0, .z_coordinate = 1.0, .rotation = 0.0},
3457
                .connecting_sea_province = 5}),
3458
               Building({.state_id = 1,
3459
                   .type = "naval_base",
3460
                   .position = {.x_coordinate = 5.0, .y_coordinate = 11.0, .z_coordinate = 1.0, .rotation = 0.0},
3461
                   .connecting_sea_province = 6}),
3462
               Building({.state_id = 1,
3463
                   .type = "naval_base",
3464
                   .position = {.x_coordinate = 2.0, .y_coordinate = 11.0, .z_coordinate = 6.0, .rotation = 0.0},
3465
                   .connecting_sea_province = 7}),
3466
               Building({.state_id = 1,
3467
                   .type = "naval_base",
3468
                   .position = {.x_coordinate = 5.0, .y_coordinate = 11.0, .z_coordinate = 6.0, .rotation = 0.0},
3469
                   .connecting_sea_province = 8})}));
1✔
3470
}
31✔
3471

3472

3473
TEST(Hoi4worldMapBuildingsCreatorTests, NuclearReactorPlacedInCenterOfFirstProvinceOfState)
4✔
3474
{
3475
   const States states({.states = {State(1, {.provinces = {1, 2, 3, 4, 5}})},
3476
       .province_to_state_id_map = {
3477
           {1, 1},
3478
           {2, 1},
3479
           {3, 1},
3480
           {4, 1},
3481
           {5, 1},
3482
       }});
2✔
3483

3484
   const Buildings buildings = ImportBuildings(states,
3485
       CoastalProvinces(),
2✔
3486
       maps::MapData(
1✔
3487
           {.the_province_points =
3488
                   {
3489
                       {"1",
3490
                           maps::ProvincePoints(
2✔
3491
                               {{1, 1}, {1, 2}, {1, 3}, {2, 1}, {2, 2}, {2, 3}, {3, 1}, {3, 2}, {3, 3}})},
3492
                       {"2",
3493
                           maps::ProvincePoints(
2✔
3494
                               {{4, 1}, {4, 2}, {4, 3}, {5, 1}, {5, 2}, {5, 3}, {6, 1}, {6, 2}, {6, 3}})},
3495
                       {"3",
3496
                           maps::ProvincePoints(
2✔
3497
                               {{1, 4}, {1, 5}, {1, 6}, {2, 4}, {2, 5}, {2, 6}, {3, 4}, {3, 5}, {3, 6}})},
3498
                       {"4",
3499
                           maps::ProvincePoints(
2✔
3500
                               {{4, 4}, {4, 5}, {4, 6}, {5, 4}, {5, 5}, {5, 6}, {6, 4}, {6, 5}, {6, 6}})},
3501
                   }}),
4✔
3502
       commonItems::ModFilesystem{"test_files/Hoi4worldMapBuildingsCreatorTests/DefaultsToNoBuildings", {}});
3✔
3503

3504
   EXPECT_THAT(buildings.GetBuildings(),
3✔
3505
       testing::IsSupersetOf({Building({.state_id = 1,
3506
           .type = "nuclear_reactor",
3507
           .position = {.x_coordinate = 2.0, .y_coordinate = 11.0, .z_coordinate = 2.0, .rotation = 0.0}})}));
1✔
3508
}
16✔
3509

3510

3511
TEST(Hoi4worldMapBuildingsCreatorTests, NoNuclearReactorInStateWithNoProvinces)
4✔
3512
{
3513
   const Buildings buildings = ImportBuildings(States({.states = {State(1, {})},
1✔
3514
                                                   .province_to_state_id_map =
3515
                                                       {
3516
                                                           {1, 1},
3517
                                                           {2, 1},
3518
                                                           {3, 1},
3519
                                                           {4, 1},
3520
                                                           {5, 1},
3521
                                                       }}),
1✔
3522
       CoastalProvinces(),
1✔
3523
       maps::MapData(
1✔
3524
           {.the_province_points =
3525
                   {
3526
                       {"1",
3527
                           maps::ProvincePoints(
2✔
3528
                               {{1, 1}, {1, 2}, {1, 3}, {2, 1}, {2, 2}, {2, 3}, {3, 1}, {3, 2}, {3, 3}})},
3529
                       {"2",
3530
                           maps::ProvincePoints(
2✔
3531
                               {{4, 1}, {4, 2}, {4, 3}, {5, 1}, {5, 2}, {5, 3}, {6, 1}, {6, 2}, {6, 3}})},
3532
                       {"3",
3533
                           maps::ProvincePoints(
2✔
3534
                               {{1, 4}, {1, 5}, {1, 6}, {2, 4}, {2, 5}, {2, 6}, {3, 4}, {3, 5}, {3, 6}})},
3535
                       {"4",
3536
                           maps::ProvincePoints(
2✔
3537
                               {{4, 4}, {4, 5}, {4, 6}, {5, 4}, {5, 5}, {5, 6}, {6, 4}, {6, 5}, {6, 6}})},
3538
                   }}),
4✔
3539
       commonItems::ModFilesystem{"test_files/Hoi4worldMapBuildingsCreatorTests/DefaultsToNoBuildings", {}});
2✔
3540

3541
   EXPECT_TRUE(buildings.GetBuildings().empty());
1✔
3542
}
15✔
3543

3544

3545
TEST(Hoi4worldMapBuildingsCreatorTests, NuclearReactorNotPlacedInProvincesWithNoPoints)
4✔
3546
{
3547
   std::stringstream log;
1✔
3548
   std::streambuf* cout_buffer = std::cout.rdbuf();
1✔
3549
   std::cout.rdbuf(log.rdbuf());
1✔
3550

3551
   const Buildings buildings = ImportBuildings(States({.states = {State(1, {.provinces = {1, 2, 3, 4, 5}})},
1✔
3552
                                                   .province_to_state_id_map =
3553
                                                       {
3554
                                                           {1, 1},
3555
                                                           {2, 1},
3556
                                                           {3, 1},
3557
                                                           {4, 1},
3558
                                                           {5, 1},
3559
                                                       }}),
1✔
3560
       CoastalProvinces(),
1✔
3561
       maps::MapData(),
2✔
3562
       commonItems::ModFilesystem{"test_files/Hoi4worldMapBuildingsCreatorTests/DefaultsToNoBuildings", {}});
2✔
3563

3564
   std::cout.rdbuf(cout_buffer);
1✔
3565

3566
   EXPECT_TRUE(buildings.GetBuildings().empty());
1✔
3567
   EXPECT_THAT(log.str(),
1✔
3568
       testing::HasSubstr("[WARNING] Province 1 did not have any points. nuclear_reactor not fully set in state 1."));
1✔
3569
   EXPECT_THAT(log.str(),
1✔
3570
       testing::HasSubstr("[WARNING] Province 2 did not have any points. nuclear_reactor not fully set in state 1."));
1✔
3571
   EXPECT_THAT(log.str(),
1✔
3572
       testing::HasSubstr("[WARNING] Province 3 did not have any points. nuclear_reactor not fully set in state 1."));
1✔
3573
   EXPECT_THAT(log.str(),
1✔
3574
       testing::HasSubstr("[WARNING] Province 4 did not have any points. nuclear_reactor not fully set in state 1."));
1✔
3575
}
4✔
3576

3577

3578
TEST(Hoi4worldMapBuildingsCreatorTests, NuclearReactorPlacementOverridenByDefaultLocations)
4✔
3579
{
3580
   const Buildings buildings = ImportBuildings(States({.states = {State(1, {.provinces = {1, 2, 3, 4, 5}})},
1✔
3581
                                                   .province_to_state_id_map =
3582
                                                       {
3583
                                                           {1, 1},
3584
                                                           {2, 1},
3585
                                                           {3, 1},
3586
                                                           {4, 1},
3587
                                                           {5, 1},
3588
                                                       }}),
1✔
3589
       CoastalProvinces(),
1✔
3590
       maps::MapData(
1✔
3591
           {.the_province_points =
3592
                   {
3593
                       {"1",
3594
                           maps::ProvincePoints(
2✔
3595
                               {{1, 1}, {1, 2}, {1, 3}, {2, 1}, {2, 2}, {2, 3}, {3, 1}, {3, 2}, {3, 3}})},
3596
                       {"2",
3597
                           maps::ProvincePoints(
2✔
3598
                               {{4, 1}, {4, 2}, {4, 3}, {5, 1}, {5, 2}, {5, 3}, {6, 1}, {6, 2}, {6, 3}})},
3599
                       {"3",
3600
                           maps::ProvincePoints(
2✔
3601
                               {{1, 4}, {1, 5}, {1, 6}, {2, 4}, {2, 5}, {2, 6}, {3, 4}, {3, 5}, {3, 6}})},
3602
                       {"4",
3603
                           maps::ProvincePoints(
2✔
3604
                               {{4, 4}, {4, 5}, {4, 6}, {5, 4}, {5, 5}, {5, 6}, {6, 4}, {6, 5}, {6, 6}})},
3605
                   },
3606
               .points_to_provinces{
3607
                   {{4, 1}, "2"},
3608
                   {{1, 4}, "3"},
3609
                   {{4, 4}, "4"},
3610
               }}),
13✔
3611
       commonItems::ModFilesystem{"test_files/Hoi4worldMapBuildingsCreatorTests/DefaultsExist", {}});
2✔
3612

3613
   EXPECT_THAT(buildings.GetBuildings(),
3✔
3614
       testing::IsSupersetOf({Building({.state_id = 1,
3615
           .type = "nuclear_reactor",
3616
           .position = {.x_coordinate = 4.0, .y_coordinate = 6.0, .z_coordinate = 1.0, .rotation = 90.0}})}));
1✔
3617
}
26✔
3618

3619

3620
TEST(Hoi4worldMapBuildingsCreatorTests, NuclearReactorPlacedInCenterOfFirstProvinceOfStateIfDefaultNotInState)
4✔
3621
{
3622
   const Buildings buildings = ImportBuildings(States({.states = {State(1, {.provinces = {1, 2, 3, 4, 5}})},
1✔
3623
                                                   .province_to_state_id_map =
3624
                                                       {
3625
                                                           {1, 1},
3626
                                                           {2, 1},
3627
                                                           {3, 1},
3628
                                                           {4, 1},
3629
                                                           {5, 1},
3630
                                                       }}),
1✔
3631
       CoastalProvinces(),
1✔
3632
       maps::MapData(
1✔
3633
           {.the_province_points =
3634
                   {
3635
                       {"1",
3636
                           maps::ProvincePoints(
2✔
3637
                               {{1, 1}, {1, 2}, {1, 3}, {2, 1}, {2, 2}, {2, 3}, {3, 1}, {3, 2}, {3, 3}})},
3638
                       {"2",
3639
                           maps::ProvincePoints(
2✔
3640
                               {{4, 1}, {4, 2}, {4, 3}, {5, 1}, {5, 2}, {5, 3}, {6, 1}, {6, 2}, {6, 3}})},
3641
                       {"3",
3642
                           maps::ProvincePoints(
2✔
3643
                               {{1, 4}, {1, 5}, {1, 6}, {2, 4}, {2, 5}, {2, 6}, {3, 4}, {3, 5}, {3, 6}})},
3644
                       {"4",
3645
                           maps::ProvincePoints(
2✔
3646
                               {{4, 4}, {4, 5}, {4, 6}, {5, 4}, {5, 5}, {5, 6}, {6, 4}, {6, 5}, {6, 6}})},
3647
                   }}),
4✔
3648
       commonItems::ModFilesystem{"test_files/Hoi4worldMapBuildingsCreatorTests/DefaultsExist", {}});
2✔
3649

3650
   EXPECT_THAT(buildings.GetBuildings(),
3✔
3651
       testing::IsSupersetOf({Building({.state_id = 1,
3652
           .type = "nuclear_reactor",
3653
           .position = {.x_coordinate = 2.0, .y_coordinate = 11.0, .z_coordinate = 2.0, .rotation = 0.0}})}));
1✔
3654
}
17✔
3655

3656

3657
TEST(Hoi4worldMapBuildingsCreatorTests, SupplyNodesPlacedInCenterOfABorderForAllProvincesOfState)
4✔
3658
{
3659
   const States states({.states = {State(1, {.provinces = {1, 2, 3, 4}})},
3660
       .province_to_state_id_map = {
3661
           {1, 1},
3662
           {2, 1},
3663
           {3, 1},
3664
           {4, 1},
3665
       }});
2✔
3666

3667
   const std::map<std::string, maps::BordersWith> borders = {{"1",
3668
                                                                 maps::BordersWith{
5✔
3669
                                                                     {"2",
UNCOV
3670
                                                                         maps::BorderPoints{
×
3671
                                                                             {3, 1},
3672
                                                                             {3, 2},
3673
                                                                             {3, 3},
3674
                                                                         }},
3675
                                                                     {"3",
3676
                                                                         maps::BorderPoints{
1✔
3677
                                                                             {1, 3},
3678
                                                                             {2, 3},
3679
                                                                             {3, 3},
3680
                                                                         }},
3681
                                                                 }},
6✔
3682
       {"2",
3683
           maps::BordersWith{
5✔
3684
               {"1",
UNCOV
3685
                   maps::BorderPoints{
×
3686
                       {4, 1},
3687
                       {4, 2},
3688
                       {4, 3},
3689
                   }},
3690
               {"4",
3691
                   maps::BorderPoints{
1✔
3692
                       {4, 3},
3693
                       {5, 3},
3694
                       {6, 3},
3695
                   }},
3696
           }},
6✔
3697
       {"3",
3698
           maps::BordersWith{
5✔
3699
               {"1",
UNCOV
3700
                   maps::BorderPoints{
×
3701
                       {1, 4},
3702
                       {2, 4},
3703
                       {3, 4},
3704
                   }},
3705
               {"4",
3706
                   maps::BorderPoints{
1✔
3707
                       {3, 4},
3708
                       {3, 5},
3709
                       {3, 6},
3710
                   }},
3711
           }},
6✔
3712
       {"4",
3713
           maps::BordersWith{
5✔
3714
               {"2",
UNCOV
3715
                   maps::BorderPoints{
×
3716
                       {4, 4},
3717
                       {5, 4},
3718
                       {6, 4},
3719
                   }},
3720
               {"3",
3721
                   maps::BorderPoints{
1✔
3722
                       {4, 4},
3723
                       {4, 5},
3724
                       {4, 6},
3725
                   }},
3726
           }}};
11✔
3727

3728
   const Buildings buildings = ImportBuildings(states,
3729
       CoastalProvinces(),
2✔
3730
       maps::MapData({.borders = borders}),
1✔
3731
       commonItems::ModFilesystem{"test_files/Hoi4worldMapBuildingsCreatorTests/DefaultsToNoBuildings", {}});
3✔
3732

3733
   EXPECT_THAT(buildings.GetBuildings(),
6✔
3734
       testing::IsSupersetOf(
3735
           {Building({.state_id = 1,
3736
                .type = "supply_node",
3737
                .position = {.x_coordinate = 3.0, .y_coordinate = 11.0, .z_coordinate = 2.0, .rotation = 0.0}}),
3738
               Building({.state_id = 1,
3739
                   .type = "supply_node",
3740
                   .position = {.x_coordinate = 4.0, .y_coordinate = 11.0, .z_coordinate = 2.0, .rotation = 0.0}}),
3741
               Building({.state_id = 1,
3742
                   .type = "supply_node",
3743
                   .position = {.x_coordinate = 2.0, .y_coordinate = 11.0, .z_coordinate = 4.0, .rotation = 0.0}}),
3744
               Building({.state_id = 1,
3745
                   .type = "supply_node",
3746
                   .position = {.x_coordinate = 5.0, .y_coordinate = 11.0, .z_coordinate = 4.0, .rotation = 0.0}})}));
1✔
3747
}
18✔
3748

3749

3750
TEST(Hoi4worldMapBuildingsCreatorTests, NoSupplyNodesInStateWithNoProvinces)
4✔
3751
{
3752
   const States states({.states = {State(1, {})}, .province_to_state_id_map = {}});
2✔
3753

3754
   const std::map<std::string, maps::BordersWith> borders = {{"1",
3755
                                                                 maps::BordersWith{
5✔
3756
                                                                     {"2",
UNCOV
3757
                                                                         maps::BorderPoints{
×
3758
                                                                             {3, 1},
3759
                                                                             {3, 2},
3760
                                                                             {3, 3},
3761
                                                                         }},
3762
                                                                     {"3",
3763
                                                                         maps::BorderPoints{
1✔
3764
                                                                             {1, 3},
3765
                                                                             {2, 3},
3766
                                                                             {3, 3},
3767
                                                                         }},
3768
                                                                 }},
6✔
3769
       {"2",
3770
           maps::BordersWith{
5✔
3771
               {"1",
UNCOV
3772
                   maps::BorderPoints{
×
3773
                       {4, 1},
3774
                       {4, 2},
3775
                       {4, 3},
3776
                   }},
3777
               {"4",
3778
                   maps::BorderPoints{
1✔
3779
                       {4, 3},
3780
                       {5, 3},
3781
                       {6, 3},
3782
                   }},
3783
           }},
6✔
3784
       {"3",
3785
           maps::BordersWith{
5✔
3786
               {"1",
UNCOV
3787
                   maps::BorderPoints{
×
3788
                       {1, 4},
3789
                       {2, 4},
3790
                       {3, 4},
3791
                   }},
3792
               {"4",
3793
                   maps::BorderPoints{
1✔
3794
                       {3, 4},
3795
                       {3, 5},
3796
                       {3, 6},
3797
                   }},
3798
           }},
6✔
3799
       {"4",
3800
           maps::BordersWith{
5✔
3801
               {"2",
UNCOV
3802
                   maps::BorderPoints{
×
3803
                       {4, 4},
3804
                       {5, 4},
3805
                       {6, 4},
3806
                   }},
3807
               {"3",
3808
                   maps::BorderPoints{
1✔
3809
                       {4, 4},
3810
                       {4, 5},
3811
                       {4, 6},
3812
                   }},
3813
           }}};
11✔
3814

3815
   const maps::MapData map_data({.borders = borders});
1✔
3816

3817
   const Buildings buildings = ImportBuildings(states,
3818
       CoastalProvinces(),
2✔
3819
       map_data,
3820
       commonItems::ModFilesystem{"test_files/Hoi4worldMapBuildingsCreatorTests/DefaultsToNoBuildings", {}});
3✔
3821

3822
   EXPECT_TRUE(buildings.GetBuildings().empty());
1✔
3823
}
16✔
3824

3825

3826
TEST(Hoi4worldMapBuildingsCreatorTests, SupplyNodesNotPlacedInProvincesWithNoBorders)
4✔
3827
{
3828
   std::stringstream log;
1✔
3829
   std::streambuf* cout_buffer = std::cout.rdbuf();
1✔
3830
   std::cout.rdbuf(log.rdbuf());
1✔
3831

3832
   const Buildings buildings = ImportBuildings(States({.states = {State(1, {.provinces = {1, 2, 3, 4}})},
1✔
3833
                                                   .province_to_state_id_map =
3834
                                                       {
3835
                                                           {1, 1},
3836
                                                           {2, 1},
3837
                                                           {3, 1},
3838
                                                           {4, 1},
3839
                                                       }}),
1✔
3840
       CoastalProvinces(),
1✔
3841
       maps::MapData(),
2✔
3842
       commonItems::ModFilesystem{"test_files/Hoi4worldMapBuildingsCreatorTests/DefaultsToNoBuildings", {}});
2✔
3843

3844
   std::cout.rdbuf(cout_buffer);
1✔
3845

3846
   EXPECT_TRUE(buildings.GetBuildings().empty());
1✔
3847
   EXPECT_THAT(log.str(),
1✔
3848
       testing::HasSubstr(
3849
           "[WARNING] Province 1 did not have any border points. Supply nodes not fully set in state 1."));
1✔
3850
   EXPECT_THAT(log.str(),
1✔
3851
       testing::HasSubstr(
3852
           "[WARNING] Province 2 did not have any border points. Supply nodes not fully set in state 1."));
1✔
3853
   EXPECT_THAT(log.str(),
1✔
3854
       testing::HasSubstr(
3855
           "[WARNING] Province 3 did not have any border points. Supply nodes not fully set in state 1."));
1✔
3856
   EXPECT_THAT(log.str(),
1✔
3857
       testing::HasSubstr(
3858
           "[WARNING] Province 4 did not have any border points. Supply nodes not fully set in state 1."));
1✔
3859
}
4✔
3860

3861

3862
TEST(Hoi4worldMapBuildingsCreatorTests, SupplyNodePlacementOverridenByDefaultLocations)
4✔
3863
{
3864
   const States states({.states = {State(1, {.provinces = {1, 2, 3, 4, 5}})},
3865
       .province_to_state_id_map = {
3866
           {1, 1},
3867
           {2, 1},
3868
           {3, 1},
3869
           {4, 1},
3870
           {5, 1},
3871
       }});
2✔
3872

3873
   const std::map<std::string, maps::BordersWith> borders = {
3874
       {"1",
3875
           maps::BordersWith{
5✔
3876
               {"2",
UNCOV
3877
                   maps::BorderPoints{
×
3878
                       {3, 1},
3879
                       {3, 2},
3880
                       {3, 3},
3881
                   }},
3882
               {"3",
3883
                   maps::BorderPoints{
1✔
3884
                       {1, 3},
3885
                       {2, 3},
3886
                       {3, 3},
3887
                   }},
3888
           }},
6✔
3889
       {"2",
3890
           maps::BordersWith{
5✔
3891
               {"1",
UNCOV
3892
                   maps::BorderPoints{
×
3893
                       {4, 1},
3894
                       {4, 2},
3895
                       {4, 3},
3896
                   }},
3897
               {"4",
3898
                   maps::BorderPoints{
1✔
3899
                       {4, 3},
3900
                       {5, 3},
3901
                       {6, 3},
3902
                   }},
3903
           }},
6✔
3904
       {"3",
3905
           maps::BordersWith{
5✔
3906
               {"1",
UNCOV
3907
                   maps::BorderPoints{
×
3908
                       {1, 4},
3909
                       {2, 4},
3910
                       {3, 4},
3911
                   }},
3912
               {"4",
3913
                   maps::BorderPoints{
1✔
3914
                       {3, 4},
3915
                       {3, 5},
3916
                       {3, 6},
3917
                   }},
3918
           }},
6✔
3919
       {"4",
3920
           maps::BordersWith{
5✔
3921
               {"2",
UNCOV
3922
                   maps::BorderPoints{
×
3923
                       {4, 4},
3924
                       {5, 4},
3925
                       {6, 4},
3926
                   }},
3927
               {"3",
3928
                   maps::BorderPoints{
1✔
3929
                       {4, 4},
3930
                       {4, 5},
3931
                       {4, 6},
3932
                   }},
3933
           }},
6✔
3934
   };
5✔
3935

3936
   const maps::MapData map_data({.borders = borders,
3937
       .points_to_provinces = {
3938
           {{3, 2}, "1"},
3939
           {{4, 2}, "2"},
3940
           {{2, 4}, "3"},
3941
           {{5, 4}, "4"},
3942
       }});
13✔
3943

3944
   const Buildings buildings = ImportBuildings(states,
3945
       CoastalProvinces(),
2✔
3946
       map_data,
3947
       commonItems::ModFilesystem{"test_files/Hoi4worldMapBuildingsCreatorTests/DefaultsExist", {}});
3✔
3948

3949
   EXPECT_THAT(buildings.GetBuildings(),
6✔
3950
       testing::IsSupersetOf(
3951
           {Building({.state_id = 1,
3952
                .type = "supply_node",
3953
                .position = {.x_coordinate = 3.0, .y_coordinate = 6.0, .z_coordinate = 2.0, .rotation = 90.0}}),
3954
               Building({.state_id = 1,
3955
                   .type = "supply_node",
3956
                   .position = {.x_coordinate = 4.0, .y_coordinate = 6.0, .z_coordinate = 2.0, .rotation = 180.0}}),
3957
               Building({.state_id = 1,
3958
                   .type = "supply_node",
3959
                   .position = {.x_coordinate = 2.0, .y_coordinate = 6.0, .z_coordinate = 4.0, .rotation = 270.0}}),
3960
               Building({.state_id = 1,
3961
                   .type = "supply_node",
3962
                   .position = {.x_coordinate = 5.0, .y_coordinate = 6.0, .z_coordinate = 4.0, .rotation = 359.0}})}));
1✔
3963
}
31✔
3964

3965

3966
TEST(Hoi4worldMapBuildingsCreatorTests, SupplyNodePlacedInCenterOfABorderForAllProvincesOfStateIfDefaultsNotInState)
4✔
3967
{
3968
   const States states({.states = {State(1, {.provinces = {1, 2, 3, 4, 5}})},
3969
       .province_to_state_id_map = {
3970
           {1, 1},
3971
           {2, 1},
3972
           {3, 1},
3973
           {4, 1},
3974
           {5, 1},
3975
       }});
2✔
3976

3977
   const std::map<std::string, maps::BordersWith> borders = {{"1",
3978
                                                                 maps::BordersWith{
5✔
3979
                                                                     {"2",
UNCOV
3980
                                                                         maps::BorderPoints{
×
3981
                                                                             {3, 1},
3982
                                                                             {3, 2},
3983
                                                                             {3, 3},
3984
                                                                         }},
3985
                                                                     {"3",
3986
                                                                         maps::BorderPoints{
1✔
3987
                                                                             {1, 3},
3988
                                                                             {2, 3},
3989
                                                                             {3, 3},
3990
                                                                         }},
3991
                                                                 }},
6✔
3992
       {"2",
3993
           maps::BordersWith{
5✔
3994
               {"1",
UNCOV
3995
                   maps::BorderPoints{
×
3996
                       {4, 1},
3997
                       {4, 2},
3998
                       {4, 3},
3999
                   }},
4000
               {"4",
4001
                   maps::BorderPoints{
1✔
4002
                       {4, 3},
4003
                       {5, 3},
4004
                       {6, 3},
4005
                   }},
4006
           }},
6✔
4007
       {"3",
4008
           maps::BordersWith{
5✔
4009
               {"1",
UNCOV
4010
                   maps::BorderPoints{
×
4011
                       {1, 4},
4012
                       {2, 4},
4013
                       {3, 4},
4014
                   }},
4015
               {"4",
4016
                   maps::BorderPoints{
1✔
4017
                       {3, 4},
4018
                       {3, 5},
4019
                       {3, 6},
4020
                   }},
4021
           }},
6✔
4022
       {"4",
4023
           maps::BordersWith{
5✔
4024
               {"2",
UNCOV
4025
                   maps::BorderPoints{
×
4026
                       {4, 4},
4027
                       {5, 4},
4028
                       {6, 4},
4029
                   }},
4030
               {"3",
4031
                   maps::BorderPoints{
1✔
4032
                       {4, 4},
4033
                       {4, 5},
4034
                       {4, 6},
4035
                   }},
4036
           }}};
11✔
4037

4038
   const Buildings buildings = ImportBuildings(states,
4039
       CoastalProvinces(),
2✔
4040
       maps::MapData({.borders = borders}),
1✔
4041
       commonItems::ModFilesystem{"test_files/Hoi4worldMapBuildingsCreatorTests/DefaultsExist", {}});
3✔
4042

4043
   EXPECT_THAT(buildings.GetBuildings(),
6✔
4044
       testing::IsSupersetOf(
4045
           {Building({.state_id = 1,
4046
                .type = "supply_node",
4047
                .position = {.x_coordinate = 3.0, .y_coordinate = 11.0, .z_coordinate = 2.0, .rotation = 0.0}}),
4048
               Building({.state_id = 1,
4049
                   .type = "supply_node",
4050
                   .position = {.x_coordinate = 4.0, .y_coordinate = 11.0, .z_coordinate = 2.0, .rotation = 0.0}}),
4051
               Building({.state_id = 1,
4052
                   .type = "supply_node",
4053
                   .position = {.x_coordinate = 2.0, .y_coordinate = 11.0, .z_coordinate = 4.0, .rotation = 0.0}}),
4054
               Building({.state_id = 1,
4055
                   .type = "supply_node",
4056
                   .position = {.x_coordinate = 5.0, .y_coordinate = 11.0, .z_coordinate = 4.0, .rotation = 0.0}})}));
1✔
4057
}
18✔
4058

4059

4060
TEST(Hoi4worldMapBuildingsCreatorTests, SyntheticRefineryPlacedInCenterOfFirstProvinceOfState)
4✔
4061
{
4062
   const Buildings buildings = ImportBuildings(States({.states = {State(1, {.provinces = {1, 2, 3, 4, 5}})},
1✔
4063
                                                   .province_to_state_id_map =
4064
                                                       {
4065
                                                           {1, 1},
4066
                                                           {2, 1},
4067
                                                           {3, 1},
4068
                                                           {4, 1},
4069
                                                           {5, 1},
4070
                                                       }}),
1✔
4071
       CoastalProvinces(),
1✔
4072
       maps::MapData(
1✔
4073
           {.the_province_points =
4074
                   {
4075
                       {"1",
4076
                           maps::ProvincePoints(
2✔
4077
                               {{1, 1}, {1, 2}, {1, 3}, {2, 1}, {2, 2}, {2, 3}, {3, 1}, {3, 2}, {3, 3}})},
4078
                       {"2",
4079
                           maps::ProvincePoints(
2✔
4080
                               {{4, 1}, {4, 2}, {4, 3}, {5, 1}, {5, 2}, {5, 3}, {6, 1}, {6, 2}, {6, 3}})},
4081
                       {"3",
4082
                           maps::ProvincePoints(
2✔
4083
                               {{1, 4}, {1, 5}, {1, 6}, {2, 4}, {2, 5}, {2, 6}, {3, 4}, {3, 5}, {3, 6}})},
4084
                       {"4",
4085
                           maps::ProvincePoints(
2✔
4086
                               {{4, 4}, {4, 5}, {4, 6}, {5, 4}, {5, 5}, {5, 6}, {6, 4}, {6, 5}, {6, 6}})},
4087
                   }}),
4✔
4088
       commonItems::ModFilesystem{"test_files/Hoi4worldMapBuildingsCreatorTests/DefaultsToNoBuildings", {}});
2✔
4089

4090
   EXPECT_THAT(buildings.GetBuildings(),
3✔
4091
       testing::IsSupersetOf({Building({.state_id = 1,
4092
           .type = "synthetic_refinery",
4093
           .position = {.x_coordinate = 2.0, .y_coordinate = 11.0, .z_coordinate = 2.0, .rotation = 0.0}})}));
1✔
4094
}
17✔
4095

4096

4097
TEST(Hoi4worldMapBuildingsCreatorTests, NoSyntheticRefineryInStateWithNoProvinces)
4✔
4098
{
4099
   const Buildings buildings = ImportBuildings(States({.states = {State(1, {})},
1✔
4100
                                                   .province_to_state_id_map =
4101
                                                       {
4102
                                                           {1, 1},
4103
                                                           {2, 1},
4104
                                                           {3, 1},
4105
                                                           {4, 1},
4106
                                                           {5, 1},
4107
                                                       }}),
1✔
4108
       CoastalProvinces(),
1✔
4109
       maps::MapData(
1✔
4110
           {.the_province_points =
4111
                   {
4112
                       {"1",
4113
                           maps::ProvincePoints(
2✔
4114
                               {{1, 1}, {1, 2}, {1, 3}, {2, 1}, {2, 2}, {2, 3}, {3, 1}, {3, 2}, {3, 3}})},
4115
                       {"2",
4116
                           maps::ProvincePoints(
2✔
4117
                               {{4, 1}, {4, 2}, {4, 3}, {5, 1}, {5, 2}, {5, 3}, {6, 1}, {6, 2}, {6, 3}})},
4118
                       {"3",
4119
                           maps::ProvincePoints(
2✔
4120
                               {{1, 4}, {1, 5}, {1, 6}, {2, 4}, {2, 5}, {2, 6}, {3, 4}, {3, 5}, {3, 6}})},
4121
                       {"4",
4122
                           maps::ProvincePoints(
2✔
4123
                               {{4, 4}, {4, 5}, {4, 6}, {5, 4}, {5, 5}, {5, 6}, {6, 4}, {6, 5}, {6, 6}})},
4124
                   }}),
4✔
4125
       commonItems::ModFilesystem{"test_files/Hoi4worldMapBuildingsCreatorTests/DefaultsToNoBuildings", {}});
2✔
4126

4127
   EXPECT_TRUE(buildings.GetBuildings().empty());
1✔
4128
}
15✔
4129

4130

4131
TEST(Hoi4worldMapBuildingsCreatorTests, SyntheticRefineryNotPlacedInProvincesWithNoPoints)
4✔
4132
{
4133
   std::stringstream log;
1✔
4134
   std::streambuf* cout_buffer = std::cout.rdbuf();
1✔
4135
   std::cout.rdbuf(log.rdbuf());
1✔
4136

4137
   const Buildings buildings = ImportBuildings(States({.states = {State(1, {.provinces = {1, 2, 3, 4, 5}})},
1✔
4138
                                                   .province_to_state_id_map =
4139
                                                       {
4140
                                                           {1, 1},
4141
                                                           {2, 1},
4142
                                                           {3, 1},
4143
                                                           {4, 1},
4144
                                                           {5, 1},
4145
                                                       }}),
1✔
4146
       CoastalProvinces(),
1✔
4147
       maps::MapData(),
2✔
4148
       commonItems::ModFilesystem{"test_files/Hoi4worldMapBuildingsCreatorTests/DefaultsToNoBuildings", {}});
2✔
4149

4150
   std::cout.rdbuf(cout_buffer);
1✔
4151

4152
   EXPECT_TRUE(buildings.GetBuildings().empty());
1✔
4153
   EXPECT_THAT(log.str(),
1✔
4154
       testing::HasSubstr(
4155
           "[WARNING] Province 1 did not have any points. synthetic_refinery not fully set in state 1."));
1✔
4156
   EXPECT_THAT(log.str(),
1✔
4157
       testing::HasSubstr(
4158
           "[WARNING] Province 2 did not have any points. synthetic_refinery not fully set in state 1."));
1✔
4159
   EXPECT_THAT(log.str(),
1✔
4160
       testing::HasSubstr(
4161
           "[WARNING] Province 3 did not have any points. synthetic_refinery not fully set in state 1."));
1✔
4162
   EXPECT_THAT(log.str(),
1✔
4163
       testing::HasSubstr(
4164
           "[WARNING] Province 4 did not have any points. synthetic_refinery not fully set in state 1."));
1✔
4165
}
4✔
4166

4167

4168
TEST(Hoi4worldMapBuildingsCreatorTests, SyntheticRefineryPlacementOverridenByDefaultLocations)
4✔
4169
{
4170
   const Buildings
4171
       buildings =
4172
           ImportBuildings(States({.states = {State(1, {.provinces = {1, 2, 3, 4, 5}})},
1✔
4173
                               .province_to_state_id_map =
4174
                                   {
4175
                                       {1, 1},
4176
                                       {2, 1},
4177
                                       {3, 1},
4178
                                       {4, 1},
4179
                                       {5, 1},
4180
                                   }}),
1✔
4181
               CoastalProvinces(),
1✔
4182
               maps::MapData(
1✔
4183
                   {.the_province_points =
4184
                           {
4185
                               {"1",
4186
                                   maps::ProvincePoints(
2✔
4187
                                       {{1, 1}, {1, 2}, {1, 3}, {2, 1}, {2, 2}, {2, 3}, {3, 1}, {3, 2}, {3, 3}})},
4188
                               {"2",
4189
                                   maps::ProvincePoints(
2✔
4190
                                       {{4, 1}, {4, 2}, {4, 3}, {5, 1}, {5, 2}, {5, 3}, {6, 1}, {6, 2}, {6, 3}})},
4191
                               {"3",
4192
                                   maps::ProvincePoints(
2✔
4193
                                       {{1, 4}, {1, 5}, {1, 6}, {2, 4}, {2, 5}, {2, 6}, {3, 4}, {3, 5}, {3, 6}})},
4194
                               {"4",
4195
                                   maps::ProvincePoints(
2✔
4196
                                       {{4, 4}, {4, 5}, {4, 6}, {5, 4}, {5, 5}, {5, 6}, {6, 4}, {6, 5}, {6, 6}})},
4197
                           },
4198
                       .points_to_provinces =
4199
                           {
4200
                               {{4, 1}, "2"},
4201
                               {{1, 4}, "3"},
4202
                               {{4, 4}, "4"},
4203
                           }}),
13✔
4204
               commonItems::ModFilesystem{"test_files/Hoi4worldMapBuildingsCreatorTests/DefaultsExist", {}});
2✔
4205

4206
   EXPECT_THAT(buildings.GetBuildings(),
3✔
4207
       testing::IsSupersetOf({Building({.state_id = 1,
4208
           .type = "synthetic_refinery",
4209
           .position = {.x_coordinate = 4.0, .y_coordinate = 6.0, .z_coordinate = 1.0, .rotation = 90.0}})}));
1✔
4210
}
26✔
4211

4212

4213
TEST(Hoi4worldMapBuildingsCreatorTests, SyntheticRefineryPlacedInCenterOfFirstProvinceOfStateIfDefaultNotInState)
4✔
4214
{
4215
   const Buildings buildings = ImportBuildings(States({.states = {State(1, {.provinces = {1, 2, 3, 4, 5}})},
1✔
4216
                                                   .province_to_state_id_map =
4217
                                                       {
4218
                                                           {1, 1},
4219
                                                           {2, 1},
4220
                                                           {3, 1},
4221
                                                           {4, 1},
4222
                                                           {5, 1},
4223
                                                       }}),
1✔
4224
       CoastalProvinces(),
1✔
4225
       maps::MapData(
1✔
4226
           {.the_province_points =
4227
                   {
4228
                       {"1",
4229
                           maps::ProvincePoints(
2✔
4230
                               {{1, 1}, {1, 2}, {1, 3}, {2, 1}, {2, 2}, {2, 3}, {3, 1}, {3, 2}, {3, 3}})},
4231
                       {"2",
4232
                           maps::ProvincePoints(
2✔
4233
                               {{4, 1}, {4, 2}, {4, 3}, {5, 1}, {5, 2}, {5, 3}, {6, 1}, {6, 2}, {6, 3}})},
4234
                       {"3",
4235
                           maps::ProvincePoints(
2✔
4236
                               {{1, 4}, {1, 5}, {1, 6}, {2, 4}, {2, 5}, {2, 6}, {3, 4}, {3, 5}, {3, 6}})},
4237
                       {"4",
4238
                           maps::ProvincePoints(
2✔
4239
                               {{4, 4}, {4, 5}, {4, 6}, {5, 4}, {5, 5}, {5, 6}, {6, 4}, {6, 5}, {6, 6}})},
4240
                   }}),
4✔
4241
       commonItems::ModFilesystem{"test_files/Hoi4worldMapBuildingsCreatorTests/DefaultsExist", {}});
2✔
4242

4243
   EXPECT_THAT(buildings.GetBuildings(),
3✔
4244
       testing::IsSupersetOf({Building({.state_id = 1,
4245
           .type = "synthetic_refinery",
4246
           .position = {.x_coordinate = 2.0, .y_coordinate = 11.0, .z_coordinate = 2.0, .rotation = 0.0}})}));
1✔
4247
}
17✔
4248

4249

4250
TEST(Hoi4worldMapBuildingsCreatorTests, RocketSitePlacedInCenterOfFirstProvinceOfState)
4✔
4251
{
4252
   const Buildings buildings = ImportBuildings(States({.states = {State(1, {.provinces = {1, 2, 3, 4, 5}})},
1✔
4253
                                                   .province_to_state_id_map =
4254
                                                       {
4255
                                                           {1, 1},
4256
                                                           {2, 1},
4257
                                                           {3, 1},
4258
                                                           {4, 1},
4259
                                                           {5, 1},
4260
                                                       }}),
1✔
4261
       CoastalProvinces(),
1✔
4262
       maps::MapData(
1✔
4263
           {.the_province_points =
4264
                   {
4265
                       {"1",
4266
                           maps::ProvincePoints(
2✔
4267
                               {{1, 1}, {1, 2}, {1, 3}, {2, 1}, {2, 2}, {2, 3}, {3, 1}, {3, 2}, {3, 3}})},
4268
                       {"2",
4269
                           maps::ProvincePoints(
2✔
4270
                               {{4, 1}, {4, 2}, {4, 3}, {5, 1}, {5, 2}, {5, 3}, {6, 1}, {6, 2}, {6, 3}})},
4271
                       {"3",
4272
                           maps::ProvincePoints(
2✔
4273
                               {{1, 4}, {1, 5}, {1, 6}, {2, 4}, {2, 5}, {2, 6}, {3, 4}, {3, 5}, {3, 6}})},
4274
                       {"4",
4275
                           maps::ProvincePoints(
2✔
4276
                               {{4, 4}, {4, 5}, {4, 6}, {5, 4}, {5, 5}, {5, 6}, {6, 4}, {6, 5}, {6, 6}})},
4277
                   }}),
4✔
4278
       commonItems::ModFilesystem{"test_files/Hoi4worldMapBuildingsCreatorTests/DefaultsToNoBuildings", {}});
2✔
4279

4280
   EXPECT_THAT(buildings.GetBuildings(),
3✔
4281
       testing::IsSupersetOf({Building({.state_id = 1,
4282
           .type = "rocket_site_spawn",
4283
           .position = {.x_coordinate = 2.0, .y_coordinate = 11.0, .z_coordinate = 2.0, .rotation = 0.0}})}));
1✔
4284
}
17✔
4285

4286

4287
TEST(Hoi4worldMapBuildingsCreatorTests, NoRocketSiteInStateWithNoProvinces)
4✔
4288
{
4289
   const Buildings buildings = ImportBuildings(States({.states = {State(1, {})},
1✔
4290
                                                   .province_to_state_id_map =
4291
                                                       {
4292
                                                           {1, 1},
4293
                                                           {2, 1},
4294
                                                           {3, 1},
4295
                                                           {4, 1},
4296
                                                           {5, 1},
4297
                                                       }}),
1✔
4298
       CoastalProvinces(),
1✔
4299
       maps::MapData(
1✔
4300
           {.the_province_points =
4301
                   {
4302
                       {"1",
4303
                           maps::ProvincePoints(
2✔
4304
                               {{1, 1}, {1, 2}, {1, 3}, {2, 1}, {2, 2}, {2, 3}, {3, 1}, {3, 2}, {3, 3}})},
4305
                       {"2",
4306
                           maps::ProvincePoints(
2✔
4307
                               {{4, 1}, {4, 2}, {4, 3}, {5, 1}, {5, 2}, {5, 3}, {6, 1}, {6, 2}, {6, 3}})},
4308
                       {"3",
4309
                           maps::ProvincePoints(
2✔
4310
                               {{1, 4}, {1, 5}, {1, 6}, {2, 4}, {2, 5}, {2, 6}, {3, 4}, {3, 5}, {3, 6}})},
4311
                       {"4",
4312
                           maps::ProvincePoints(
2✔
4313
                               {{4, 4}, {4, 5}, {4, 6}, {5, 4}, {5, 5}, {5, 6}, {6, 4}, {6, 5}, {6, 6}})},
4314
                   }}),
4✔
4315
       commonItems::ModFilesystem{"test_files/Hoi4worldMapBuildingsCreatorTests/DefaultsToNoBuildings", {}});
2✔
4316

4317
   EXPECT_TRUE(buildings.GetBuildings().empty());
1✔
4318
}
15✔
4319

4320

4321
TEST(Hoi4worldMapBuildingsCreatorTests, RocketSiteNotPlacedInProvincesWithNoPoints)
4✔
4322
{
4323
   std::stringstream log;
1✔
4324
   std::streambuf* cout_buffer = std::cout.rdbuf();
1✔
4325
   std::cout.rdbuf(log.rdbuf());
1✔
4326

4327
   const Buildings buildings = ImportBuildings(States({.states = {State(1, {.provinces = {1, 2, 3, 4, 5}})},
1✔
4328
                                                   .province_to_state_id_map =
4329
                                                       {
4330
                                                           {1, 1},
4331
                                                           {2, 1},
4332
                                                           {3, 1},
4333
                                                           {4, 1},
4334
                                                           {5, 1},
4335
                                                       }}),
1✔
4336
       CoastalProvinces(),
1✔
4337
       maps::MapData(),
2✔
4338
       commonItems::ModFilesystem{"test_files/Hoi4worldMapBuildingsCreatorTests/DefaultsToNoBuildings", {}});
2✔
4339

4340
   std::cout.rdbuf(cout_buffer);
1✔
4341

4342
   EXPECT_TRUE(buildings.GetBuildings().empty());
1✔
4343
   EXPECT_THAT(log.str(),
1✔
4344
       testing::HasSubstr("[WARNING] Province 1 did not have any points. rocket_site_spawn not fully set in state 1."));
1✔
4345
   EXPECT_THAT(log.str(),
1✔
4346
       testing::HasSubstr("[WARNING] Province 2 did not have any points. rocket_site_spawn not fully set in state 1."));
1✔
4347
   EXPECT_THAT(log.str(),
1✔
4348
       testing::HasSubstr("[WARNING] Province 3 did not have any points. rocket_site_spawn not fully set in state 1."));
1✔
4349
   EXPECT_THAT(log.str(),
1✔
4350
       testing::HasSubstr("[WARNING] Province 4 did not have any points. rocket_site_spawn not fully set in state 1."));
1✔
4351
}
4✔
4352

4353

4354
TEST(Hoi4worldMapBuildingsCreatorTests, RocketSitePlacementOverridenByDefaultLocations)
4✔
4355
{
4356
   const Buildings
4357
       buildings =
4358
           ImportBuildings(States({.states = {State(1, {.provinces = {1, 2, 3, 4, 5}})},
1✔
4359
                               .province_to_state_id_map =
4360
                                   {
4361
                                       {1, 1},
4362
                                       {2, 1},
4363
                                       {3, 1},
4364
                                       {4, 1},
4365
                                       {5, 1},
4366
                                   }}),
1✔
4367
               CoastalProvinces(),
1✔
4368
               maps::MapData(
1✔
4369
                   {.the_province_points =
4370
                           {
4371
                               {"1",
4372
                                   maps::ProvincePoints(
2✔
4373
                                       {{1, 1}, {1, 2}, {1, 3}, {2, 1}, {2, 2}, {2, 3}, {3, 1}, {3, 2}, {3, 3}})},
4374
                               {"2",
4375
                                   maps::ProvincePoints(
2✔
4376
                                       {{4, 1}, {4, 2}, {4, 3}, {5, 1}, {5, 2}, {5, 3}, {6, 1}, {6, 2}, {6, 3}})},
4377
                               {"3",
4378
                                   maps::ProvincePoints(
2✔
4379
                                       {{1, 4}, {1, 5}, {1, 6}, {2, 4}, {2, 5}, {2, 6}, {3, 4}, {3, 5}, {3, 6}})},
4380
                               {"4",
4381
                                   maps::ProvincePoints(
2✔
4382
                                       {{4, 4}, {4, 5}, {4, 6}, {5, 4}, {5, 5}, {5, 6}, {6, 4}, {6, 5}, {6, 6}})},
4383
                           },
4384
                       .points_to_provinces =
4385
                           {
4386
                               {{4, 1}, "2"},
4387
                               {{1, 4}, "3"},
4388
                               {{4, 4}, "4"},
4389
                           }}),
13✔
4390
               commonItems::ModFilesystem{"test_files/Hoi4worldMapBuildingsCreatorTests/DefaultsExist", {}});
2✔
4391

4392
   EXPECT_THAT(buildings.GetBuildings(),
3✔
4393
       testing::IsSupersetOf({Building({.state_id = 1,
4394
           .type = "rocket_site_spawn",
4395
           .position = {.x_coordinate = 4.0, .y_coordinate = 6.0, .z_coordinate = 1.0, .rotation = 90.0}})}));
1✔
4396
}
26✔
4397

4398

4399
TEST(Hoi4worldMapBuildingsCreatorTests, RocketSitePlacedInCenterOfFirstProvinceOfStateIfDefaultNotInState)
4✔
4400
{
4401
   const Buildings buildings = ImportBuildings(States({.states = {State(1, {.provinces = {1, 2, 3, 4, 5}})},
1✔
4402
                                                   .province_to_state_id_map =
4403
                                                       {
4404
                                                           {1, 1},
4405
                                                           {2, 1},
4406
                                                           {3, 1},
4407
                                                           {4, 1},
4408
                                                           {5, 1},
4409
                                                       }}),
1✔
4410
       CoastalProvinces(),
1✔
4411
       maps::MapData(
1✔
4412
           {.the_province_points =
4413
                   {
4414
                       {"1",
4415
                           maps::ProvincePoints(
2✔
4416
                               {{1, 1}, {1, 2}, {1, 3}, {2, 1}, {2, 2}, {2, 3}, {3, 1}, {3, 2}, {3, 3}})},
4417
                       {"2",
4418
                           maps::ProvincePoints(
2✔
4419
                               {{4, 1}, {4, 2}, {4, 3}, {5, 1}, {5, 2}, {5, 3}, {6, 1}, {6, 2}, {6, 3}})},
4420
                       {"3",
4421
                           maps::ProvincePoints(
2✔
4422
                               {{1, 4}, {1, 5}, {1, 6}, {2, 4}, {2, 5}, {2, 6}, {3, 4}, {3, 5}, {3, 6}})},
4423
                       {"4",
4424
                           maps::ProvincePoints(
2✔
4425
                               {{4, 4}, {4, 5}, {4, 6}, {5, 4}, {5, 5}, {5, 6}, {6, 4}, {6, 5}, {6, 6}})},
4426
                   }}),
4✔
4427
       commonItems::ModFilesystem{"test_files/Hoi4worldMapBuildingsCreatorTests/DefaultsExist", {}});
2✔
4428

4429
   EXPECT_THAT(buildings.GetBuildings(),
3✔
4430
       testing::IsSupersetOf({Building({.state_id = 1,
4431
           .type = "rocket_site_spawn",
4432
           .position = {.x_coordinate = 2.0, .y_coordinate = 11.0, .z_coordinate = 2.0, .rotation = 0.0}})}));
1✔
4433
}
17✔
4434

4435

4436
TEST(Hoi4worldMapBuildingsCreatorTests, RadarStationPlacedInCenterOfFirstProvinceOfState)
4✔
4437
{
4438
   const Buildings buildings = ImportBuildings(States({.states = {State(1, {.provinces = {1, 2, 3, 4, 5}})},
1✔
4439
                                                   .province_to_state_id_map =
4440
                                                       {
4441
                                                           {1, 1},
4442
                                                           {2, 1},
4443
                                                           {3, 1},
4444
                                                           {4, 1},
4445
                                                           {5, 1},
4446
                                                       }}),
1✔
4447
       CoastalProvinces(),
1✔
4448
       maps::MapData(
1✔
4449
           {.the_province_points =
4450
                   {
4451
                       {"1",
4452
                           maps::ProvincePoints(
2✔
4453
                               {{1, 1}, {1, 2}, {1, 3}, {2, 1}, {2, 2}, {2, 3}, {3, 1}, {3, 2}, {3, 3}})},
4454
                       {"2",
4455
                           maps::ProvincePoints(
2✔
4456
                               {{4, 1}, {4, 2}, {4, 3}, {5, 1}, {5, 2}, {5, 3}, {6, 1}, {6, 2}, {6, 3}})},
4457
                       {"3",
4458
                           maps::ProvincePoints(
2✔
4459
                               {{1, 4}, {1, 5}, {1, 6}, {2, 4}, {2, 5}, {2, 6}, {3, 4}, {3, 5}, {3, 6}})},
4460
                       {"4",
4461
                           maps::ProvincePoints(
2✔
4462
                               {{4, 4}, {4, 5}, {4, 6}, {5, 4}, {5, 5}, {5, 6}, {6, 4}, {6, 5}, {6, 6}})},
4463
                   }}),
4✔
4464
       commonItems::ModFilesystem{"test_files/Hoi4worldMapBuildingsCreatorTests/DefaultsToNoBuildings", {}});
2✔
4465

4466
   EXPECT_THAT(buildings.GetBuildings(),
3✔
4467
       testing::IsSupersetOf({Building({.state_id = 1,
4468
           .type = "radar_station",
4469
           .position = {.x_coordinate = 2.0, .y_coordinate = 11.0, .z_coordinate = 2.0, .rotation = 0.0}})}));
1✔
4470
}
17✔
4471

4472

4473
TEST(Hoi4worldMapBuildingsCreatorTests, NoRadarStationInStateWithNoProvinces)
4✔
4474
{
4475
   const Buildings buildings = ImportBuildings(States({.states = {State(1, {})},
1✔
4476
                                                   .province_to_state_id_map =
4477
                                                       {
4478
                                                           {1, 1},
4479
                                                           {2, 1},
4480
                                                           {3, 1},
4481
                                                           {4, 1},
4482
                                                           {5, 1},
4483
                                                       }}),
1✔
4484
       CoastalProvinces(),
1✔
4485
       maps::MapData(
1✔
4486
           {.the_province_points =
4487
                   {
4488
                       {"1",
4489
                           maps::ProvincePoints(
2✔
4490
                               {{1, 1}, {1, 2}, {1, 3}, {2, 1}, {2, 2}, {2, 3}, {3, 1}, {3, 2}, {3, 3}})},
4491
                       {"2",
4492
                           maps::ProvincePoints(
2✔
4493
                               {{4, 1}, {4, 2}, {4, 3}, {5, 1}, {5, 2}, {5, 3}, {6, 1}, {6, 2}, {6, 3}})},
4494
                       {"3",
4495
                           maps::ProvincePoints(
2✔
4496
                               {{1, 4}, {1, 5}, {1, 6}, {2, 4}, {2, 5}, {2, 6}, {3, 4}, {3, 5}, {3, 6}})},
4497
                       {"4",
4498
                           maps::ProvincePoints(
2✔
4499
                               {{4, 4}, {4, 5}, {4, 6}, {5, 4}, {5, 5}, {5, 6}, {6, 4}, {6, 5}, {6, 6}})},
4500
                   }}),
4✔
4501
       commonItems::ModFilesystem{"test_files/Hoi4worldMapBuildingsCreatorTests/DefaultsToNoBuildings", {}});
2✔
4502

4503
   EXPECT_TRUE(buildings.GetBuildings().empty());
1✔
4504
}
15✔
4505

4506

4507
TEST(Hoi4worldMapBuildingsCreatorTests, RadarStationNotPlacedInProvincesWithNoPoints)
4✔
4508
{
4509
   std::stringstream log;
1✔
4510
   std::streambuf* cout_buffer = std::cout.rdbuf();
1✔
4511
   std::cout.rdbuf(log.rdbuf());
1✔
4512

4513
   const Buildings buildings = ImportBuildings(States({.states = {State(1, {.provinces = {1, 2, 3, 4, 5}})},
1✔
4514
                                                   .province_to_state_id_map =
4515
                                                       {
4516
                                                           {1, 1},
4517
                                                           {2, 1},
4518
                                                           {3, 1},
4519
                                                           {4, 1},
4520
                                                           {5, 1},
4521
                                                       }}),
1✔
4522
       CoastalProvinces(),
1✔
4523
       maps::MapData(),
2✔
4524
       commonItems::ModFilesystem{"test_files/Hoi4worldMapBuildingsCreatorTests/DefaultsToNoBuildings", {}});
2✔
4525

4526
   std::cout.rdbuf(cout_buffer);
1✔
4527

4528
   EXPECT_TRUE(buildings.GetBuildings().empty());
1✔
4529
   EXPECT_THAT(log.str(),
1✔
4530
       testing::HasSubstr("[WARNING] Province 1 did not have any points. radar_station not fully set in state 1."));
1✔
4531
   EXPECT_THAT(log.str(),
1✔
4532
       testing::HasSubstr("[WARNING] Province 2 did not have any points. radar_station not fully set in state 1."));
1✔
4533
   EXPECT_THAT(log.str(),
1✔
4534
       testing::HasSubstr("[WARNING] Province 3 did not have any points. radar_station not fully set in state 1."));
1✔
4535
   EXPECT_THAT(log.str(),
1✔
4536
       testing::HasSubstr("[WARNING] Province 4 did not have any points. radar_station not fully set in state 1."));
1✔
4537
}
4✔
4538

4539

4540
TEST(Hoi4worldMapBuildingsCreatorTests, RadarStationPlacementOverridenByDefaultLocations)
4✔
4541
{
4542
   const Buildings
4543
       buildings =
4544
           ImportBuildings(States({.states = {State(1, {.provinces = {1, 2, 3, 4, 5}})},
1✔
4545
                               .province_to_state_id_map =
4546
                                   {
4547
                                       {1, 1},
4548
                                       {2, 1},
4549
                                       {3, 1},
4550
                                       {4, 1},
4551
                                       {5, 1},
4552
                                   }}),
1✔
4553
               CoastalProvinces(),
1✔
4554
               maps::MapData(
1✔
4555
                   {.the_province_points =
4556
                           {
4557
                               {"1",
4558
                                   maps::ProvincePoints(
2✔
4559
                                       {{1, 1}, {1, 2}, {1, 3}, {2, 1}, {2, 2}, {2, 3}, {3, 1}, {3, 2}, {3, 3}})},
4560
                               {"2",
4561
                                   maps::ProvincePoints(
2✔
4562
                                       {{4, 1}, {4, 2}, {4, 3}, {5, 1}, {5, 2}, {5, 3}, {6, 1}, {6, 2}, {6, 3}})},
4563
                               {"3",
4564
                                   maps::ProvincePoints(
2✔
4565
                                       {{1, 4}, {1, 5}, {1, 6}, {2, 4}, {2, 5}, {2, 6}, {3, 4}, {3, 5}, {3, 6}})},
4566
                               {"4",
4567
                                   maps::ProvincePoints(
2✔
4568
                                       {{4, 4}, {4, 5}, {4, 6}, {5, 4}, {5, 5}, {5, 6}, {6, 4}, {6, 5}, {6, 6}})},
4569
                           },
4570
                       .points_to_provinces =
4571
                           {
4572
                               {{4, 1}, "2"},
4573
                               {{1, 4}, "3"},
4574
                               {{4, 4}, "4"},
4575
                           }}),
13✔
4576
               commonItems::ModFilesystem{"test_files/Hoi4worldMapBuildingsCreatorTests/DefaultsExist", {}});
2✔
4577

4578
   EXPECT_THAT(buildings.GetBuildings(),
3✔
4579
       testing::IsSupersetOf({Building({.state_id = 1,
4580
           .type = "radar_station",
4581
           .position = {.x_coordinate = 4.0, .y_coordinate = 6.0, .z_coordinate = 1.0, .rotation = 90.0}})}));
1✔
4582
}
26✔
4583

4584

4585
TEST(Hoi4worldMapBuildingsCreatorTests, RadarStationPlacedInCenterOfFirstProvinceOfStateIfDefaultNotInState)
4✔
4586
{
4587
   const Buildings buildings = ImportBuildings(States({.states = {State(1, {.provinces = {1, 2, 3, 4, 5}})},
1✔
4588
                                                   .province_to_state_id_map =
4589
                                                       {
4590
                                                           {1, 1},
4591
                                                           {2, 1},
4592
                                                           {3, 1},
4593
                                                           {4, 1},
4594
                                                           {5, 1},
4595
                                                       }}),
1✔
4596
       CoastalProvinces(),
1✔
4597
       maps::MapData(
1✔
4598
           {.the_province_points =
4599
                   {
4600
                       {"1",
4601
                           maps::ProvincePoints(
2✔
4602
                               {{1, 1}, {1, 2}, {1, 3}, {2, 1}, {2, 2}, {2, 3}, {3, 1}, {3, 2}, {3, 3}})},
4603
                       {"2",
4604
                           maps::ProvincePoints(
2✔
4605
                               {{4, 1}, {4, 2}, {4, 3}, {5, 1}, {5, 2}, {5, 3}, {6, 1}, {6, 2}, {6, 3}})},
4606
                       {"3",
4607
                           maps::ProvincePoints(
2✔
4608
                               {{1, 4}, {1, 5}, {1, 6}, {2, 4}, {2, 5}, {2, 6}, {3, 4}, {3, 5}, {3, 6}})},
4609
                       {"4",
4610
                           maps::ProvincePoints(
2✔
4611
                               {{4, 4}, {4, 5}, {4, 6}, {5, 4}, {5, 5}, {5, 6}, {6, 4}, {6, 5}, {6, 6}})},
4612
                   }}),
4✔
4613
       commonItems::ModFilesystem{"test_files/Hoi4worldMapBuildingsCreatorTests/DefaultsExist", {}});
2✔
4614

4615
   EXPECT_THAT(buildings.GetBuildings(),
3✔
4616
       testing::IsSupersetOf({Building({.state_id = 1,
4617
           .type = "radar_station",
4618
           .position = {.x_coordinate = 2.0, .y_coordinate = 11.0, .z_coordinate = 2.0, .rotation = 0.0}})}));
1✔
4619
}
17✔
4620

4621
TEST(Hoi4worldMapBuildingsCreatorTests, FuelSiloPlacedInCenterOfFirstProvinceOfState)
4✔
4622
{
4623
   const Buildings buildings = ImportBuildings(States({.states = {State(1, {.provinces = {1, 2, 3, 4, 5}})},
1✔
4624
                                                   .province_to_state_id_map =
4625
                                                       {
4626
                                                           {1, 1},
4627
                                                           {2, 1},
4628
                                                           {3, 1},
4629
                                                           {4, 1},
4630
                                                           {5, 1},
4631
                                                       }}),
1✔
4632
       CoastalProvinces(),
1✔
4633
       maps::MapData(
1✔
4634
           {.the_province_points =
4635
                   {
4636
                       {"1",
4637
                           maps::ProvincePoints(
2✔
4638
                               {{1, 1}, {1, 2}, {1, 3}, {2, 1}, {2, 2}, {2, 3}, {3, 1}, {3, 2}, {3, 3}})},
4639
                       {"2",
4640
                           maps::ProvincePoints(
2✔
4641
                               {{4, 1}, {4, 2}, {4, 3}, {5, 1}, {5, 2}, {5, 3}, {6, 1}, {6, 2}, {6, 3}})},
4642
                       {"3",
4643
                           maps::ProvincePoints(
2✔
4644
                               {{1, 4}, {1, 5}, {1, 6}, {2, 4}, {2, 5}, {2, 6}, {3, 4}, {3, 5}, {3, 6}})},
4645
                       {"4",
4646
                           maps::ProvincePoints(
2✔
4647
                               {{4, 4}, {4, 5}, {4, 6}, {5, 4}, {5, 5}, {5, 6}, {6, 4}, {6, 5}, {6, 6}})},
4648
                   }}),
4✔
4649
       commonItems::ModFilesystem{"test_files/Hoi4worldMapBuildingsCreatorTests/DefaultsToNoBuildings", {}});
2✔
4650

4651
   EXPECT_THAT(buildings.GetBuildings(),
3✔
4652
       testing::IsSupersetOf({Building({.state_id = 1,
4653
           .type = "fuel_silo",
4654
           .position = {.x_coordinate = 2.0, .y_coordinate = 11.0, .z_coordinate = 2.0, .rotation = 0.0}})}));
1✔
4655
}
17✔
4656

4657

4658
TEST(Hoi4worldMapBuildingsCreatorTests, NoFuelSiloInStateWithNoProvinces)
4✔
4659
{
4660
   const Buildings buildings = ImportBuildings(States({.states = {State(1, {})},
1✔
4661
                                                   .province_to_state_id_map =
4662
                                                       {
4663
                                                           {1, 1},
4664
                                                           {2, 1},
4665
                                                           {3, 1},
4666
                                                           {4, 1},
4667
                                                           {5, 1},
4668
                                                       }}),
1✔
4669
       CoastalProvinces(),
1✔
4670
       maps::MapData(
1✔
4671
           {.the_province_points =
4672
                   {
4673
                       {"1",
4674
                           maps::ProvincePoints(
2✔
4675
                               {{1, 1}, {1, 2}, {1, 3}, {2, 1}, {2, 2}, {2, 3}, {3, 1}, {3, 2}, {3, 3}})},
4676
                       {"2",
4677
                           maps::ProvincePoints(
2✔
4678
                               {{4, 1}, {4, 2}, {4, 3}, {5, 1}, {5, 2}, {5, 3}, {6, 1}, {6, 2}, {6, 3}})},
4679
                       {"3",
4680
                           maps::ProvincePoints(
2✔
4681
                               {{1, 4}, {1, 5}, {1, 6}, {2, 4}, {2, 5}, {2, 6}, {3, 4}, {3, 5}, {3, 6}})},
4682
                       {"4",
4683
                           maps::ProvincePoints(
2✔
4684
                               {{4, 4}, {4, 5}, {4, 6}, {5, 4}, {5, 5}, {5, 6}, {6, 4}, {6, 5}, {6, 6}})},
4685
                   }}),
4✔
4686
       commonItems::ModFilesystem{"test_files/Hoi4worldMapBuildingsCreatorTests/DefaultsToNoBuildings", {}});
2✔
4687

4688
   EXPECT_TRUE(buildings.GetBuildings().empty());
1✔
4689
}
15✔
4690

4691

4692
TEST(Hoi4worldMapBuildingsCreatorTests, FuelSiloNotPlacedInProvincesWithNoPoints)
4✔
4693
{
4694
   std::stringstream log;
1✔
4695
   std::streambuf* cout_buffer = std::cout.rdbuf();
1✔
4696
   std::cout.rdbuf(log.rdbuf());
1✔
4697

4698
   const Buildings buildings = ImportBuildings(States({.states = {State(1, {.provinces = {1, 2, 3, 4, 5}})},
1✔
4699
                                                   .province_to_state_id_map =
4700
                                                       {
4701
                                                           {1, 1},
4702
                                                           {2, 1},
4703
                                                           {3, 1},
4704
                                                           {4, 1},
4705
                                                           {5, 1},
4706
                                                       }}),
1✔
4707
       CoastalProvinces(),
1✔
4708
       maps::MapData(),
2✔
4709
       commonItems::ModFilesystem{"test_files/Hoi4worldMapBuildingsCreatorTests/DefaultsToNoBuildings", {}});
2✔
4710

4711
   std::cout.rdbuf(cout_buffer);
1✔
4712

4713
   EXPECT_TRUE(buildings.GetBuildings().empty());
1✔
4714
   EXPECT_THAT(log.str(),
1✔
4715
       testing::HasSubstr("[WARNING] Province 1 did not have any points. fuel_silo not fully set in state 1."));
1✔
4716
   EXPECT_THAT(log.str(),
1✔
4717
       testing::HasSubstr("[WARNING] Province 2 did not have any points. fuel_silo not fully set in state 1."));
1✔
4718
   EXPECT_THAT(log.str(),
1✔
4719
       testing::HasSubstr("[WARNING] Province 3 did not have any points. fuel_silo not fully set in state 1."));
1✔
4720
   EXPECT_THAT(log.str(),
1✔
4721
       testing::HasSubstr("[WARNING] Province 4 did not have any points. fuel_silo not fully set in state 1."));
1✔
4722
}
4✔
4723

4724

4725
TEST(Hoi4worldMapBuildingsCreatorTests, FuelSiloPlacementOverridenByDefaultLocations)
4✔
4726
{
4727
   const Buildings
4728
       buildings =
4729
           ImportBuildings(States({.states = {State(1, {.provinces = {1, 2, 3, 4, 5}})},
1✔
4730
                               .province_to_state_id_map =
4731
                                   {
4732
                                       {1, 1},
4733
                                       {2, 1},
4734
                                       {3, 1},
4735
                                       {4, 1},
4736
                                       {5, 1},
4737
                                   }}),
1✔
4738
               CoastalProvinces(),
1✔
4739
               maps::MapData(
1✔
4740
                   {.the_province_points =
4741
                           {
4742
                               {"1",
4743
                                   maps::ProvincePoints(
2✔
4744
                                       {{1, 1}, {1, 2}, {1, 3}, {2, 1}, {2, 2}, {2, 3}, {3, 1}, {3, 2}, {3, 3}})},
4745
                               {"2",
4746
                                   maps::ProvincePoints(
2✔
4747
                                       {{4, 1}, {4, 2}, {4, 3}, {5, 1}, {5, 2}, {5, 3}, {6, 1}, {6, 2}, {6, 3}})},
4748
                               {"3",
4749
                                   maps::ProvincePoints(
2✔
4750
                                       {{1, 4}, {1, 5}, {1, 6}, {2, 4}, {2, 5}, {2, 6}, {3, 4}, {3, 5}, {3, 6}})},
4751
                               {"4",
4752
                                   maps::ProvincePoints(
2✔
4753
                                       {{4, 4}, {4, 5}, {4, 6}, {5, 4}, {5, 5}, {5, 6}, {6, 4}, {6, 5}, {6, 6}})},
4754
                           },
4755
                       .points_to_provinces =
4756
                           {
4757
                               {{4, 1}, "2"},
4758
                               {{1, 4}, "3"},
4759
                               {{4, 4}, "4"},
4760
                           }}),
13✔
4761
               commonItems::ModFilesystem{"test_files/Hoi4worldMapBuildingsCreatorTests/DefaultsExist", {}});
2✔
4762

4763
   EXPECT_THAT(buildings.GetBuildings(),
3✔
4764
       testing::IsSupersetOf({Building({.state_id = 1,
4765
           .type = "fuel_silo",
4766
           .position = {.x_coordinate = 4.0, .y_coordinate = 6.0, .z_coordinate = 1.0, .rotation = 90.0}})}));
1✔
4767
}
26✔
4768

4769

4770
TEST(Hoi4worldMapBuildingsCreatorTests, FuelSiloPlacedInCenterOfFirstProvinceOfStateIfDefaultNotInState)
4✔
4771
{
4772
   const Buildings buildings = ImportBuildings(States({.states = {State(1, {.provinces = {1, 2, 3, 4, 5}})},
1✔
4773
                                                   .province_to_state_id_map =
4774
                                                       {
4775
                                                           {1, 1},
4776
                                                           {2, 1},
4777
                                                           {3, 1},
4778
                                                           {4, 1},
4779
                                                           {5, 1},
4780
                                                       }}),
1✔
4781
       CoastalProvinces(),
1✔
4782
       maps::MapData(
1✔
4783
           {.the_province_points =
4784
                   {
4785
                       {"1",
4786
                           maps::ProvincePoints(
2✔
4787
                               {{1, 1}, {1, 2}, {1, 3}, {2, 1}, {2, 2}, {2, 3}, {3, 1}, {3, 2}, {3, 3}})},
4788
                       {"2",
4789
                           maps::ProvincePoints(
2✔
4790
                               {{4, 1}, {4, 2}, {4, 3}, {5, 1}, {5, 2}, {5, 3}, {6, 1}, {6, 2}, {6, 3}})},
4791
                       {"3",
4792
                           maps::ProvincePoints(
2✔
4793
                               {{1, 4}, {1, 5}, {1, 6}, {2, 4}, {2, 5}, {2, 6}, {3, 4}, {3, 5}, {3, 6}})},
4794
                       {"4",
4795
                           maps::ProvincePoints(
2✔
4796
                               {{4, 4}, {4, 5}, {4, 6}, {5, 4}, {5, 5}, {5, 6}, {6, 4}, {6, 5}, {6, 6}})},
4797
                   }}),
4✔
4798
       commonItems::ModFilesystem{"test_files/Hoi4worldMapBuildingsCreatorTests/DefaultsExist", {}});
2✔
4799

4800
   EXPECT_THAT(buildings.GetBuildings(),
3✔
4801
       testing::IsSupersetOf({Building({.state_id = 1,
4802
           .type = "fuel_silo",
4803
           .position = {.x_coordinate = 2.0, .y_coordinate = 11.0, .z_coordinate = 2.0, .rotation = 0.0}})}));
1✔
4804
}
17✔
4805

4806

4807
TEST(Hoi4worldMapBuildingsCreatorTests, SpecialProjectFacilitesPlacedIndefaultLocationsAndOnlyInDefaultLocations)
4✔
4808
{
4809
   const Buildings
4810
       buildings =
4811
           ImportBuildings(States({.states =
1✔
4812
                                       {
4813
                                           State(1, {.provinces = {1, 2, 3, 4, 5}}),
4814
                                           State(2, {.provinces = {6, 7, 8, 9, 10}}),
4815
                                           State(3, {.provinces = {11, 12, 13, 14, 15}}),
4816
                                       },
4817
                               .province_to_state_id_map =
4818
                                   {
4819
                                       {1, 1},
4820
                                       {2, 1},
4821
                                       {3, 1},
4822
                                       {4, 1},
4823
                                       {5, 1},
4824
                                       {6, 2},
4825
                                       {7, 2},
4826
                                       {8, 2},
4827
                                       {9, 2},
4828
                                       {10, 2},
4829
                                       {11, 3},
4830
                                       {12, 3},
4831
                                       {13, 3},
4832
                                       {14, 3},
4833
                                       {15, 3},
4834
                                   }}),
3✔
4835
               CoastalProvinces(),
1✔
4836
               maps::MapData(
1✔
4837
                   {.the_province_points =
4838
                           {
4839
                               {"1",
4840
                                   maps::ProvincePoints(
2✔
4841
                                       {{1, 1}, {1, 2}, {1, 3}, {2, 1}, {2, 2}, {2, 3}, {3, 1}, {3, 2}, {3, 3}})},
4842
                               {"4",
4843
                                   maps::ProvincePoints(
2✔
4844
                                       {{4, 4}, {4, 5}, {4, 6}, {5, 4}, {5, 5}, {5, 6}, {6, 4}, {6, 5}, {6, 6}})},
4845
                               {"7",
4846
                                   maps::ProvincePoints(
2✔
4847
                                       {{7, 7}, {7, 8}, {7, 9}, {8, 7}, {8, 8}, {8, 9}, {9, 7}, {9, 8}, {9, 9}})},
4848
                           },
4849
                       .points_to_provinces =
4850
                           {
4851
                               {{1, 3}, "1"},
4852
                               {{4, 6}, "4"},
4853
                               {{7, 9}, "7"},
4854
                           }}),
12✔
4855
               commonItems::ModFilesystem{"test_files/Hoi4worldMapBuildingsCreatorTests/DefaultsExist", {}});
2✔
4856

4857
   EXPECT_THAT(buildings.GetBuildings(),
5✔
4858
       testing::IsSupersetOf({
4859
           Building({.state_id = 1,
4860
               .type = "special_project_facility_spawn",
4861
               .position = {.x_coordinate = 1.0, .y_coordinate = 3.0, .z_coordinate = 3.0, .rotation = 90.0}}),
4862
           Building({.state_id = 1,
4863
               .type = "special_project_facility_spawn",
4864
               .position = {.x_coordinate = 4.0, .y_coordinate = 6.0, .z_coordinate = 6.0, .rotation = 135.0}}),
4865
           Building({.state_id = 2,
4866
               .type = "special_project_facility_spawn",
4867
               .position = {.x_coordinate = 7.0, .y_coordinate = 9.0, .z_coordinate = 9.0, .rotation = 180.0}}),
4868
       }));
1✔
4869
}
26✔
4870

4871

4872
TEST(Hoi4worldMapBuildingsCreatorTests, LandmarksPlacedIndefaultLocationsAndOnlyInDefaultLocations)
4✔
4873
{
4874
   const Buildings
4875
       buildings =
4876
           ImportBuildings(States({.states =
1✔
4877
                                       {
4878
                                           State(1, {.provinces = {1, 2, 3, 4, 5}}),
4879
                                           State(2, {.provinces = {6, 7, 8, 9, 10}}),
4880
                                           State(3, {.provinces = {11, 12, 13, 14, 15}}),
4881
                                       },
4882
                               .province_to_state_id_map =
4883
                                   {
4884
                                       {1, 1},
4885
                                       {2, 1},
4886
                                       {3, 1},
4887
                                       {4, 1},
4888
                                       {5, 1},
4889
                                       {6, 2},
4890
                                       {7, 2},
4891
                                       {8, 2},
4892
                                       {9, 2},
4893
                                       {10, 2},
4894
                                       {11, 3},
4895
                                       {12, 3},
4896
                                       {13, 3},
4897
                                       {14, 3},
4898
                                       {15, 3},
4899
                                   }}),
3✔
4900
               CoastalProvinces(),
1✔
4901
               maps::MapData(
1✔
4902
                   {.the_province_points =
4903
                           {
4904
                               {"1",
4905
                                   maps::ProvincePoints(
2✔
4906
                                       {{1, 1}, {1, 2}, {1, 3}, {2, 1}, {2, 2}, {2, 3}, {3, 1}, {3, 2}, {3, 3}})},
4907
                               {"4",
4908
                                   maps::ProvincePoints(
2✔
4909
                                       {{4, 4}, {4, 5}, {4, 6}, {5, 4}, {5, 5}, {5, 6}, {6, 4}, {6, 5}, {6, 6}})},
4910
                               {"7",
4911
                                   maps::ProvincePoints(
2✔
4912
                                       {{7, 7}, {7, 8}, {7, 9}, {8, 7}, {8, 8}, {8, 9}, {9, 7}, {9, 8}, {9, 9}})},
4913
                           },
4914
                       .points_to_provinces =
4915
                           {
4916
                               {{1, 3}, "1"},
4917
                               {{4, 6}, "4"},
4918
                               {{7, 9}, "7"},
4919
                           }}),
12✔
4920
               commonItems::ModFilesystem{"test_files/Hoi4worldMapBuildingsCreatorTests/DefaultsExist", {}});
2✔
4921

4922
   EXPECT_THAT(buildings.GetBuildings(),
5✔
4923
       testing::IsSupersetOf({
4924
           Building({.state_id = 1,
4925
               .type = "landmark_spawn",
4926
               .position = {.x_coordinate = 1.0, .y_coordinate = 3.0, .z_coordinate = 3.0, .rotation = 90.0}}),
4927
           Building({.state_id = 1,
4928
               .type = "landmark_spawn",
4929
               .position = {.x_coordinate = 4.0, .y_coordinate = 6.0, .z_coordinate = 6.0, .rotation = 135.0}}),
4930
           Building({.state_id = 2,
4931
               .type = "landmark_spawn",
4932
               .position = {.x_coordinate = 7.0, .y_coordinate = 9.0, .z_coordinate = 9.0, .rotation = 180.0}}),
4933
       }));
1✔
4934
}
26✔
4935

4936

4937
TEST(Hoi4worldMapBuildingsCreatorTests, StrongholdNetworkPlacedInCenterOfFirstProvinceOfState)
4✔
4938
{
4939
   const Buildings buildings = ImportBuildings(States({.states = {State(1, {.provinces = {1, 2, 3, 4, 5}})},
1✔
4940
                                                   .province_to_state_id_map =
4941
                                                       {
4942
                                                           {1, 1},
4943
                                                           {2, 1},
4944
                                                           {3, 1},
4945
                                                           {4, 1},
4946
                                                           {5, 1},
4947
                                                       }}),
1✔
4948
       CoastalProvinces(),
1✔
4949
       maps::MapData(
1✔
4950
           {.the_province_points =
4951
                   {
4952
                       {"1",
4953
                           maps::ProvincePoints(
2✔
4954
                               {{1, 1}, {1, 2}, {1, 3}, {2, 1}, {2, 2}, {2, 3}, {3, 1}, {3, 2}, {3, 3}})},
4955
                       {"2",
4956
                           maps::ProvincePoints(
2✔
4957
                               {{4, 1}, {4, 2}, {4, 3}, {5, 1}, {5, 2}, {5, 3}, {6, 1}, {6, 2}, {6, 3}})},
4958
                       {"3",
4959
                           maps::ProvincePoints(
2✔
4960
                               {{1, 4}, {1, 5}, {1, 6}, {2, 4}, {2, 5}, {2, 6}, {3, 4}, {3, 5}, {3, 6}})},
4961
                       {"4",
4962
                           maps::ProvincePoints(
2✔
4963
                               {{4, 4}, {4, 5}, {4, 6}, {5, 4}, {5, 5}, {5, 6}, {6, 4}, {6, 5}, {6, 6}})},
4964
                   }}),
4✔
4965
       commonItems::ModFilesystem{"test_files/Hoi4worldMapBuildingsCreatorTests/DefaultsToNoBuildings", {}});
2✔
4966

4967
   EXPECT_THAT(buildings.GetBuildings(),
3✔
4968
       testing::IsSupersetOf({Building({.state_id = 1,
4969
           .type = "stronghold_network",
4970
           .position = {.x_coordinate = 2.0, .y_coordinate = 11.0, .z_coordinate = 2.0, .rotation = 0.0}})}));
1✔
4971
}
17✔
4972

4973

4974
TEST(Hoi4worldMapBuildingsCreatorTests, NoStrongholdNetworkInStateWithNoProvinces)
4✔
4975
{
4976
   const Buildings buildings = ImportBuildings(States({.states = {State(1, {})},
1✔
4977
                                                   .province_to_state_id_map =
4978
                                                       {
4979
                                                           {1, 1},
4980
                                                           {2, 1},
4981
                                                           {3, 1},
4982
                                                           {4, 1},
4983
                                                           {5, 1},
4984
                                                       }}),
1✔
4985
       CoastalProvinces(),
1✔
4986
       maps::MapData(
1✔
4987
           {.the_province_points =
4988
                   {
4989
                       {"1",
4990
                           maps::ProvincePoints(
2✔
4991
                               {{1, 1}, {1, 2}, {1, 3}, {2, 1}, {2, 2}, {2, 3}, {3, 1}, {3, 2}, {3, 3}})},
4992
                       {"2",
4993
                           maps::ProvincePoints(
2✔
4994
                               {{4, 1}, {4, 2}, {4, 3}, {5, 1}, {5, 2}, {5, 3}, {6, 1}, {6, 2}, {6, 3}})},
4995
                       {"3",
4996
                           maps::ProvincePoints(
2✔
4997
                               {{1, 4}, {1, 5}, {1, 6}, {2, 4}, {2, 5}, {2, 6}, {3, 4}, {3, 5}, {3, 6}})},
4998
                       {"4",
4999
                           maps::ProvincePoints(
2✔
5000
                               {{4, 4}, {4, 5}, {4, 6}, {5, 4}, {5, 5}, {5, 6}, {6, 4}, {6, 5}, {6, 6}})},
5001
                   }}),
4✔
5002
       commonItems::ModFilesystem{"test_files/Hoi4worldMapBuildingsCreatorTests/DefaultsToNoBuildings", {}});
2✔
5003

5004
   EXPECT_TRUE(buildings.GetBuildings().empty());
1✔
5005
}
15✔
5006

5007

5008
TEST(Hoi4worldMapBuildingsCreatorTests, StrongholdNetworkNotPlacedInProvincesWithNoPoints)
4✔
5009
{
5010
   std::stringstream log;
1✔
5011
   std::streambuf* cout_buffer = std::cout.rdbuf();
1✔
5012
   std::cout.rdbuf(log.rdbuf());
1✔
5013

5014
   const Buildings buildings = ImportBuildings(States({.states = {State(1, {.provinces = {1, 2, 3, 4, 5}})},
1✔
5015
                                                   .province_to_state_id_map =
5016
                                                       {
5017
                                                           {1, 1},
5018
                                                           {2, 1},
5019
                                                           {3, 1},
5020
                                                           {4, 1},
5021
                                                           {5, 1},
5022
                                                       }}),
1✔
5023
       CoastalProvinces(),
1✔
5024
       maps::MapData(),
2✔
5025
       commonItems::ModFilesystem{"test_files/Hoi4worldMapBuildingsCreatorTests/DefaultsToNoBuildings", {}});
2✔
5026

5027
   std::cout.rdbuf(cout_buffer);
1✔
5028

5029
   EXPECT_TRUE(buildings.GetBuildings().empty());
1✔
5030
   EXPECT_THAT(log.str(),
1✔
5031
       testing::HasSubstr(
5032
           "[WARNING] Province 1 did not have any points. stronghold_network not fully set in state 1."));
1✔
5033
   EXPECT_THAT(log.str(),
1✔
5034
       testing::HasSubstr(
5035
           "[WARNING] Province 2 did not have any points. stronghold_network not fully set in state 1."));
1✔
5036
   EXPECT_THAT(log.str(),
1✔
5037
       testing::HasSubstr(
5038
           "[WARNING] Province 3 did not have any points. stronghold_network not fully set in state 1."));
1✔
5039
   EXPECT_THAT(log.str(),
1✔
5040
       testing::HasSubstr(
5041
           "[WARNING] Province 4 did not have any points. stronghold_network not fully set in state 1."));
1✔
5042
}
4✔
5043

5044

5045
TEST(Hoi4worldMapBuildingsCreatorTests, StrongholdNetworkPlacementOverridenByDefaultLocations)
4✔
5046
{
5047
   const Buildings
5048
       buildings =
5049
           ImportBuildings(States({.states = {State(1, {.provinces = {1, 2, 3, 4, 5}})},
1✔
5050
                               .province_to_state_id_map =
5051
                                   {
5052
                                       {1, 1},
5053
                                       {2, 1},
5054
                                       {3, 1},
5055
                                       {4, 1},
5056
                                       {5, 1},
5057
                                   }}),
1✔
5058
               CoastalProvinces(),
1✔
5059
               maps::MapData(
1✔
5060
                   {.the_province_points =
5061
                           {
5062
                               {"1",
5063
                                   maps::ProvincePoints(
2✔
5064
                                       {{1, 1}, {1, 2}, {1, 3}, {2, 1}, {2, 2}, {2, 3}, {3, 1}, {3, 2}, {3, 3}})},
5065
                               {"2",
5066
                                   maps::ProvincePoints(
2✔
5067
                                       {{4, 1}, {4, 2}, {4, 3}, {5, 1}, {5, 2}, {5, 3}, {6, 1}, {6, 2}, {6, 3}})},
5068
                               {"3",
5069
                                   maps::ProvincePoints(
2✔
5070
                                       {{1, 4}, {1, 5}, {1, 6}, {2, 4}, {2, 5}, {2, 6}, {3, 4}, {3, 5}, {3, 6}})},
5071
                               {"4",
5072
                                   maps::ProvincePoints(
2✔
5073
                                       {{4, 4}, {4, 5}, {4, 6}, {5, 4}, {5, 5}, {5, 6}, {6, 4}, {6, 5}, {6, 6}})},
5074
                           },
5075
                       .points_to_provinces =
5076
                           {
5077
                               {{4, 1}, "2"},
5078
                               {{1, 4}, "3"},
5079
                               {{4, 4}, "4"},
5080
                           }}),
13✔
5081
               commonItems::ModFilesystem{"test_files/Hoi4worldMapBuildingsCreatorTests/DefaultsExist", {}});
2✔
5082

5083
   EXPECT_THAT(buildings.GetBuildings(),
3✔
5084
       testing::IsSupersetOf({Building({.state_id = 1,
5085
           .type = "stronghold_network",
5086
           .position = {.x_coordinate = 4.0, .y_coordinate = 6.0, .z_coordinate = 1.0, .rotation = 90.0}})}));
1✔
5087
}
26✔
5088

5089

5090
TEST(Hoi4worldMapBuildingsCreatorTests, StrongholdNetworkPlacedInCenterOfFirstProvinceOfStateIfDefaultNotInState)
4✔
5091
{
5092
   const Buildings buildings = ImportBuildings(States({.states = {State(1, {.provinces = {1, 2, 3, 4, 5}})},
1✔
5093
                                                   .province_to_state_id_map =
5094
                                                       {
5095
                                                           {1, 1},
5096
                                                           {2, 1},
5097
                                                           {3, 1},
5098
                                                           {4, 1},
5099
                                                           {5, 1},
5100
                                                       }}),
1✔
5101
       CoastalProvinces(),
1✔
5102
       maps::MapData(
1✔
5103
           {.the_province_points =
5104
                   {
5105
                       {"1",
5106
                           maps::ProvincePoints(
2✔
5107
                               {{1, 1}, {1, 2}, {1, 3}, {2, 1}, {2, 2}, {2, 3}, {3, 1}, {3, 2}, {3, 3}})},
5108
                       {"2",
5109
                           maps::ProvincePoints(
2✔
5110
                               {{4, 1}, {4, 2}, {4, 3}, {5, 1}, {5, 2}, {5, 3}, {6, 1}, {6, 2}, {6, 3}})},
5111
                       {"3",
5112
                           maps::ProvincePoints(
2✔
5113
                               {{1, 4}, {1, 5}, {1, 6}, {2, 4}, {2, 5}, {2, 6}, {3, 4}, {3, 5}, {3, 6}})},
5114
                       {"4",
5115
                           maps::ProvincePoints(
2✔
5116
                               {{4, 4}, {4, 5}, {4, 6}, {5, 4}, {5, 5}, {5, 6}, {6, 4}, {6, 5}, {6, 6}})},
5117
                   }}),
4✔
5118
       commonItems::ModFilesystem{"test_files/Hoi4worldMapBuildingsCreatorTests/DefaultsExist", {}});
2✔
5119

5120
   EXPECT_THAT(buildings.GetBuildings(),
3✔
5121
       testing::IsSupersetOf({Building({.state_id = 1,
5122
           .type = "stronghold_network",
5123
           .position = {.x_coordinate = 2.0, .y_coordinate = 11.0, .z_coordinate = 2.0, .rotation = 0.0}})}));
1✔
5124
}
17✔
5125

5126

5127
TEST(Hoi4worldMapBuildingsCreatorTests, DamsPlacedIndefaultLocationsAndOnlyInDefaultLocations)
4✔
5128
{
5129
   const Buildings
5130
       buildings =
5131
           ImportBuildings(States({.states =
1✔
5132
                                       {
5133
                                           State(1, {.provinces = {1, 2, 3, 4, 5}}),
5134
                                           State(2, {.provinces = {6, 7, 8, 9, 10}}),
5135
                                           State(3, {.provinces = {11, 12, 13, 14, 15}}),
5136
                                       },
5137
                               .province_to_state_id_map =
5138
                                   {
5139
                                       {1, 1},
5140
                                       {2, 1},
5141
                                       {3, 1},
5142
                                       {4, 1},
5143
                                       {5, 1},
5144
                                       {6, 2},
5145
                                       {7, 2},
5146
                                       {8, 2},
5147
                                       {9, 2},
5148
                                       {10, 2},
5149
                                       {11, 3},
5150
                                       {12, 3},
5151
                                       {13, 3},
5152
                                       {14, 3},
5153
                                       {15, 3},
5154
                                   }}),
3✔
5155
               CoastalProvinces(),
1✔
5156
               maps::MapData(
1✔
5157
                   {.the_province_points =
5158
                           {
5159
                               {"1",
5160
                                   maps::ProvincePoints(
2✔
5161
                                       {{1, 1}, {1, 2}, {1, 3}, {2, 1}, {2, 2}, {2, 3}, {3, 1}, {3, 2}, {3, 3}})},
5162
                               {"4",
5163
                                   maps::ProvincePoints(
2✔
5164
                                       {{4, 4}, {4, 5}, {4, 6}, {5, 4}, {5, 5}, {5, 6}, {6, 4}, {6, 5}, {6, 6}})},
5165
                               {"7",
5166
                                   maps::ProvincePoints(
2✔
5167
                                       {{7, 7}, {7, 8}, {7, 9}, {8, 7}, {8, 8}, {8, 9}, {9, 7}, {9, 8}, {9, 9}})},
5168
                           },
5169
                       .points_to_provinces =
5170
                           {
5171
                               {{1, 3}, "1"},
5172
                               {{4, 6}, "4"},
5173
                               {{7, 9}, "7"},
5174
                           }}),
12✔
5175
               commonItems::ModFilesystem{"test_files/Hoi4worldMapBuildingsCreatorTests/DefaultsExist", {}});
2✔
5176

5177
   EXPECT_THAT(buildings.GetBuildings(),
5✔
5178
       testing::IsSupersetOf({
5179
           Building({.state_id = 1,
5180
               .type = "dam_spawn",
5181
               .position = {.x_coordinate = 1.0, .y_coordinate = 3.0, .z_coordinate = 3.0, .rotation = 90.0}}),
5182
           Building({.state_id = 1,
5183
               .type = "dam_spawn",
5184
               .position = {.x_coordinate = 4.0, .y_coordinate = 6.0, .z_coordinate = 6.0, .rotation = 135.0}}),
5185
           Building({.state_id = 2,
5186
               .type = "dam_spawn",
5187
               .position = {.x_coordinate = 7.0, .y_coordinate = 9.0, .z_coordinate = 9.0, .rotation = 180.0}}),
5188
       }));
1✔
5189
   EXPECT_THAT(buildings.GetBuildings(),
5✔
5190
       testing::IsSupersetOf({
5191
           Building({.state_id = 1,
5192
               .type = "locks_spawn",
5193
               .position = {.x_coordinate = 1.0, .y_coordinate = 3.0, .z_coordinate = 3.0, .rotation = 90.0}}),
5194
           Building({.state_id = 1,
5195
               .type = "locks_spawn",
5196
               .position = {.x_coordinate = 4.0, .y_coordinate = 6.0, .z_coordinate = 6.0, .rotation = 135.0}}),
5197
           Building({.state_id = 2,
5198
               .type = "locks_spawn",
5199
               .position = {.x_coordinate = 7.0, .y_coordinate = 9.0, .z_coordinate = 9.0, .rotation = 180.0}}),
5200
       }));
1✔
5201
}
28✔
5202

5203
}  // 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

© 2026 Coveralls, Inc