[MemProf] Templatize CallStackRadixTreeBuilder (NFC) (#117014)
[llvm-project.git] / flang / unittests / Evaluate / testing.h
blob422e2853c05bc66c72c7d1781fc2c5466590a12a
1 #ifndef FORTRAN_EVALUATE_TESTING_H_
2 #define FORTRAN_EVALUATE_TESTING_H_
4 #include <cinttypes>
5 #include <string>
7 namespace testing {
9 // Returns EXIT_SUCCESS or EXIT_FAILURE, so a test's main() should end
10 // with "return testing::Complete()".
11 int Complete();
13 // Pass/fail testing. These macros return a pointer to a printf-like
14 // function that can be optionally called to print more detail, e.g.
15 // COMPARE(x, ==, y)("z is 0x%llx", z);
16 // will also print z after the usual failure message if x != y.
17 #define TEST(predicate) \
18 testing::Test(__FILE__, __LINE__, #predicate, (predicate))
19 #define MATCH(want, got) testing::Match(__FILE__, __LINE__, (want), #got, (got))
20 #define COMPARE(x, rel, y) \
21 testing::Compare(__FILE__, __LINE__, #x, #rel, #y, (x), (y))
23 // Functions called by these macros; do not call directly.
24 using FailureDetailPrinter = void (*)(const char *, ...);
25 FailureDetailPrinter Test(
26 const char *file, int line, const char *predicate, bool pass);
27 FailureDetailPrinter Match(const char *file, int line, std::uint64_t want,
28 const char *gots, std::uint64_t got);
29 FailureDetailPrinter Match(const char *file, int line, const char *want,
30 const char *gots, const std::string &got);
31 FailureDetailPrinter Match(const char *file, int line, const std::string &want,
32 const char *gots, const std::string &got);
33 FailureDetailPrinter Compare(const char *file, int line, const char *xs,
34 const char *rel, const char *ys, std::uint64_t x, std::uint64_t y);
35 } // namespace testing
36 #endif // FORTRAN_EVALUATE_TESTING_H_