add test for log2_approx()
This commit is contained in:
committed by
francescomani
parent
4e09353b43
commit
58a2966499
@@ -9,3 +9,9 @@ target_link_libraries(benchmark_rotate_vector PRIVATE benchmark::benchmark UTIL
|
||||
add_dependencies(tests benchmark_rotate_vector)
|
||||
add_test(NAME benchmark_rotate_vector
|
||||
COMMAND ./benchmark_rotate_vector)
|
||||
|
||||
add_executable(test_log2_approx test_log2_approx.cpp ../log2_approx.c)
|
||||
target_link_libraries(test_log2_approx PRIVATE GTest::gtest LOG minimal_lib)
|
||||
add_dependencies(tests test_log2_approx)
|
||||
add_test(NAME test_log2_approx
|
||||
COMMAND ./test_log2_approx)
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
#include <gtest/gtest.h>
|
||||
extern "C" {
|
||||
#include "openair1/PHY/TOOLS/tools_defs.h"
|
||||
#include "common/utils/LOG/log.h"
|
||||
}
|
||||
#include <cmath>
|
||||
|
||||
uint8_t log2_approx_ref(uint32_t x)
|
||||
{
|
||||
return std::round(std::log2(x));
|
||||
}
|
||||
|
||||
TEST(log2_approx_ref, complete)
|
||||
{
|
||||
for (uint32_t i = 0; i < UINT32_MAX; i++)
|
||||
EXPECT_EQ(log2_approx(i), log2_approx_ref(i));
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
logInit();
|
||||
testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
Reference in New Issue
Block a user