1#ifndef FORTRAN_EVALUATE_TESTING_H_
2#define FORTRAN_EVALUATE_TESTING_H_
3
4#include <cinttypes>
5#include <string>
6
7namespace testing {
8
9// Returns EXIT_SUCCESS or EXIT_FAILURE, so a test's main() should end
10// with "return testing::Complete()".
11int Complete();
12
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))
22
23// Functions called by these macros; do not call directly.
24using FailureDetailPrinter = void (*)(const char *, ...);
25FailureDetailPrinter Test(
26 const char *file, int line, const char *predicate, bool pass);
27FailureDetailPrinter Match(const char *file, int line, std::uint64_t want,
28 const char *gots, std::uint64_t got);
29FailureDetailPrinter Match(const char *file, int line, const char *want,
30 const char *gots, const std::string &got);
31FailureDetailPrinter Match(const char *file, int line, const std::string &want,
32 const char *gots, const std::string &got);
33FailureDetailPrinter 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_
37

source code of flang/unittests/Evaluate/testing.h