mirror of
https://github.com/slint-ui/slint.git
synced 2025-09-28 21:04:47 +00:00
C++ Tests add an assert_eq macro
More consistency with rusts tests
This commit is contained in:
parent
932d0f23a0
commit
b41e80b7db
3 changed files with 27 additions and 11 deletions
|
@ -8,8 +8,8 @@
|
|||
Please contact info@sixtyfps.io for more information.
|
||||
LICENSE END */
|
||||
#pragma once
|
||||
|
||||
#include "sixtyfps.h"
|
||||
#include <iostream>
|
||||
|
||||
namespace sixtyfps::testing {
|
||||
inline void mock_elapsed_time(int64_t time_in_ms)
|
||||
|
@ -20,4 +20,20 @@ template<typename Component>
|
|||
inline void send_mouse_click(Component &component, float x, float y) {
|
||||
cbindgen_private::sixtyfps_send_mouse_click({&Component::component_type, &component}, x, y);
|
||||
}
|
||||
|
||||
#define assert_eq(A, B) sixtyfps::testing::private_api::assert_eq_impl(A, B, #A, #B, __FILE__, __LINE__)
|
||||
|
||||
namespace private_api {
|
||||
template<typename A, typename B>
|
||||
void assert_eq_impl(const A &a, const B &b, const char *a_str, const char *b_str,
|
||||
const char *file, int line) {
|
||||
if (a != b) {
|
||||
std::cerr << file << ":" << line <<": assert_eq FAILED!\n"
|
||||
<< a_str << ": " << a << "\n"
|
||||
<< b_str << ": " << b << std::endl;
|
||||
std::abort();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace sixtyfps
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue