added asserts with number
This commit is contained in:
parent
dde9be29fc
commit
0d4b15c266
|
|
@ -29,6 +29,17 @@
|
|||
#define TEST_PASS_MSG_TYPE(msg, type_hint) ret_val_s { "", ReturnCode::PASSED, msg, to_type_hint_str::value<type_hint> }
|
||||
#define TEST_SKIP_TYPE(type_hint) ret_val_s { "", ReturnCode::SKIPPED, nullptr, to_type_hint_str::value<type_hint> }
|
||||
|
||||
#define TEST_FAIL_TYPE_NUM(msg, type_hint, num) ret_val_s { "", ReturnCode::FAILED, msg, to_type_hint_str::value<type_hint>, num }
|
||||
#define TEST_PASS_TYPE_NUM(type_hint, num) ret_val_s { "", ReturnCode::PASSED, nullptr, to_type_hint_str::value<type_hint>, num }
|
||||
#define TEST_PASS_MSG_TYPE_NUM(msg, type_hint, num) ret_val_s { "", ReturnCode::PASSED, msg, to_type_hint_str::value<type_hint>, num }
|
||||
#define TEST_SKIP_TYPE_NUM(type_hint, num) ret_val_s { "", ReturnCode::SKIPPED, nullptr, to_type_hint_str::value<type_hint>, num }
|
||||
|
||||
#define ASSERT_TYPE_NUM(condition, type, num) ASSERT_TYPE_NUM_MSG(condition, #condition "" _LOCATION, type, num)
|
||||
#define ASSERT_TYPE_NUM_MSG(condition, msg, type, num) { if (!(condition)) return TEST_FAIL_TYPE_NUM(msg, type, num); } static_assert(true, "")
|
||||
#define ASSERT_TYPE_NUM_ALL_EQ(first, last, eq, type, num) ASSERT_TYPE_NUM_MSG(std::all_of(first, last, all_eq_arr_elem_test_func(eq)), "Not all elements in (" #first ", " #last ") equal " #eq "" _LOCATION, type, num)
|
||||
#define ASSERT_TYPE_NUM_C_ARR_EQ(first, last, eq, type, num) ASSERT_TYPE_NUM_MSG(std::equal(first, last, eq, all_eq_arr_arr_test_func<decltype(eq)>()), "Elements in (" #first ", " #last ") and " #eq " differ" _LOCATION, type, num)
|
||||
#define ASSERT_TYPE_NUM_ITER_EQ(first, last, eq, type, num) ASSERT_TYPE_NUM_MSG(std::equal(first, last, (eq).begin(), all_eq_arr_arr_test_func<std::iterator_traits<decltype(eq)::iterator>::value_type>()), "Elements in (" #first ", " #last ") and " #eq " differ" _LOCATION, type, num)
|
||||
|
||||
#define ASSERT_TYPE(condition, type) ASSERT_TYPE_MSG(condition, #condition "" _LOCATION, type)
|
||||
#define ASSERT_TYPE_MSG(condition, msg, type) { if (!(condition)) return TEST_FAIL_TYPE(msg, type); } static_assert(true, "")
|
||||
#define ASSERT_TYPE_ALL_EQ(first, last, eq, type) ASSERT_TYPE_MSG(std::all_of(first, last, all_eq_arr_elem_test_func(eq)), "Not all elements in (" #first ", " #last ") equal " #eq "" _LOCATION, type)
|
||||
|
|
@ -41,7 +52,8 @@
|
|||
#define ASSERT_C_ARR_EQ(first, last, eq) ASSERT_TYPE_C_ARR_EQ(first, last, eq, std::nullptr_t)
|
||||
#define ASSERT_ITER_EQ(first, last, eq) ASSERT_TYPE_ITER_EQ(first, last, eq, std::nullptr_t)
|
||||
|
||||
#define ASSERT_TYPE_THROWS(operation, exception_type, type) if not consteval { try { operation; ASSERT_TYPE_MSG(false, #operation " did not throw " #exception_type _LOCATION, type); } catch (exception_type &e) {} } static_assert(true, "")
|
||||
#define ASSERT_TYPE_NUM_THROWS(operation, exception_type, type, num) if not consteval { try { operation; ASSERT_TYPE_NUM_MSG(false, #operation " did not throw " #exception_type _LOCATION, type, num); } catch (exception_type &e) {} } static_assert(true, "")
|
||||
#define ASSERT_TYPE_THROWS(operation, exception_type, type) ASSERT_TYPE_NUM_THROWS(operation, exception_type, type, -1ULL)
|
||||
#define ASSERT_THROWS(operation, exception_type) ASSERT_TYPE_THROWS(operation, exception_type, std::nullptr_t)
|
||||
|
||||
template<typename T>
|
||||
|
|
@ -89,6 +101,7 @@ struct ret_val_s {
|
|||
ReturnCode val = ReturnCode::FAILED;
|
||||
const char *msg = "";
|
||||
const char *type_hint = nullptr;
|
||||
std::size_t param_nr = -1;
|
||||
};
|
||||
|
||||
template<std::size_t Nr>
|
||||
|
|
@ -183,6 +196,9 @@ class test_suite {
|
|||
if (ret.type_hint != nullptr) {
|
||||
std::cout << "\n\t" << "with type '" << ret.type_hint << "'";
|
||||
}
|
||||
if (ret.param_nr != -1) {
|
||||
std::cout << "\n\t" << "with parameter param_nr: " << ret.param_nr;
|
||||
}
|
||||
std::cout << std::endl;
|
||||
|
||||
ret_vals[i][0] = ret.val;
|
||||
|
|
@ -197,6 +213,9 @@ class test_suite {
|
|||
if (ret.type_hint != nullptr) {
|
||||
std::cout << "\n\t" << "with type '" << ret.type_hint << "'";
|
||||
}
|
||||
if (ret.param_nr != -1) {
|
||||
std::cout << "\n\t" << "with parameter param_nr: " << ret.param_nr;
|
||||
}
|
||||
std::cout << std::endl;
|
||||
|
||||
ret_vals[i][1] = ret.val;
|
||||
|
|
|
|||
Loading…
Reference in New Issue