forked from M-Labs/nac3
1
0
Fork 0
nac3/nac3core/irrt/test/test_utils.hpp

27 lines
782 B
C++
Raw Normal View History

2024-07-13 23:58:29 +08:00
#pragma once
#include <test/core.hpp>
#include <irrt/utils.hpp>
2024-07-13 23:58:29 +08:00
void test_int_log_10() {
BEGIN_TEST();
assert_values_match((uint32_t) 0, int_log_floor(0, 10));
assert_values_match((uint32_t) 0, int_log_floor(9, 10));
assert_values_match((uint32_t) 1, int_log_floor(10, 10));
assert_values_match((uint32_t) 1, int_log_floor(11, 10));
assert_values_match((uint32_t) 1, int_log_floor(99, 10));
assert_values_match((uint32_t) 2, int_log_floor(100, 10));
assert_values_match((uint32_t) 2, int_log_floor(101, 10));
}
void test_cstr_utils() {
BEGIN_TEST();
assert_values_match((uint32_t) 42, (uint32_t) cstr_utils::length("THROWN FROM __nac3_error_dummy_raise!!!!!!"));
}
void run_test_utils() {
test_int_log_10();
test_cstr_utils();
}