Always keep macro definitions in the Includes section.
This commit is contained in:
Kartik K. Agaram 2016-08-28 23:27:04 -07:00
parent 5f05e954ee
commit 4e39c6bb08
1 changed files with 22 additions and 22 deletions

View File

@ -214,6 +214,28 @@ START_TRACING_UNTIL_END_OF_SCOPE
:(before "End Includes")
#define CHECK_TRACE_CONTENTS(...) check_trace_contents(__FUNCTION__, __FILE__, __LINE__, __VA_ARGS__)
#define CHECK_TRACE_CONTAINS_ERROR() CHECK(trace_count("error") > 0)
#define CHECK_TRACE_DOESNT_CONTAIN_ERROR() \
if (trace_count("error") > 0) { \
++Num_failures; \
cerr << "\nF - " << __FUNCTION__ << "(" << __FILE__ << ":" << __LINE__ << "): unexpected errors\n"; \
DUMP("error"); \
Passed = false; \
return; \
}
#define CHECK_TRACE_COUNT(label, count) \
if (trace_count(label) != (count)) { \
++Num_failures; \
cerr << "\nF - " << __FUNCTION__ << "(" << __FILE__ << ":" << __LINE__ << "): trace_count of " << label << " should be " << count << '\n'; \
cerr << " got " << trace_count(label) << '\n'; /* multiple eval */ \
DUMP(label); \
Passed = false; \
return; /* Currently we stop at the very first failure. */ \
}
#define CHECK_TRACE_DOESNT_CONTAIN(...) CHECK(trace_doesnt_contain(__VA_ARGS__))
:(code)
bool check_trace_contents(string FUNCTION, string FILE, int LINE, string expected) {
if (!Trace_stream) return false;
@ -296,26 +318,6 @@ int trace_count_prefix(string label, string prefix) {
return result;
}
#define CHECK_TRACE_CONTAINS_ERROR() CHECK(trace_count("error") > 0)
#define CHECK_TRACE_DOESNT_CONTAIN_ERROR() \
if (trace_count("error") > 0) { \
++Num_failures; \
cerr << "\nF - " << __FUNCTION__ << "(" << __FILE__ << ":" << __LINE__ << "): unexpected errors\n"; \
DUMP("error"); \
Passed = false; \
return; \
}
#define CHECK_TRACE_COUNT(label, count) \
if (trace_count(label) != (count)) { \
++Num_failures; \
cerr << "\nF - " << __FUNCTION__ << "(" << __FILE__ << ":" << __LINE__ << "): trace_count of " << label << " should be " << count << '\n'; \
cerr << " got " << trace_count(label) << '\n'; /* multiple eval */ \
DUMP(label); \
Passed = false; \
return; /* Currently we stop at the very first failure. */ \
}
bool trace_doesnt_contain(string label, string line) {
return trace_count(label, line) == 0;
}
@ -325,8 +327,6 @@ bool trace_doesnt_contain(string expected) {
return trace_doesnt_contain(tmp.at(0), tmp.at(1));
}
#define CHECK_TRACE_DOESNT_CONTAIN(...) CHECK(trace_doesnt_contain(__VA_ARGS__))
vector<string> split(string s, string delim) {
vector<string> result;
size_t begin=0, end=s.find(delim);