add test for log2_approx()

This commit is contained in:
Thomas Schlichter
2024-09-23 17:58:05 +02:00
committed by francescomani
parent 4e09353b43
commit 58a2966499
2 changed files with 30 additions and 0 deletions
@@ -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();
}