-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestcasevector.cpp
More file actions
45 lines (36 loc) · 1.34 KB
/
testcasevector.cpp
File metadata and controls
45 lines (36 loc) · 1.34 KB
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
#include "testcasevector.h"
template <typename T1, typename T2, typename T3, typename T4>
TestCaseVector<T1, T2, T3, T4>::TestCaseVector(vector<T1> expected){
this->expected = expected;
}
template <typename T1, typename T2, typename T3, typename T4>
void TestCaseVector<T1, T2, T3, T4>::run(T2 para1, T3 para2, T4 para3)
{
start = std::chrono::system_clock::now();
result = code.solve(para1, para2, para3);
endtime = std::chrono::system_clock::now();
}
template <typename T1, typename T2, typename T3, typename T4>
bool TestCaseVector<T1, T2, T3, T4>::isPassed(){
return result == expected;
}
template <typename T>
string getArrayString(vector<T> array, string type){
int n = array.size();
string str = type + ": [";
for (int i = 0; i < n; i++){
str += to_string(array[i]);
if (i != n - 1) str += ", ";
else str += "]";
}
return str;
}
template <typename T1, typename T2, typename T3, typename T4>
pair<string, string> TestCaseVector<T1, T2, T3, T4>::getStrExpectedandResult(){
return make_pair(getArrayString<T1>(expected, "Expected"), getArrayString<T1>(result, "Result"));
}
template <typename T1, typename T2, typename T3, typename T4>
double TestCaseVector<T1, T2, T3, T4>::getExcuteTime(){
std::chrono::duration<double> excuteTime = endtime - start;
return excuteTime.count();
}