-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtemplate.cpp
More file actions
56 lines (45 loc) · 1.01 KB
/
template.cpp
File metadata and controls
56 lines (45 loc) · 1.01 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
46
47
48
49
50
51
52
53
54
55
56
// URL to leetcode exercise
//
// Status: (Not) Accepted
// Runtime: 8 ms
// Score: X.Y %
//
#include <iostream>
#include <vector>
#include <gtest/gtest.h>
#include "args.h"
#include "macros.h"
using namespace std;
// class definition comes from leetcode
class Solution {
public:
bool solution(bool throwError)
{
if ( throwError ) {
throw "No solution found";
}
return throwError;
}
};
TEST(Solution, CorrectTest)
{
Solution solution;
bool correct = true;
try {
ASSERT_EQ(solution.solution(false), correct);
} catch (const exception &e) {
std::cout << "Solution.CorrectTest: Exception - " << e.what() << endl;
}
}
TEST(Solution, NoSolution)
{
bool exceptionThrown = false;
bool ignoreAnswer = true;
try {
Solution solution;
ignoreAnswer = solution.solution(true);
} catch (const exception &e) {
exceptionThrown = true;
}
ASSERT_EQ(exceptionThrown, true);
}