From 00ffdf75af43d714f7b0a0f9b93b030815d1a07b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=91=D1=80=D0=B0=D0=BD=D0=B8=D0=BC=D0=B8=D1=80=20=D0=9A?= =?UTF-8?q?=D0=B0=D1=80=D0=B0=D1=9F=D0=B8=D1=9B?= Date: Mon, 11 Dec 2023 21:36:34 -0800 Subject: [PATCH] Added floorLog2 tests. --- tests/math_test.cpp | 66 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/tests/math_test.cpp b/tests/math_test.cpp index 9daff9e..4c24c16 100644 --- a/tests/math_test.cpp +++ b/tests/math_test.cpp @@ -104,6 +104,72 @@ TEST_CASE("ceilLog2", "[math]") } } +TEST_CASE("floorLog2", "[math]") +{ + REQUIRE(0 == bx::floorLog2(-1) ); + REQUIRE(0 == bx::floorLog2(0) ); + REQUIRE(0 == bx::floorLog2(1) ); + REQUIRE(1 == bx::floorLog2(2) ); + REQUIRE(2 == bx::floorLog2(4) ); + REQUIRE(3 == bx::floorLog2(8) ); + REQUIRE(4 == bx::floorLog2(16) ); + REQUIRE(5 == bx::floorLog2(32) ); + REQUIRE(6 == bx::floorLog2(64) ); + REQUIRE(7 == bx::floorLog2(128) ); + REQUIRE(8 == bx::floorLog2(256) ); + + { + uint32_t ii = 0; + for (; ii < 8; ++ii) + { + REQUIRE(ii == bx::floorLog2(uint8_t(1<(1) );