Halide 19.0.0
Halide compiler and libraries
Loading...
Searching...
No Matches
test.h
Go to the documentation of this file.
1#ifndef TEST_H
2#define TEST_H
3
4#include "Halide.h"
5
6namespace Halide {
7namespace Internal {
8namespace Autoscheduler {
9
10#define user_assert(c) _halide_internal_assertion(c, Halide::Internal::ErrorReport::User)
11#define EXPECT_EQ(expected, actual) expect_eq(__LINE__, expected, actual)
12#define APPROX_EQ(expected, actual, epsilon) approx_eq(__LINE__, expected, actual, epsilon)
13#define EXPECT(expected) expect(__LINE__, expected)
14
15template<typename A, typename B>
16void expect_eq(int line, const A &expected, const B &actual) {
17 user_assert(expected == actual)
18 << "Assert failed on line " << line << "."
19 << "\nExpected value = " << expected
20 << "\nActual value = " << actual;
21}
22
23template<typename A, typename B>
24void approx_eq(int line, const A &expected, const B &actual, float epsilon) {
25 user_assert(std::abs(expected - actual) < epsilon)
26 << "Assert failed on line " << line << "."
27 << "\nExpected value = " << expected
28 << "\nActual value = " << actual;
29}
30
31template<typename A>
32void expect(int line, const A &expected) {
33 user_assert(expected)
34 << "Assert failed on line " << line << "."
35 << "\nExpected value to be true\n";
36}
37
38} // namespace Autoscheduler
39} // namespace Internal
40} // namespace Halide
41
42#endif // TEST_H
void expect(int line, const A &expected)
Definition test.h:32
void approx_eq(int line, const A &expected, const B &actual, float epsilon)
Definition test.h:24
void expect_eq(int line, const A &expected, const B &actual)
Definition test.h:16
This file defines the class FunctionDAG, which is our representation of a Halide pipeline,...
@ Internal
Not visible externally, similar to 'static' linkage in C.
#define user_assert(c)
Definition test.h:10