MCPcopy Create free account
hub / github.com/OpenApoc/OpenApoc / test_gamestate_serialization_roundtrip

Function test_gamestate_serialization_roundtrip

tests/test_serialize.cpp:22–50  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

20*/
21
22bool test_gamestate_serialization_roundtrip(OpenApoc::sp<OpenApoc::GameState> state,
23 OpenApoc::UString save_name)
24{
25 if (!state->saveGame(save_name))
26 {
27
28 LogWarning("Failed to save packed gamestate");
29 return false;
30 }
31
32 auto read_gamestate = OpenApoc::mksp<OpenApoc::GameState>();
33 if (!read_gamestate->loadGame(save_name))
34 {
35 LogWarning("Failed to load packed gamestate");
36 return false;
37 }
38
39#if 0
40 // FIXME: This isn't reliable due to undefined order of containers
41 if (*state != *read_gamestate)
42#endif
43 if (0)
44 {
45 LogWarning("Gamestate changed over serialization");
46
47 return false;
48 }
49 return true;
50}
51
52bool test_gamestate_serialization(OpenApoc::sp<OpenApoc::GameState> state)
53{

Callers 1

Calls 2

saveGameMethod · 0.45
loadGameMethod · 0.45

Tested by

no test coverage detected