Halide
test.h
Go to the documentation of this file.
1 #ifndef TEST_H
2 #define TEST_H
3 
4 #include "Halide.h"
5 
6 namespace Halide {
7 namespace Internal {
8 namespace 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 
15 template<typename A, typename B>
16 void 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 
23 template<typename A, typename B>
24 void 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 
31 template<typename A>
32 void 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
Halide::Internal::Autoscheduler::expect_eq
void expect_eq(int line, const A &expected, const B &actual)
Definition: test.h:16
user_assert
#define user_assert(c)
Definition: test.h:10
Halide
This file defines the class FunctionDAG, which is our representation of a Halide pipeline,...
Definition: AbstractGenerator.h:19
Halide::Internal::Autoscheduler::approx_eq
void approx_eq(int line, const A &expected, const B &actual, float epsilon)
Definition: test.h:24
Halide::LinkageType::Internal
@ Internal
Not visible externally, similar to 'static' linkage in C.
Halide::abs
Expr abs(Expr a)
Returns the absolute value of a signed integer or floating-point expression.
Halide::Internal::Autoscheduler::expect
void expect(int line, const A &expected)
Definition: test.h:32