bit_utils.cpp 810 B

1234567891011121314151617181920212223
  1. // Copyright 2017 Citra Emulator Project
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #include <catch2/catch.hpp>
  5. #include <math.h>
  6. #include "common/bit_util.h"
  7. namespace Common {
  8. TEST_CASE("BitUtils::CountTrailingZeroes", "[common]") {
  9. REQUIRE(Common::CountTrailingZeroes32(0) == 32);
  10. REQUIRE(Common::CountTrailingZeroes64(0) == 64);
  11. REQUIRE(Common::CountTrailingZeroes32(9) == 0);
  12. REQUIRE(Common::CountTrailingZeroes32(8) == 3);
  13. REQUIRE(Common::CountTrailingZeroes32(0x801000) == 12);
  14. REQUIRE(Common::CountTrailingZeroes64(9) == 0);
  15. REQUIRE(Common::CountTrailingZeroes64(8) == 3);
  16. REQUIRE(Common::CountTrailingZeroes64(0x801000) == 12);
  17. REQUIRE(Common::CountTrailingZeroes64(0x801000000000UL) == 36);
  18. }
  19. } // namespace Common