12345678910111213141516171819202122232425262728293031323334353637383940 |
- #include "../Tests.hpp"
- #include "core/utils/Error.hpp"
- void Core::testError() {
- CORE_TEST_STRING("0", ErrorCode::NONE);
- CORE_TEST_STRING("1", ErrorCode::ERROR);
- CORE_TEST_STRING("01", ErrorCode::NEGATIVE_ARGUMENT);
- CORE_TEST_STRING("001", ErrorCode::CAPACITY_REACHED);
- CORE_TEST_STRING("0001", ErrorCode::BLOCKED_STDOUT);
- CORE_TEST_STRING("00001", ErrorCode::OUT_OF_MEMORY);
- CORE_TEST_STRING("000001", ErrorCode::INVALID_CHAR);
- CORE_TEST_STRING("0000001", ErrorCode::NOT_FOUND);
- CORE_TEST_STRING("00000001", ErrorCode::INVALID_STATE);
- CORE_TEST_STRING("000000001", ErrorCode::INVALID_INDEX);
- CORE_TEST_STRING("0000000001", ErrorCode::INVALID_ARGUMENT);
- CORE_TEST_STRING("00000000001", ErrorCode::TIME_NOT_AVAILABLE);
- CORE_TEST_STRING("000000000001", ErrorCode::SLEEP_INTERRUPTED);
- CORE_TEST_STRING("0000000000001", ErrorCode::THREAD_ERROR);
- CORE_TEST_STRING("00000000000001", ErrorCode::MUTEX_ERROR);
- CORE_TEST_STRING("000000000000001", ErrorCode::EXISTING_KEY);
- CORE_TEST_STRING("0000000000000001", ErrorCode::CANNOT_OPEN_FILE);
- CORE_TEST_STRING("00000000000000001", ErrorCode::END_OF_FILE);
- CORE_TEST_STRING(
- "11111111111111111",
- ErrorCode::ERROR | ErrorCode::NEGATIVE_ARGUMENT |
- ErrorCode::CAPACITY_REACHED | ErrorCode::BLOCKED_STDOUT |
- ErrorCode::OUT_OF_MEMORY | ErrorCode::INVALID_CHAR |
- ErrorCode::NOT_FOUND | ErrorCode::INVALID_STATE |
- ErrorCode::INVALID_INDEX | ErrorCode::INVALID_ARGUMENT |
- ErrorCode::TIME_NOT_AVAILABLE | ErrorCode::SLEEP_INTERRUPTED |
- ErrorCode::THREAD_ERROR | ErrorCode::MUTEX_ERROR |
- ErrorCode::EXISTING_KEY | ErrorCode::CANNOT_OPEN_FILE |
- ErrorCode::END_OF_FILE);
- char buffer[4];
- CORE_TEST_EQUAL(
- 8, Core::toString(ErrorCode::INVALID_STATE, buffer, sizeof(buffer)));
- CORE_TEST_STRING("000", buffer);
- }
|