#include "tests/UtilityTests.h" #include "test/Test.h" #include "utils/Utility.h" static void testPopCount(Core::Test& test) { test.checkEqual(4, Core::popCount(0xF), "pop count 1"); test.checkEqual(0, Core::popCount(0x0), "pop count 2"); test.checkEqual(2, Core::popCount(0x6), "pop count 3"); test.checkEqual(7, Core::popCount(0x7F), "pop count 4"); test.checkEqual(3, Core::popCount(0x2A), "pop count 5"); test.checkEqual(32, Core::popCount(0xFFFFFFFF), "pop count 6"); test.checkEqual(64, Core::popCount(0xFFFFFFFFFFFFFFFFL), "pop count 7"); test.checkEqual(44, Core::popCount(0xFFFF0FFFFFFF), "pop count 8"); test.checkEqual(32, Core::popCount(-1), "pop count 9"); } void Core::UtilityTests::test() { Core::Test test("Utility"); testPopCount(test); test.finalize(); }