summaryrefslogtreecommitdiffstats
path: root/src/tests/common/bit_utils.cpp
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2019-03-29 02:41:40 +0100
committerGitHub <noreply@github.com>2019-03-29 02:41:40 +0100
commitb404fcdf1443b91ac9994c05ad1fe039fcd9675e (patch)
tree42b6141dcd6a5315f9330f064524963a7915c28a /src/tests/common/bit_utils.cpp
parentMerge pull request #2284 from lioncash/heap-alloc (diff)
parentFixes and corrections on formatting. (diff)
downloadyuzu-b404fcdf1443b91ac9994c05ad1fe039fcd9675e.tar
yuzu-b404fcdf1443b91ac9994c05ad1fe039fcd9675e.tar.gz
yuzu-b404fcdf1443b91ac9994c05ad1fe039fcd9675e.tar.bz2
yuzu-b404fcdf1443b91ac9994c05ad1fe039fcd9675e.tar.lz
yuzu-b404fcdf1443b91ac9994c05ad1fe039fcd9675e.tar.xz
yuzu-b404fcdf1443b91ac9994c05ad1fe039fcd9675e.tar.zst
yuzu-b404fcdf1443b91ac9994c05ad1fe039fcd9675e.zip
Diffstat (limited to 'src/tests/common/bit_utils.cpp')
-rw-r--r--src/tests/common/bit_utils.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/tests/common/bit_utils.cpp b/src/tests/common/bit_utils.cpp
new file mode 100644
index 000000000..479b5995a
--- /dev/null
+++ b/src/tests/common/bit_utils.cpp
@@ -0,0 +1,23 @@
+// Copyright 2017 Citra Emulator Project
+// Licensed under GPLv2 or any later version
+// Refer to the license.txt file included.
+
+#include <catch2/catch.hpp>
+#include <math.h>
+#include "common/bit_util.h"
+
+namespace Common {
+
+TEST_CASE("BitUtils::CountTrailingZeroes", "[common]") {
+ REQUIRE(Common::CountTrailingZeroes32(0) == 32);
+ REQUIRE(Common::CountTrailingZeroes64(0) == 64);
+ REQUIRE(Common::CountTrailingZeroes32(9) == 0);
+ REQUIRE(Common::CountTrailingZeroes32(8) == 3);
+ REQUIRE(Common::CountTrailingZeroes32(0x801000) == 12);
+ REQUIRE(Common::CountTrailingZeroes64(9) == 0);
+ REQUIRE(Common::CountTrailingZeroes64(8) == 3);
+ REQUIRE(Common::CountTrailingZeroes64(0x801000) == 12);
+ REQUIRE(Common::CountTrailingZeroes64(0x801000000000UL) == 36);
+}
+
+} // namespace Common