UtilityTests.cpp 799 B

1234567891011121314151617181920212223242526
  1. #include "tests/UtilityTests.h"
  2. #include "test/Test.h"
  3. #include "utils/Utility.h"
  4. static void testPopCount() {
  5. CORE_TEST_EQUAL(4, Core::popCount(0xF));
  6. CORE_TEST_EQUAL(0, Core::popCount(0x0));
  7. CORE_TEST_EQUAL(2, Core::popCount(0x6));
  8. CORE_TEST_EQUAL(7, Core::popCount(0x7F));
  9. CORE_TEST_EQUAL(3, Core::popCount(0x2A));
  10. CORE_TEST_EQUAL(32, Core::popCount(0xFFFFFFFF));
  11. CORE_TEST_EQUAL(64, Core::popCount(0xFFFFFFFFFFFFFFFFL));
  12. CORE_TEST_EQUAL(44, Core::popCount(0xFFFF0FFFFFFF));
  13. CORE_TEST_EQUAL(32, Core::popCount(-1));
  14. }
  15. static void testIf() {
  16. CORE_TEST_TRUE((Core::IsSame<Core::If<true, int, double>, int>));
  17. CORE_TEST_TRUE((Core::IsSame<Core::If<false, int, double>, double>));
  18. }
  19. void Core::UtilityTests::test() {
  20. testPopCount();
  21. testIf();
  22. }