summaryrefslogtreecommitdiff
path: root/tests/lua_get_level.cc
blob: b1cb559d86ca104075291495ba9378f4d936c461 (plain)
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#include "spell_type.h"
#include <bandit/bandit.h>
using namespace bandit;

go_bandit([]() {
	describe("lua_get_level", []() {

		auto createEntsPotion = ([]() {
			auto my_spell = spell_type_new("TEST: Ent's Potion");
			spell_type_set_difficulty(my_spell, 6, 35); // Copied from standard Ent's Potion spell.
			return my_spell;
		});
		
		auto createSenseHidden = ([]() {
			auto my_spell = spell_type_new("TEST: Sense Hidden");
			spell_type_set_difficulty(my_spell, 5, 25); // Copied from standard Sense Hidden spell.
			return my_spell;
		});

		//
		// Test cases derived from empirical testing of the code before refactoring.
		//
		
		it("calculates \"Ent's Potion\" level appropriately for Sorcery@1.0", [&](){
			// Setup
			auto my_spell = createEntsPotion();
			// Exercise
			auto actualResult = lua_get_level(my_spell, 100, 50, -50, 0);
			// Verify
			AssertThat(actualResult, Equals(-4));
		});
		
		it("calculates \"Ent's Potion\" cost appropriately for Sorcery@1.0", [&](){
			// Setup
			auto my_spell = createEntsPotion();
			// Exercise
			auto actualResult = lua_get_level(my_spell, 100, 15, 7, 0);
			// Verify
			AssertThat(actualResult, Equals(7));
		});

		it("calculates \"Ent's Potion\" level appropriately for Sorcery@25.0", [&](){
			// Setup
			auto my_spell = createEntsPotion();
			// Exercise
			auto actualResult = lua_get_level(my_spell, 2500, 50, 1, 0);
			// Verify
			AssertThat(actualResult, Equals(20));
		});

		it("calculates \"Ent's Potion\" cost appropriately for Sorcery@25.0", [&](){
			// Setup
			auto my_spell = createEntsPotion();
			// Exercise
			auto actualResult = lua_get_level(my_spell, 2500, 15, 7, 0);
			// Verify
			AssertThat(actualResult, Equals(7));
		});

		it("calculates \"Ent's Potion\" level appropriately for Sorcery@25.0 with +3 equipment SP bonus", [&](){
			// Setup
			auto my_spell = createEntsPotion();
			// Exercise
			auto actualResult = lua_get_level(my_spell, 2500, 50, 1, 300);
			// Verify
			AssertThat(actualResult, Equals(23));
		});

		it("calculates \"Ent's Potion\" cost appropriately for Sorcery@25.0 with +3 equipment SP bonus", [&](){
			// Setup
			auto my_spell = createEntsPotion();
			// Exercise
			auto actualResult = lua_get_level(my_spell, 2500, 15, 7, 300);
			// Verify
			AssertThat(actualResult, Equals(7));

		});

		it("calculates \"Sense Hidden\" level appropriately for Sorcery@1.0", [&](){
			// Setup
			auto my_spell = createSenseHidden();
			// Exercise
			auto actualResult = lua_get_level(my_spell, 100, 50, -50, 0);
			// Verify
			AssertThat(actualResult, Equals(-3));
		});
		
		it("calculates \"Sense Hidden\" cost appropriately for Sorcery@1.0", [&](){
			// Setup
			auto my_spell = createSenseHidden();
			// Exercise
			auto actualResult = lua_get_level(my_spell, 100, 10, 2, 0);
			// Verify
			AssertThat(actualResult, Equals(2));
		});

		it("calculates \"Sense Hidden\" level appropriately for Sorcery@25.0", [&](){
			// Setup
			auto my_spell = createSenseHidden();
			// Exercise
			auto actualResult = lua_get_level(my_spell, 2500, 50, 1, 0);
			// Verify
			AssertThat(actualResult, Equals(21));
		});

		it("calculates \"Sense Hidden\" cost appropriately for Sorcery@25.0", [&](){
			// Setup
			auto my_spell = createSenseHidden();
			// Exercise
			auto actualResult = lua_get_level(my_spell, 2500, 10, 2, 0);
			// Verify
			AssertThat(actualResult, Equals(4));
		});

		it("calculates \"Sense Hidden\" level appropriately for Sorcery@25.0 with +3 equipment SP bonus", [&](){
			// Setup
			auto my_spell = createSenseHidden();
			// Exercise
			auto actualResult = lua_get_level(my_spell, 2500, 50, 1, 300);
			// Verify
			AssertThat(actualResult, Equals(24));
		});

		it("calculates \"Sense Hidden\" cost appropriately for Sorcery@25.0 with +3 equipment SP bonus", [&](){
			// Setup
			auto my_spell = createSenseHidden();
			// Exercise
			auto actualResult = lua_get_level(my_spell, 2500, 10, 2, 300);
			// Verify
			AssertThat(actualResult, Equals(4));
		});

	});
});