The check to see if an item was already on the heap was randomly hitting.
[jitcs.git] / tests / test_power2funcs.cpp
blobb4a76a647980f58dafd697d1922017428d9a9a47
1 #include "jitcs_int_power2funcs.h"
2 #include "unittest.h"
4 using namespace jitcs;
6 static void test(UnitTest& t) {
7 t.check("IsPowerOf2OrZeroCT/0", IsPowerOf2OrZeroCT<0>::Val == true);
8 t.check("IsPowerOf2OrZeroCT/3", IsPowerOf2OrZeroCT<3>::Val == false);
9 t.check("IsPowerOf2OrZeroCT/4", IsPowerOf2OrZeroCT<4>::Val == true);
10 t.check("IsPowerOf2CT/0", IsPowerOf2CT<0>::Val == false);
11 t.check("IsPowerOf2CT/3", IsPowerOf2CT<3>::Val == false);
12 t.check("IsPowerOf2CT/4", IsPowerOf2CT<4>::Val == true);
13 t.check("Log2CT/1", Log2CT<1>::Val == 0);
14 t.check("Log2CT/4", Log2CT<4>::Val == 2);
15 t.check("Log2CT/5", Log2CT<5>::Val == 2);
16 t.check("RoundUpToPowerOf2CT/16,16", RoundUpToPowerOf2CT<16,16>::Val == 16);
17 t.check("RoundUpToPowerOf2CT/20,16", RoundUpToPowerOf2CT<20,16>::Val == 32);
19 t.check("IsPowerOf2OrZero/0", IsPowerOf2OrZero(0) == true);
20 t.check("IsPowerOf2OrZero/3", IsPowerOf2OrZero(3) == false);
21 t.check("IsPowerOf2OrZero/4", IsPowerOf2OrZero(4) == true);
22 t.check("IsPowerOf2/0", IsPowerOf2(0) == false);
23 t.check("IsPowerOf2/3", IsPowerOf2(3) == false);
24 t.check("IsPowerOf2/4", IsPowerOf2(4) == true);
25 t.check("RoundUpToPowerOf2/16,T16", RoundUpToPowerOf2<16>(16) == 16);
26 t.check("RoundUpToPowerOf2/20,T16", RoundUpToPowerOf2<16>(20) == 32);
27 t.check("RoundUpToPowerOf2/16,16", RoundUpToPowerOf2(16,16) == 16);
28 t.check("RoundUpToPowerOf2/20,16", RoundUpToPowerOf2(20,16) == 32);
29 t.check("DivRoundedUpByPowerOf2/16,T16", DivRoundedUpByPowerOf2<16>(16) == 1);
30 t.check("DivRoundedUpByPowerOf2/20,T16", DivRoundedUpByPowerOf2<16>(20) == 2);
33 static UnitTestRun _1("ADT/PowerOf2Funcs", test);