MCPcopy Create free account
hub / github.com/catboost/catboost / TestFastClp2ForEachPowerOf2

Function TestFastClp2ForEachPowerOf2

util/generic/bitops_ut.cpp:15–29  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13
14template <typename T>
15static void TestFastClp2ForEachPowerOf2() {
16 for (size_t i = 0; i < sizeof(T) * 8 - 1; ++i) {
17 const auto current = T(1) << i;
18 UNIT_ASSERT_VALUES_EQUAL(FastClp2(current), current);
19 }
20
21 UNIT_ASSERT_VALUES_EQUAL(FastClp2(T(1)), T(1));
22 for (size_t i = 1; i < sizeof(T) * 8 - 1; ++i) {
23 for (size_t j = 0; j < i; ++j) {
24 const auto value = (T(1) << i) | (T(1) << j);
25 const auto next = T(1) << (i + 1);
26 UNIT_ASSERT_VALUES_EQUAL(FastClp2(value), next);
27 }
28 }
29}
30
31template <typename T>
32static T ReverseBitsSlow(T v) {

Callers

nothing calls this directly

Calls 2

FastClp2Function · 0.85
TClass · 0.70

Tested by

no test coverage detected