Changeset View
Changeset View
Standalone View
Standalone View
source/simulation2/tests/test_ComponentManager.h
/* Copyright (C) 2019 Wildfire Games. | /* Copyright (C) 2020 Wildfire Games. | ||||
* This file is part of 0 A.D. | * This file is part of 0 A.D. | ||||
* | * | ||||
* 0 A.D. is free software: you can redistribute it and/or modify | * 0 A.D. is free software: you can redistribute it and/or modify | ||||
* it under the terms of the GNU General Public License as published by | * it under the terms of the GNU General Public License as published by | ||||
* the Free Software Foundation, either version 2 of the License, or | * the Free Software Foundation, either version 2 of the License, or | ||||
* (at your option) any later version. | * (at your option) any later version. | ||||
* | * | ||||
* 0 A.D. is distributed in the hope that it will be useful, | * 0 A.D. is distributed in the hope that it will be useful, | ||||
▲ Show 20 Lines • Show All 758 Lines • ▼ Show 20 Lines | void test_script_serialization() | ||||
std::stringstream debugStream; | std::stringstream debugStream; | ||||
TS_ASSERT(man.DumpDebugState(debugStream, true)); | TS_ASSERT(man.DumpDebugState(debugStream, true)); | ||||
TS_ASSERT_STR_EQUALS(debugStream.str(), | TS_ASSERT_STR_EQUALS(debugStream.str(), | ||||
"rng: \"78606\"\n\ | "rng: \"78606\"\n\ | ||||
entities:\n\ | entities:\n\ | ||||
- id: 1\n\ | - id: 1\n\ | ||||
TestScript1_values:\n\ | TestScript1_values:\n\ | ||||
object: {\n\ | comp: {\n\ | ||||
\"x\": 1234,\n\ | \"x\": 1234,\n\ | ||||
\"str\": \"this is a string\",\n\ | \"str\": \"this is a string\",\n\ | ||||
\"things\": {\n\ | \"things\": {\n\ | ||||
\"a\": 1,\n\ | \"a\": 1,\n\ | ||||
\"b\": \"2\",\n\ | \"b\": \"2\",\n\ | ||||
\"c\": [\n\ | \"c\": [\n\ | ||||
3,\n\ | 3,\n\ | ||||
\"4\",\n\ | \"4\",\n\ | ||||
[\n\ | [\n\ | ||||
5,\n\ | 5,\n\ | ||||
[]\n\ | []\n\ | ||||
]\n\ | ]\n\ | ||||
]\n\ | ]\n\ | ||||
}\n\ | }\n\ | ||||
}\n\ | }\n\ | ||||
\n\ | \n\ | ||||
- id: 2\n\ | - id: 2\n\ | ||||
TestScript1_entity:\n\ | TestScript1_entity:\n\ | ||||
object: {}\n\ | comp: {}\n\ | ||||
\n\ | \n\ | ||||
- id: 3\n\ | - id: 3\n\ | ||||
TestScript1_nontree:\n\ | TestScript1_nontree:\n\ | ||||
object: ({x:[[2], [2], [], {y:[2]}]})\n\ | comp: ({x:[[2], [2], [], {y:[2]}]})\n\ | ||||
\n\ | \n\ | ||||
- id: 4\n\ | - id: 4\n\ | ||||
TestScript1_custom:\n\ | TestScript1_custom:\n\ | ||||
object: {\n\ | comp: {\n\ | ||||
\"c\": 1\n\ | \"c\": 1\n\ | ||||
}\n\ | } (raw: ({y:2}))\n\ | ||||
\n" | \n" | ||||
); | ); | ||||
std::stringstream stateStream; | std::stringstream stateStream; | ||||
TS_ASSERT(man.SerializeState(stateStream)); | TS_ASSERT(man.SerializeState(stateStream)); | ||||
CSimContext context2; | CSimContext context2; | ||||
CComponentManager man2(context2, g_ScriptContext); | CComponentManager man2(context2, g_ScriptContext); | ||||
▲ Show 20 Lines • Show All 89 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator