File: ERM_VR.cpp

package info (click to toggle)
vcmi 1.1.0%2Bdfsg-1
  • links: PTS, VCS
  • area: contrib
  • in suites: bookworm
  • size: 14,672 kB
  • sloc: cpp: 181,738; sh: 220; python: 178; ansic: 69; objc: 66; xml: 59; makefile: 34
file content (97 lines) | stat: -rw-r--r-- 2,534 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/*
 * ERM_VR.cpp, part of VCMI engine
 *
 * Authors: listed in file AUTHORS in main folder
 *
 * License: GNU General Public License v2.0 or later
 * Full text of license available in license.txt file, in main folder
 *
 */
#include "StdInc.h"

#include "../scripting/ScriptFixture.h"


namespace test
{
namespace scripting
{

using namespace ::testing;

class ERM_VR : public Test, public ScriptFixture
{
protected:
	void SetUp() override
	{
		ScriptFixture::setUp();
	}
};

TEST_F(ERM_VR, C)
{
	std::stringstream source;
	source << "VERM" << std::endl;
	source << "!?PI;" << std::endl;
	source << "!!VRv2:S99;" << std::endl;
	source << "!!VRv45:S100;" << std::endl;
	source << "!!VRv42:C3/5/75/?k/v2;" << std::endl;
	JsonNode actualState = runScript(VLC->scriptHandler->erm, source.str());

	SCOPED_TRACE("\n" + subject->code);

	EXPECT_EQ(actualState["ERM"]["Q"]["k"], JsonUtils::floatNode(100)) << actualState.toJson(true);

	const JsonNode & v = actualState["ERM"]["v"];

	EXPECT_EQ(v["42"], JsonUtils::floatNode(3)) << actualState.toJson(true);
	EXPECT_EQ(v["43"], JsonUtils::floatNode(5)) << actualState.toJson(true);
	EXPECT_EQ(v["44"], JsonUtils::floatNode(75)) << actualState.toJson(true);
	EXPECT_EQ(v["46"], JsonUtils::floatNode(99)) << actualState.toJson(true);
}

TEST_F(ERM_VR, H)
{
	std::stringstream source;
	source << "VERM" << std::endl;
	source << "!?PI;" << std::endl;
	source << "!!VRz100:S^Test!^;" << std::endl;
	source << "!!VRz101:S^^;" << std::endl;
	source << "!!VRz102:S^ ^;" << std::endl;
	source << "!!VRz100:H200;" << std::endl;
	source << "!!VRz101:H201;" << std::endl;
	source << "!!VRz102:H202;" << std::endl;

	JsonNode actualState = runScript(VLC->scriptHandler->erm, source.str());

	SCOPED_TRACE("\n" + subject->code);

	const JsonNode & f = actualState["ERM"]["F"];

	EXPECT_EQ(f["200"], JsonUtils::boolNode(true)) << actualState.toJson(true);
	EXPECT_EQ(f["201"], JsonUtils::boolNode(false)) << actualState.toJson(true);
	EXPECT_EQ(f["202"], JsonUtils::boolNode(false)) << actualState.toJson(true);
}

TEST_F(ERM_VR, U)
{
	std::stringstream source;
	source << "VERM" << std::endl;
	source << "!?PI;" << std::endl;
	source << "!!VRz100:S^Test!^;" << std::endl;
	source << "!!VRz101:S^est^;" << std::endl;
	source << "!!VRz100:Uz101;" << std::endl;

	JsonNode actualState = runScript(VLC->scriptHandler->erm, source.str());

	SCOPED_TRACE("\n" + subject->code);

	const JsonNode & f = actualState["ERM"]["F"];

	EXPECT_EQ(f["1"], JsonUtils::boolNode(true)) << actualState.toJson(true);
}

}
}