35 inline void assert_bool_with_log(std::string assert_name,
bool v, std::string log) {
37 TestAssert{.value = v, .name = std::move(assert_name), .comment = std::move(log)});
46 [[deprecated(
"Please use the supplied testing macros instead")]]
53 .name = std::move(assert_name),
54 .comment =
"failed assert location : " + loc.format_one_line()});
58 template<
class T1,
class T2>
59 [[deprecated(
"Please use the supplied testing macros instead")]]
64 std::string comment =
"";
67 comment =
"left=" + std::to_string(a) +
" right=" + std::to_string(b);
73 .name = std::move(assert_name),
78 template<
class Acca,
class Accb>
79 [[deprecated(
"Please use the supplied testing macros instead")]]
81 std::string assert_name,
88 std::string comment =
"";
90 for (
u32 i = 0; i < len; i++) {
91 t = t && (acc_a[i] == acc_b[i]);
95 comment +=
"left : \n";
97 comment +=
"right : \n";
104 .name = std::move(assert_name),
117 [[deprecated(
"Please use the supplied testing macros instead")]]
120 f64 diff = sycl::fabs(a - b);
123 std::string comment =
"";
126 comment =
"left=" + std::to_string(a) +
" right=" + std::to_string(b)
127 +
" diff=" + std::to_string(diff);
133 .name = std::move(assert_name),
139 std::string assert_name,
146 .name = std::move(assert_name),
153 void serialize(std::basic_stringstream<byte> &stream);
155 static TestAssertList
deserialize(std::basic_stringstream<byte> &reader);
double f64
Alias for double.
std::uint32_t u32
32 bit unsigned integer
std::string format_array(const It &iter, u32 len, u32 column_count, fmt::format_string< Tformat... > fmt)
Format an array of elements into a string.
implementation details of the test library
shamtest::details::TestAssertList & asserts()
current test asserts
provide information about the source location
std::string format_multiline() const
format the location in multiple lines
Class to hold the list of assertion related to a test.
static TestAssertList deserialize(std::basic_stringstream< byte > &reader)
DeSerialize the assertion from binary format.
void assert_float_equal(std::string assert_name, f64 a, f64 b, f64 eps, SourceLocation loc=SourceLocation{})
Add an assertion testing a floating point equality up to precision eps.
u32 get_assert_success_count()
Get the number of successful assertions.
void assert_equal(std::string assert_name, T1 a, T2 b, SourceLocation loc=SourceLocation{})
Test for an equality.
void serialize(std::basic_stringstream< byte > &stream)
Serialize the assertion in binary format.
u32 get_assert_count()
Get number of assertion in the list.
std::string serialize_json()
Serialize the assertion in JSON.
void assert_bool(std::string assert_name, bool v, SourceLocation loc=SourceLocation{})
Test if the supplied boolean is true.
static std::string gen_comment(std::string s, SourceLocation loc)
Append the source location to the the supplied string to generate a comment.
std::vector< TestAssert > asserts
List of assertion held by the class.
void assert_add_comment(std::string assert_name, bool v, std::string comment, SourceLocation loc=SourceLocation{})
add an assertion with a comment
void assert_equal_array(std::string assert_name, Acca &acc_a, Accb &acc_b, u32 len, SourceLocation loc=SourceLocation{})
Assert equal on an array of values.