forked from EbenZhang/kcppunitlite
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfailure.h
More file actions
58 lines (44 loc) · 1.14 KB
/
failure.h
File metadata and controls
58 lines (44 loc) · 1.14 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
57
58
#ifndef FAILURE_H
#define FAILURE_H
// Failure records the circumstances surrounding a test failure. Using C++
// macros were are able to record the name of the file where the failure
// occurred, the line number, and the text of the condition which provoked
// the failure.
#include <string>
#include <iostream>
class Success
{
public:
Success(const std::string& theTestName) : _theTestName(theTestName)
{
}
const std::string getTestName()const
{
return _theTestName;
}
protected:
std::string _theTestName;
};
class Failure
{
public:
Failure (std::string theCondition, std::string theTestName, std::string theFileName, long theLineNumber)
: condition (theCondition), testName (theTestName), fileName (theFileName), lineNumber (theLineNumber)
{
}
std::string condition;
std::string testName;
std::string fileName;
long lineNumber;
};
inline std::ostream& operator<< (std::ostream& stream, Failure& failure)
{
stream
<< "Failure: \"" << failure.condition.c_str () << "\" "
<< "line " << failure.lineNumber << " in "
<< failure.fileName.c_str ()
<< std::endl;
return stream;
}
#endif
//END OF FILE