-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestcase.cc
More file actions
42 lines (38 loc) · 1.13 KB
/
testcase.cc
File metadata and controls
42 lines (38 loc) · 1.13 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
#include "testcase.h"
#include <span>
map<string_view, TestcaseBase *> TestcaseBase::smTestCases_ = {};
int main(int argc, const char *argv[]) {
auto args = span(argv + 1, argc - 1);
if (argc == 1) {
TestcaseBase::TestAllCases();
} else {
for (auto arg : args) {
string_view option(arg);
if (option == "-i" || option == "--interactive") {
auto i = -1;
auto num = TestcaseBase::PrintAllTestcases();
while (true) {
if (cin.peek() == '\n') {
TestcaseBase::TestAllCases();
break;
} else {
cin >> i;
if (cin.good() && i >= 0 && i < num) {
TestcaseBase::GetTestcaseByIndex(i)->testRoutine();
cin.ignore(numeric_limits<streamsize>::max(), '\n');
break;
} else {
cin.clear();
cin.ignore(numeric_limits<streamsize>::max(), '\n');
cout << "invalid input, make sure you choose num from [0 to "
<< num << ")" << endl;
}
}
}
break;
}
}
}
TestcaseBase::FreeAllCases();
return 0;
}