/proc/self/cwd/cpp/htmlparser/glog_polyfill.h
Line | Count | Source (jump to first uncovered line) |
1 | | #ifndef CPP_HTMLPARSER_GLOG_POLYFILL_H_ |
2 | | #define CPP_HTMLPARSER_GLOG_POLYFILL_H_ |
3 | | |
4 | | #include <cstdlib> |
5 | | |
6 | | class Checker { |
7 | | public: |
8 | 25.0M | Checker(bool condition) : condition_(condition) {} |
9 | 25.0M | ~Checker() { |
10 | 25.0M | if (!condition_) { |
11 | 0 | abort(); |
12 | 0 | } |
13 | 25.0M | } |
14 | | template <typename T> |
15 | 25.0M | Checker& operator<<(T s) { |
16 | 25.0M | return *this; |
17 | 25.0M | } |
18 | | |
19 | | private: |
20 | | bool condition_; |
21 | | }; |
22 | | |
23 | | // Using the same value as `absl::LogSeverity` |
24 | | const int INFO = 0; |
25 | | const int WARNING = 1; |
26 | | const int ERROR = 2; |
27 | | const int FATAL = 3; |
28 | | |
29 | 98.5M | #define CHECK(condition) Checker(condition) |
30 | | #define CHECK_EQ(val1, val2) Checker((val1) == (val2)) |
31 | | #define CHECK_GE(val1, val2) Checker((val1) >= (val2)) |
32 | | #define CHECK_LT(val1, val2) Checker((val1) < (val2)) |
33 | | #define CHECK_NE(val1, val2) Checker((val1) != (val2)) |
34 | | #define LOG(level) Checker((level) < FATAL) |
35 | | |
36 | | #define DCHECK(condition) Checker(true) |
37 | | #define DCHECK_EQ(val1, val2) Checker(true) |
38 | | #define DCHECK_GE(val1, val2) Checker(true) |
39 | | #define DLOG(level) Checker(true) |
40 | | |
41 | | #endif // CPP_HTMLPARSER_GLOG_POLYFILL_H_ |