diff options
author | Fernando Sahmkow <fsahmkow27@gmail.com> | 2019-03-20 03:20:15 +0100 |
---|---|---|
committer | FernandoS27 <fsahmkow27@gmail.com> | 2019-03-27 19:49:43 +0100 |
commit | db42bcb306323d6221e7f893d39558c3db579bf3 (patch) | |
tree | ef23218b123f80a0c2a773908a6fa2685cd34898 /src/tests/common | |
parent | Fixes to multilevelqueue's iterator. (diff) | |
download | yuzu-db42bcb306323d6221e7f893d39558c3db579bf3.tar yuzu-db42bcb306323d6221e7f893d39558c3db579bf3.tar.gz yuzu-db42bcb306323d6221e7f893d39558c3db579bf3.tar.bz2 yuzu-db42bcb306323d6221e7f893d39558c3db579bf3.tar.lz yuzu-db42bcb306323d6221e7f893d39558c3db579bf3.tar.xz yuzu-db42bcb306323d6221e7f893d39558c3db579bf3.tar.zst yuzu-db42bcb306323d6221e7f893d39558c3db579bf3.zip |
Diffstat (limited to 'src/tests/common')
-rw-r--r-- | src/tests/common/bit_utils.cpp | 39 | ||||
-rw-r--r-- | src/tests/common/multi_level_queue.cpp | 2 |
2 files changed, 11 insertions, 30 deletions
diff --git a/src/tests/common/bit_utils.cpp b/src/tests/common/bit_utils.cpp index 77c17c526..479b5995a 100644 --- a/src/tests/common/bit_utils.cpp +++ b/src/tests/common/bit_utils.cpp @@ -8,35 +8,16 @@ namespace Common { -inline u32 CTZ32(u32 value) { - u32 count = 0; - while (((value >> count) & 0xf) == 0 && count < 32) - count += 4; - while (((value >> count) & 1) == 0 && count < 32) - count++; - return count; -} - -inline u64 CTZ64(u64 value) { - u64 count = 0; - while (((value >> count) & 0xf) == 0 && count < 64) - count += 4; - while (((value >> count) & 1) == 0 && count < 64) - count++; - return count; -} - - -TEST_CASE("BitUtils", "[common]") { - REQUIRE(Common::CountTrailingZeroes32(0) == CTZ32(0)); - REQUIRE(Common::CountTrailingZeroes64(0) == CTZ64(0)); - REQUIRE(Common::CountTrailingZeroes32(9) == CTZ32(9)); - REQUIRE(Common::CountTrailingZeroes32(8) == CTZ32(8)); - REQUIRE(Common::CountTrailingZeroes32(0x801000) == CTZ32(0x801000)); - REQUIRE(Common::CountTrailingZeroes64(9) == CTZ64(9)); - REQUIRE(Common::CountTrailingZeroes64(8) == CTZ64(8)); - REQUIRE(Common::CountTrailingZeroes64(0x801000) == CTZ64(0x801000)); - REQUIRE(Common::CountTrailingZeroes64(0x801000000000UL) == CTZ64(0x801000000000UL)); +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 diff --git a/src/tests/common/multi_level_queue.cpp b/src/tests/common/multi_level_queue.cpp index 9a8b84695..cca7ec7da 100644 --- a/src/tests/common/multi_level_queue.cpp +++ b/src/tests/common/multi_level_queue.cpp @@ -11,7 +11,7 @@ namespace Common { TEST_CASE("MultiLevelQueue", "[common]") { std::array<f32, 8> values = {0.0, 5.0, 1.0, 9.0, 8.0, 2.0, 6.0, 7.0}; - Common::MultiLevelQueue<f32,64> mlq; + Common::MultiLevelQueue<f32, 64> mlq; REQUIRE(mlq.empty()); mlq.add(values[2], 2); mlq.add(values[7], 7); |