Commit 58a29664 authored by Thomas Schlichter's avatar Thomas Schlichter Committed by francescomani

add test for log2_approx()

parent 4e09353b
......@@ -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)
#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();
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment