blob: ab0bfb9b690f0d2b2760c18c82243b08d71b0355 (
plain) (
blame)
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
|
#include <testing/TestScript.hpp>
using namespace OpenVic;
// Getters
std::vector<Requirement*> TestScript::get_requirements() {
return requirements;
}
Requirement* TestScript::get_requirement_at_index(int index) {
return requirements[index];
}
Requirement* TestScript::get_requirement_by_id(std::string id) {
for (auto req : requirements) {
if (req->get_id() == id) {
return req;
}
}
return new Requirement("NULL", "NULL", "NULL"); // edge case of failing to find
}
std::vector<Requirement*> TestScript::get_passed_requirements() {
std::vector<Requirement*> passed_requirements = std::vector<Requirement*>();
for (auto req : requirements) {
if (req->get_pass()) {
passed_requirements.push_back(req);
}
}
return passed_requirements;
}
std::vector<Requirement*> TestScript::get_failed_requirements() {
std::vector<Requirement*> failed_requirements = std::vector<Requirement*>();
for (auto req : requirements) {
if (!req->get_pass() && req->get_tested()) {
failed_requirements.push_back(req);
}
}
return failed_requirements;
}
std::vector<Requirement*> TestScript::get_untested_requirements() {
std::vector<Requirement*> untested_requirements = std::vector<Requirement*>();
for (auto req : requirements) {
if (!req->get_tested()) {
untested_requirements.push_back(req);
}
}
return untested_requirements;
}
// Setters
void TestScript::set_requirements(std::vector<Requirement*> in_requirements) {
requirements = in_requirements;
}
void TestScript::add_requirement(Requirement* req) {
requirements.push_back(req);
}
// Methods
void TestScript::pass_or_fail_req_with_actual_and_target_values(
std::string req_name, std::string target_value, std::string actual_value
) {
Requirement* req = get_requirement_by_id(req_name);
req->set_target_value(target_value);
req->set_actual_value(actual_value);
if (target_value == actual_value) {
req->set_pass(true);
} else {
req->set_pass(false);
}
}
|