-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcard_tests.cpp
147 lines (93 loc) · 3.26 KB
/
card_tests.cpp
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
135
136
137
138
139
140
141
142
143
144
145
146
//
// card_tests.cpp
// Cards
//
// Created by Sisir Potluri on 6/3/20.
// Copyright © 2020 Sisir Potluri. All rights reserved.
//
#include <cassert>
#include <iostream>
#include <string>
#include <sstream>
#include "Card.h"
using namespace std;
void test_ctor();
void test_set_attack();
void test_origin_form();
void test_reduce_health_alive();
void test_print();
int main () {
test_ctor();
test_set_attack();
test_origin_form();
test_reduce_health_alive();
test_print();
cout << "ALL TESTS PASSED" << endl;
return 0;
}
void test_ctor() {
Card test_1;
assert(test_1.get_element() == Card::PYRO);
assert(test_1.get_form() == Card::PHOENIX);
Card test_2 = Card(Card::GLEAM, Card::DJINN);
assert(test_2.get_element() == Card::GLEAM);
assert(test_2.get_form() == Card::DJINN);
cout << "TEST PASSED" << endl;
}
void test_set_attack() {
Card test = Card(Card::GLEAM, Card::DJINN);
string level = "Base";
test.set_attack("Ashen Spell", level, 30);
Attack correct;
correct.set_strength(30);
correct.set_name("Ashen Spell");
assert((test.get_base()).get_name() == correct.get_name());
assert((test.get_base()).get_strength() == correct.get_strength());
level = "Ultra";
test.set_attack("Photon Spear", level, 70);
correct.set_strength(70);
correct.set_name("Photon Spear");
assert((test.get_ultra()).get_name() == correct.get_name());
assert((test.get_ultra()).get_strength() == correct.get_strength());
cout << "TEST PASSED" << endl;
}
void test_origin_form() {
Card test_1 = Card(Card::GLEAM, Card::DJINN);
Card test_2 = Card(Card::SPECTRAL, Card::DJINN);
Card test_3 = Card(Card::PYRO, Card::PHOENIX);
Card test_4 = Card(Card::AQUA, Card::LEVIATHAN);
Card test_5 = Card(Card::AERO, Card::GRIFFIN);
Card test_6 = Card(Card::EARTH, Card::BEHEMOTH);
Card test_7 = Card(Card::AERO, Card::BEHEMOTH);
Card test_8 = Card(Card::PYRO, Card::GRIFFIN);
Card test_9 = Card(Card::AQUA, Card::PHOENIX);
Card test_10 = Card(Card::EARTH, Card::LEVIATHAN);
assert(test_1.is_origin_form() == true);
assert(test_2.is_origin_form() == true);
assert(test_3.is_origin_form() == true);
assert(test_4.is_origin_form() == true);
assert(test_5.is_origin_form() == true);
assert(test_6.is_origin_form() == true);
assert(test_7.is_origin_form() == false);
assert(test_8.is_origin_form() == false);
assert(test_9.is_origin_form() == false);
assert(test_10.is_origin_form() == false);
cout << "TEST PASSED" << endl;
}
void test_reduce_health_alive() {
Card test = Card(Card::AQUA, Card::GRIFFIN);
test.reduce_health(30);
assert(test.alive() == true);
test.reduce_health(70);
assert(test.alive() == false);
cout << "TEST PASSED" << endl;
}
void test_print() {
Card test = Card(Card::EARTH, Card::PHOENIX);
string output_correct = "Earth Phoenix";
ostringstream ss_output;
ss_output << test;
string correct = ss_output.str();
assert(correct == output_correct);
cout << "TEST PASSED" << endl;
}