ErrorTests.cpp 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #include "../Tests.hpp"
  2. #include "core/utils/Error.hpp"
  3. void Core::testError() {
  4. CORE_TEST_STRING("0", ErrorCode::NONE);
  5. CORE_TEST_STRING("1", ErrorCode::ERROR);
  6. CORE_TEST_STRING("01", ErrorCode::NEGATIVE_ARGUMENT);
  7. CORE_TEST_STRING("001", ErrorCode::CAPACITY_REACHED);
  8. CORE_TEST_STRING("0001", ErrorCode::BLOCKED_STDOUT);
  9. CORE_TEST_STRING("00001", ErrorCode::OUT_OF_MEMORY);
  10. CORE_TEST_STRING("000001", ErrorCode::INVALID_CHAR);
  11. CORE_TEST_STRING("0000001", ErrorCode::NOT_FOUND);
  12. CORE_TEST_STRING("00000001", ErrorCode::INVALID_STATE);
  13. CORE_TEST_STRING("000000001", ErrorCode::INVALID_INDEX);
  14. CORE_TEST_STRING("0000000001", ErrorCode::INVALID_ARGUMENT);
  15. CORE_TEST_STRING("00000000001", ErrorCode::TIME_NOT_AVAILABLE);
  16. CORE_TEST_STRING("000000000001", ErrorCode::SLEEP_INTERRUPTED);
  17. CORE_TEST_STRING("0000000000001", ErrorCode::THREAD_ERROR);
  18. CORE_TEST_STRING("00000000000001", ErrorCode::MUTEX_ERROR);
  19. CORE_TEST_STRING("000000000000001", ErrorCode::EXISTING_KEY);
  20. CORE_TEST_STRING("0000000000000001", ErrorCode::CANNOT_OPEN_FILE);
  21. CORE_TEST_STRING("00000000000000001", ErrorCode::END_OF_FILE);
  22. CORE_TEST_STRING(
  23. "11111111111111111",
  24. ErrorCode::ERROR | ErrorCode::NEGATIVE_ARGUMENT |
  25. ErrorCode::CAPACITY_REACHED | ErrorCode::BLOCKED_STDOUT |
  26. ErrorCode::OUT_OF_MEMORY | ErrorCode::INVALID_CHAR |
  27. ErrorCode::NOT_FOUND | ErrorCode::INVALID_STATE |
  28. ErrorCode::INVALID_INDEX | ErrorCode::INVALID_ARGUMENT |
  29. ErrorCode::TIME_NOT_AVAILABLE | ErrorCode::SLEEP_INTERRUPTED |
  30. ErrorCode::THREAD_ERROR | ErrorCode::MUTEX_ERROR |
  31. ErrorCode::EXISTING_KEY | ErrorCode::CANNOT_OPEN_FILE |
  32. ErrorCode::END_OF_FILE);
  33. char buffer[4];
  34. CORE_TEST_EQUAL(
  35. 8, Core::toString(ErrorCode::INVALID_STATE, buffer, sizeof(buffer)));
  36. CORE_TEST_STRING("000", buffer);
  37. }