Browse Source

Error can store multiple errors

Kajetan Johannes Hammerle 2 weeks ago
parent
commit
a8989829d7
71 changed files with 362 additions and 335 deletions
  1. 1 2
      CMakeLists.txt
  2. 5 5
      include/core/data/ArrayList.hpp
  3. 1 1
      include/core/data/BitArray.hpp
  4. 3 3
      include/core/data/Components.hpp
  5. 11 11
      include/core/data/HashMap.hpp
  6. 4 4
      include/core/data/LinkedList.hpp
  7. 14 14
      include/core/data/List.hpp
  8. 11 11
      include/core/data/ProbingHashMap.hpp
  9. 5 5
      include/core/data/RingBuffer.hpp
  10. 2 2
      include/core/data/Stack.hpp
  11. 2 2
      include/core/math/Box.hpp
  12. 1 1
      include/core/math/BufferedValue.hpp
  13. 2 2
      include/core/math/Frustum.hpp
  14. 1 1
      include/core/math/Math.hpp
  15. 2 2
      include/core/math/Matrix.hpp
  16. 2 2
      include/core/math/MatrixStack.hpp
  17. 2 2
      include/core/math/Plane.hpp
  18. 2 2
      include/core/math/Quaternion.hpp
  19. 1 1
      include/core/math/View.hpp
  20. 1 1
      include/core/thread/Mutex.hpp
  21. 1 1
      include/core/thread/Thread.hpp
  22. 3 10
      include/core/utils/ArrayString.hpp
  23. 60 22
      include/core/utils/Error.hpp
  24. 2 1
      include/core/utils/HashCode.hpp
  25. 2 2
      include/core/utils/Logger.hpp
  26. 1 1
      include/core/utils/Meta.hpp
  27. 26 33
      src/ArrayString.cpp
  28. 4 4
      src/BitArray.cpp
  29. 2 2
      src/Buffer.cpp
  30. 7 7
      src/Clock.cpp
  31. 17 24
      src/Error.cpp
  32. 1 1
      src/ErrorSimulator.cpp
  33. 1 1
      src/ErrorSimulator.hpp
  34. 9 9
      src/FileReader.cpp
  35. 1 1
      src/Logger.cpp
  36. 1 1
      src/Math.cpp
  37. 8 7
      src/Mutex.cpp
  38. 1 1
      src/Plane.cpp
  39. 1 1
      src/Quaternion.cpp
  40. 4 4
      src/Thread.cpp
  41. 8 8
      src/Utility.cpp
  42. 1 1
      src/Vector.cpp
  43. 1 2
      test/Test.cpp
  44. 4 4
      test/Test.hpp
  45. 5 5
      test/modules/ArrayListTests.cpp
  46. 14 14
      test/modules/ArrayStringTests.cpp
  47. 1 1
      test/modules/ArrayTests.cpp
  48. 8 8
      test/modules/BitArrayTests.cpp
  49. 1 1
      test/modules/BoxTests.cpp
  50. 1 1
      test/modules/BufferTests.cpp
  51. 1 1
      test/modules/BufferedValueTests.cpp
  52. 3 2
      test/modules/ClockTests.cpp
  53. 1 1
      test/modules/ColorTests.cpp
  54. 4 4
      test/modules/ComponentsTests.cpp
  55. 29 23
      test/modules/ErrorTests.cpp
  56. 10 10
      test/modules/FileReaderTests.cpp
  57. 1 1
      test/modules/FrustumTests.cpp
  58. 6 5
      test/modules/HashMapTests.cpp
  59. 1 1
      test/modules/LinkedListTests.cpp
  60. 8 8
      test/modules/ListTests.cpp
  61. 1 1
      test/modules/MathTests.cpp
  62. 3 3
      test/modules/MatrixStackTests.cpp
  63. 1 1
      test/modules/PlaneTests.cpp
  64. 7 6
      test/modules/ProbingHashMapTests.cpp
  65. 1 1
      test/modules/RandomTests.cpp
  66. 5 5
      test/modules/RingBufferTests.cpp
  67. 2 2
      test/modules/StackTests.cpp
  68. 4 4
      test/modules/ThreadTests.cpp
  69. 3 2
      test/modules/UtilityTests.cpp
  70. 1 1
      test/modules/VectorTests.cpp
  71. 1 1
      test/modules/ViewTests.cpp

+ 1 - 2
CMakeLists.txt

@@ -175,13 +175,12 @@ target_compile_options(core PUBLIC
     -Wsign-conversion
     -Wsign-promo
     -Wstack-protector
-    -Wstrict-overflow=5
+    -Wstrict-overflow=2
     -Wsuggest-override
     -Wswitch-enum
     -Wsynth
     -Wundef
     -Wunreachable-code
-    -Wunused-macros
     -Wvla
     -Wwrite-strings
     -Wzero-as-null-pointer-constant

+ 5 - 5
include/core/data/ArrayList.hpp

@@ -65,10 +65,10 @@ namespace Core {
         template<typename... Args>
         check_return Error put(T*& t, Args&&... args) {
             if(length >= N) {
-                return Error::CAPACITY_REACHED;
+                return ErrorCode::CAPACITY_REACHED;
             }
             t = new(begin() + length++) T(Core::forward<Args>(args)...);
-            return Error::NONE;
+            return ErrorCode::NONE;
         }
 
         template<typename... Args>
@@ -98,14 +98,14 @@ namespace Core {
 
         check_return Error removeBySwap(i64 index) {
             if(index < 0 || index >= length) {
-                return Error::INVALID_INDEX;
+                return ErrorCode::INVALID_INDEX;
             }
             length--;
             if(index != length) {
                 begin()[index] = Core::move(begin()[length]);
             }
             begin()[length].~T();
-            return Error::NONE;
+            return ErrorCode::NONE;
         }
 
         check_return Error removeLast() {
@@ -132,4 +132,4 @@ namespace Core {
     };
 }
 
-#endif
+#endif

+ 1 - 1
include/core/data/BitArray.hpp

@@ -50,4 +50,4 @@ namespace Core {
     };
 }
 
-#endif
+#endif

+ 3 - 3
include/core/data/Components.hpp

@@ -63,7 +63,7 @@ namespace Core {
             i64 index = components.getLength();
             i64* indexP = nullptr;
             CORE_RETURN_ERROR(entityToIndex.tryEmplace(indexP, ent, index));
-            Error e = Error::NONE;
+            Error e = ErrorCode::NONE;
             if(checkError(e, indexToEntity.add(ent))) {
                 (void)entityToIndex.remove(ent);
                 return e;
@@ -84,7 +84,7 @@ namespace Core {
         check_return Error remove(Entity ent) {
             i64* indexP = entityToIndex.search(ent);
             if(indexP == nullptr) {
-                return Error::NOT_FOUND;
+                return ErrorCode::NOT_FOUND;
             }
             i64 lastIndex = components.getLength() - 1;
             i64 index = *indexP;
@@ -140,4 +140,4 @@ namespace Core {
     };
 }
 
-#endif
+#endif

+ 11 - 11
include/core/data/HashMap.hpp

@@ -124,12 +124,12 @@ namespace Core {
             }
             swap(copy.nodes, nodes);
             swap(copy.nodePointers, nodePointers);
-            return Error::NONE;
+            return ErrorCode::NONE;
         }
 
         check_return Error rehash(i64 minCapacity) {
             if(minCapacity <= nodePointers.getLength()) {
-                return Error::NONE;
+                return ErrorCode::NONE;
             }
             HashMap<K, V> map;
             i64 l = 1l << Math::roundUpLog2(Core::Math::max(minCapacity, 8l));
@@ -141,7 +141,7 @@ namespace Core {
                 }
             }
             Core::swap(map.nodePointers, nodePointers);
-            return Error::NONE;
+            return ErrorCode::NONE;
         }
 
         template<typename... Args>
@@ -150,17 +150,17 @@ namespace Core {
             i64 h = hashIndex(key);
             v = searchList(key, h);
             if(v != nullptr) {
-                return Error::EXISTING_KEY;
+                return ErrorCode::EXISTING_KEY;
             }
             NodePointer np = nullptr;
             CORE_RETURN_ERROR(nodes.put(np, key, Core::forward<Args>(args)...));
-            Error e = Error::NONE;
+            Error e = ErrorCode::NONE;
             if(checkError(e, nodePointers[h].add(np))) {
                 nodes.remove(np);
                 return e;
             }
             v = &(np->data.value);
-            return Error::NONE;
+            return ErrorCode::NONE;
         }
 
         template<typename VA>
@@ -170,17 +170,17 @@ namespace Core {
             v = searchList(key, h);
             if(v != nullptr) {
                 *v = Core::forward<VA>(value);
-                return Error::NONE;
+                return ErrorCode::NONE;
             }
             NodePointer np = nullptr;
             CORE_RETURN_ERROR(nodes.put(np, key, Core::forward<VA>(value)));
-            Error e = Error::NONE;
+            Error e = ErrorCode::NONE;
             if(checkError(e, nodePointers[h].add(np))) {
                 nodes.remove(np);
                 return e;
             }
             v = &(np->data.value);
-            return Error::NONE;
+            return ErrorCode::NONE;
         }
 
         template<typename VA>
@@ -197,7 +197,7 @@ namespace Core {
                     return list.removeBySwap(i);
                 }
             }
-            return Error::NOT_FOUND;
+            return ErrorCode::NOT_FOUND;
         }
 
         const V* search(const K& key) const {
@@ -280,4 +280,4 @@ namespace Core {
     };
 }
 
-#endif
+#endif

+ 4 - 4
include/core/data/LinkedList.hpp

@@ -77,25 +77,25 @@ namespace Core {
                 CORE_RETURN_ERROR(copy.add(t));
             }
             swap(copy);
-            return Error::NONE;
+            return ErrorCode::NONE;
         }
 
         template<typename... Args>
         check_return Error put(Node*& n, Args&&... args) {
             n = new(noThrow) Node(Core::forward<Args>(args)...);
             if(n == nullptr) {
-                return Error::OUT_OF_MEMORY;
+                return ErrorCode::OUT_OF_MEMORY;
             }
             length++;
             if(first == nullptr) {
                 first = n;
                 last = n;
-                return Error::NONE;
+                return ErrorCode::NONE;
             }
             last->next = n;
             n->previous = last;
             last = n;
-            return Error::NONE;
+            return ErrorCode::NONE;
         }
 
         template<typename... Args>

+ 14 - 14
include/core/data/List.hpp

@@ -41,7 +41,7 @@ namespace Core {
                 copy.unsafeAdd(other[i]);
             }
             swap(copy);
-            return Error::NONE;
+            return ErrorCode::NONE;
         }
 
         T* begin() {
@@ -62,14 +62,14 @@ namespace Core {
 
         check_return Error reserve(i64 n) {
             if(n <= capacity) {
-                return Error::NONE;
+                return ErrorCode::NONE;
             }
             return setSize(n);
         }
 
         check_return Error shrink() {
             if(length == capacity) {
-                return Error::NONE;
+                return ErrorCode::NONE;
             }
             return setSize(length);
         }
@@ -86,7 +86,7 @@ namespace Core {
                 }
                 length = n;
             }
-            return Error::NONE;
+            return ErrorCode::NONE;
         }
 
         check_return Error resize(i64 n) {
@@ -101,14 +101,14 @@ namespace Core {
                 }
                 length = n;
             }
-            return Error::NONE;
+            return ErrorCode::NONE;
         }
 
         template<typename... Args>
         check_return Error put(T*& t, Args&&... args) {
             CORE_RETURN_ERROR(ensureCapacity());
             t = unsafeAdd(Core::forward<Args>(args)...);
-            return Error::NONE;
+            return ErrorCode::NONE;
         }
 
         template<typename... Args>
@@ -142,19 +142,19 @@ namespace Core {
 
         check_return Error removeBySwap(i64 index) {
             if(index < 0 || index >= length) {
-                return Error::INVALID_INDEX;
+                return ErrorCode::INVALID_INDEX;
             }
             length--;
             if(index != length) {
                 data[index] = Core::move(data[length]);
             }
             data[length].~T();
-            return Error::NONE;
+            return ErrorCode::NONE;
         }
 
         check_return Error remove(i64 index) {
             if(index < 0 || index >= length) {
-                return Error::INVALID_INDEX;
+                return ErrorCode::INVALID_INDEX;
             }
             length--;
             T* currentT = begin() + index;
@@ -165,7 +165,7 @@ namespace Core {
                 currentT = nextT;
             }
             endT->~T();
-            return Error::NONE;
+            return ErrorCode::NONE;
         }
 
         check_return Error removeLast() {
@@ -186,16 +186,16 @@ namespace Core {
     private:
         static Error allocate(T*& t, i64 n) {
             if(n <= 0) {
-                return Error::NONE;
+                return ErrorCode::NONE;
             }
             t = reinterpret_cast<T*>(new(noThrow)
                                          AlignedType<T>[static_cast<u64>(n)]);
-            return t == nullptr ? Error::OUT_OF_MEMORY : Error::NONE;
+            return t == nullptr ? ErrorCode::OUT_OF_MEMORY : ErrorCode::NONE;
         }
 
         check_return Error ensureCapacity() {
             return length < capacity
-                       ? Error::NONE
+                       ? ErrorCode::NONE
                        : reserve(capacity + Core::Math::max(4l, capacity / 4));
         }
 
@@ -213,7 +213,7 @@ namespace Core {
                 copy.unsafeAdd(Core::move(data[i]));
             }
             swap(copy);
-            return Error::NONE;
+            return ErrorCode::NONE;
         }
     };
 }

+ 11 - 11
include/core/data/ProbingHashMap.hpp

@@ -157,24 +157,24 @@ namespace Core {
                 CORE_RETURN_ERROR(copy.add(e.getKey(), e.value));
             }
             swap(copy);
-            return Error::NONE;
+            return ErrorCode::NONE;
         }
 
         check_return Error rehash(i64 minCapacity) {
             if(minCapacity <= keys.getLength()) {
-                return Error::NONE;
+                return ErrorCode::NONE;
             }
             ProbingHashMap<K, V> map;
             i64 shifts = Math::roundUpLog2(Core::Math::max(minCapacity, 8l));
             if(shifts >= 48) {
-                return Error::CAPACITY_REACHED;
+                return ErrorCode::CAPACITY_REACHED;
             }
             i64 l = 1l << shifts;
             CORE_RETURN_ERROR(map.keys.resize(l, emptyValue<K>()));
             map.values = reinterpret_cast<V*>(
                 new(noThrow) AlignedType<V>[static_cast<u64>(l)]);
             if(map.values == nullptr) {
-                return Error::OUT_OF_MEMORY;
+                return ErrorCode::OUT_OF_MEMORY;
             }
             for(i64 i = 0; i < keys.getLength(); i++) {
                 if(keys[i] != emptyValue<K>()) {
@@ -182,29 +182,29 @@ namespace Core {
                 }
             }
             swap(map);
-            return Error::NONE;
+            return ErrorCode::NONE;
         }
 
         template<typename... Args>
         check_return Error tryEmplace(V*& v, const K& key, Args&&... args) {
             if(key == emptyValue<K>()) {
-                return Error::INVALID_ARGUMENT;
+                return ErrorCode::INVALID_ARGUMENT;
             }
             i64 index = 0;
             CORE_RETURN_ERROR(searchSlot(index, key));
             if(keys[index] == key) {
-                return Error::EXISTING_KEY;
+                return ErrorCode::EXISTING_KEY;
             }
             keys[index] = key;
             v = new(values + index) V(Core::forward<Args>(args)...);
             entries++;
-            return Error::NONE;
+            return ErrorCode::NONE;
         }
 
         template<typename VA>
         check_return Error put(V*& v, const K& key, VA&& value) {
             if(key == emptyValue<K>()) {
-                return Error::INVALID_ARGUMENT;
+                return ErrorCode::INVALID_ARGUMENT;
             }
             i64 index = 0;
             CORE_RETURN_ERROR(searchSlot(index, key));
@@ -216,7 +216,7 @@ namespace Core {
             }
             keys[index] = key;
             v = reinterpret_cast<V*>(values + index);
-            return Error::NONE;
+            return ErrorCode::NONE;
         }
 
         template<typename VA>
@@ -294,7 +294,7 @@ namespace Core {
                     i64 hash = static_cast<i64>((baseHash + i) & end);
                     if(keys[hash] == emptyValue<K>() || keys[hash] == key) {
                         slot = hash;
-                        return Core::Error::NONE;
+                        return Core::ErrorCode::NONE;
                     }
                 }
                 rehashFactor *= 2;

+ 5 - 5
include/core/data/RingBuffer.hpp

@@ -51,12 +51,12 @@ namespace Core {
         template<typename... Args>
         check_return Error put(T*& t, Args&&... args) {
             if(getLength() >= N) {
-                return Error::CAPACITY_REACHED;
+                return ErrorCode::CAPACITY_REACHED;
             }
             t = new(data + writeIndex) T(Core::forward<Args>(args)...);
             writeIndex = (writeIndex + 1) % N;
             values++;
-            return Error::NONE;
+            return ErrorCode::NONE;
         }
 
         template<typename... Args>
@@ -92,12 +92,12 @@ namespace Core {
 
         check_return Error remove() {
             if(!canRemove()) {
-                return Error::INVALID_STATE;
+                return ErrorCode::INVALID_STATE;
             }
             values--;
             (*this)[0].~T();
             readIndex = (readIndex + 1) % N;
-            return Error::NONE;
+            return ErrorCode::NONE;
         }
 
         template<typename String>
@@ -130,4 +130,4 @@ namespace Core {
     };
 }
 
-#endif
+#endif

+ 2 - 2
include/core/data/Stack.hpp

@@ -23,7 +23,7 @@ namespace Core {
             check_return Error pop() {
                 i64 index = data.getLength();
                 if(index <= 0) {
-                    return Error::INVALID_STATE;
+                    return ErrorCode::INVALID_STATE;
                 }
                 return data.removeBySwap(index - 1);
             }
@@ -54,4 +54,4 @@ namespace Core {
     using ArrayStack = Internal::BaseStack<T, ArrayList<T, N>>;
 }
 
-#endif
+#endif

+ 2 - 2
include/core/math/Box.hpp

@@ -29,9 +29,9 @@ namespace Core {
             CORE_RETURN_ERROR(s.append(", "));
             CORE_RETURN_ERROR(s.append(max));
             CORE_RETURN_ERROR(s.append(")"));
-            return Error::NONE;
+            return ErrorCode::NONE;
         }
     };
 }
 
-#endif
+#endif

+ 1 - 1
include/core/math/BufferedValue.hpp

@@ -93,4 +93,4 @@ namespace Core {
     };
 }
 
-#endif
+#endif

+ 2 - 2
include/core/math/Frustum.hpp

@@ -33,9 +33,9 @@ namespace Core {
             CORE_RETURN_ERROR(s.append(", farClip = "));
             CORE_RETURN_ERROR(s.append(farClip));
             CORE_RETURN_ERROR(s.append(')'));
-            return Error::NONE;
+            return ErrorCode::NONE;
         }
     };
 }
 
-#endif
+#endif

+ 1 - 1
include/core/math/Math.hpp

@@ -72,4 +72,4 @@ namespace Core::Math {
     float squareRoot(float f);
 }
 
-#endif
+#endif

+ 2 - 2
include/core/math/Matrix.hpp

@@ -48,7 +48,7 @@ namespace Core {
             CORE_RETURN_ERROR(s.append(", "));
             CORE_RETURN_ERROR(s.append(data[3]));
             CORE_RETURN_ERROR(s.append("]"));
-            return Error::NONE;
+            return ErrorCode::NONE;
         }
 
     private:
@@ -56,4 +56,4 @@ namespace Core {
     };
 }
 
-#endif
+#endif

+ 2 - 2
include/core/math/MatrixStack.hpp

@@ -16,7 +16,7 @@ namespace Core {
 
         check_return Error pop() {
             if(stack.getLength() <= 1) {
-                return Error::INVALID_STATE;
+                return ErrorCode::INVALID_STATE;
             }
             return stack.removeLast();
         }
@@ -45,4 +45,4 @@ namespace Core {
     };
 }
 
-#endif
+#endif

+ 2 - 2
include/core/math/Plane.hpp

@@ -25,9 +25,9 @@ namespace Core {
             CORE_RETURN_ERROR(s.append(" z + "));
             CORE_RETURN_ERROR(s.append(d));
             CORE_RETURN_ERROR(s.append(')'));
-            return Error::NONE;
+            return ErrorCode::NONE;
         }
     };
 }
 
-#endif
+#endif

+ 2 - 2
include/core/math/Quaternion.hpp

@@ -29,9 +29,9 @@ namespace Core {
             CORE_RETURN_ERROR(s.append(" k + "));
             CORE_RETURN_ERROR(s.append(w));
             CORE_RETURN_ERROR(s.append(')'));
-            return Error::NONE;
+            return ErrorCode::NONE;
         }
     };
 }
 
-#endif
+#endif

+ 1 - 1
include/core/math/View.hpp

@@ -24,4 +24,4 @@ namespace Core {
     };
 }
 
-#endif
+#endif

+ 1 - 1
include/core/thread/Mutex.hpp

@@ -24,4 +24,4 @@ namespace Core {
     };
 }
 
-#endif
+#endif

+ 1 - 1
include/core/thread/Thread.hpp

@@ -26,4 +26,4 @@ namespace Core {
     };
 }
 
-#endif
+#endif

+ 3 - 10
include/core/utils/ArrayString.hpp

@@ -42,7 +42,7 @@ namespace Core {
             while(index < f.getLength()) {
                 CORE_RETURN_ERROR(s.append(f[index++]));
             }
-            return Error::NONE;
+            return ErrorCode::NONE;
         }
     }
 
@@ -50,14 +50,9 @@ namespace Core {
     CError copyFormat(String& result, String& s, Args&&... args) {
         if constexpr(sizeof...(args) > 0) {
             Error e = Internal::formatR(result, s, 0, forward<Args>(args)...);
-            if(e == Error::NONE) {
-                return result.copyFrom(s);
-            } else if(e == Error::CAPACITY_REACHED) {
-                (void)result.copyFrom(s);
-            }
-            return e;
+            return e | result.copyFrom(s);
         }
-        return Error::NONE;
+        return ErrorCode::NONE;
     }
 
     class Char32String;
@@ -91,7 +86,6 @@ namespace Core {
         CError append(const signed char* s);
         CError append(const unsigned char* s);
         CError append(bool b);
-        CError append(Error e);
 
         template<typename T>
         CError append(const T& t) {
@@ -155,7 +149,6 @@ namespace Core {
         CError append(const signed char* s);
         CError append(const unsigned char* s);
         CError append(bool b);
-        CError append(Error e);
 
         template<typename T>
         CError append(const T& t) {

+ 60 - 22
include/core/utils/Error.hpp

@@ -1,39 +1,77 @@
 #ifndef CORE_ERROR_HPP
 #define CORE_ERROR_HPP
 
+#include "core/utils/Check.hpp"
+
 namespace Core {
-    enum class Error {
-        NONE = 0,
-        NEGATIVE_ARGUMENT,
-        CAPACITY_REACHED,
-        BLOCKED_STDOUT,
-        OUT_OF_MEMORY,
-        INVALID_CHAR,
-        NOT_FOUND,
-        INVALID_STATE,
-        INVALID_INDEX,
-        INVALID_ARGUMENT,
-        TIME_NOT_AVAILABLE,
-        SLEEP_INTERRUPTED,
-        THREAD_ERROR,
-        MUTEX_ERROR,
-        EXISTING_KEY,
-        CANNOT_OPEN_FILE,
-        END_OF_FILE
+    struct Error {
+        using Code = unsigned int;
+        static_assert(sizeof(Code) >= 4, "error code too small");
+        Code code;
+
+        constexpr Error(Code c) : code(c) {
+        }
+
+        bool check() const {
+            return code != 0;
+        }
+
+        bool contains(Error e) const {
+            return code & e.code;
+        }
+
+        bool operator==(Error e) const {
+            return code == e.code;
+        }
+
+        bool operator!=(Error e) const {
+            return !(*this == e);
+        }
+
+        Error& operator|=(Error e) {
+            code |= e.code;
+            return *this;
+        }
+
+        Error operator|(Error e) const {
+            e |= *this;
+            return e;
+        }
     };
-    const char* getErrorName(Error e);
+
+    namespace ErrorCode {
+        static constexpr Error NONE = 0;
+        static constexpr Error NEGATIVE_ARGUMENT = 1 << 0;
+        static constexpr Error CAPACITY_REACHED = 1 << 1;
+        static constexpr Error BLOCKED_STDOUT = 1 << 2;
+        static constexpr Error OUT_OF_MEMORY = 1 << 3;
+        static constexpr Error INVALID_CHAR = 1 << 4;
+        static constexpr Error NOT_FOUND = 1 << 5;
+        static constexpr Error INVALID_STATE = 1 << 6;
+        static constexpr Error INVALID_INDEX = 1 << 7;
+        static constexpr Error INVALID_ARGUMENT = 1 << 8;
+        static constexpr Error TIME_NOT_AVAILABLE = 1 << 9;
+        static constexpr Error SLEEP_INTERRUPTED = 1 << 10;
+        static constexpr Error THREAD_ERROR = 1 << 11;
+        static constexpr Error MUTEX_ERROR = 1 << 12;
+        static constexpr Error EXISTING_KEY = 1 << 13;
+        static constexpr Error CANNOT_OPEN_FILE = 1 << 14;
+        static constexpr Error END_OF_FILE = 1 << 15;
+    }
+
+    CError toString(Error e, char* buffer, int size);
 
     inline bool checkError(Error& storage, Error e) {
-        return (storage = e) != Error::NONE;
+        return (storage = e).check();
     }
 
 #define CORE_RETURN_ERROR(checked)                                             \
     {                                                                          \
-        Core::Error error = Core::Error::NONE;                                 \
+        Core::Error error = Core::ErrorCode::NONE;                             \
         if(checkError(error, checked)) [[unlikely]] {                          \
             return error;                                                      \
         }                                                                      \
     }
 }
 
-#endif
+#endif

+ 2 - 1
include/core/utils/HashCode.hpp

@@ -3,6 +3,7 @@
 
 #include <limits.h>
 
+#include "core/utils/Meta.hpp"
 #include "core/utils/Types.hpp"
 
 namespace Core {
@@ -91,4 +92,4 @@ namespace Core {
     }
 }
 
-#endif
+#endif

+ 2 - 2
include/core/utils/Logger.hpp

@@ -16,7 +16,7 @@ namespace Core::Logger {
     const char* getFileName(const char* path);
 
     inline bool filterError(Error e) {
-        return e != Error::NONE && e != Error::CAPACITY_REACHED;
+        return e != ErrorCode::NONE && e != ErrorCode::CAPACITY_REACHED;
     }
 
     // aborts on critical logging failure
@@ -84,4 +84,4 @@ namespace Core::Logger {
 #define CORE_LOG_DEBUG(format, ...)
 #endif
 
-#endif
+#endif

+ 1 - 1
include/core/utils/Meta.hpp

@@ -84,4 +84,4 @@ namespace Core {
     }
 }
 
-#endif
+#endif

+ 26 - 33
src/ArrayString.cpp

@@ -5,6 +5,7 @@
 using CharString = Core::CharString;
 using Char32String = Core::Char32String;
 using Error = Core::Error;
+namespace ErrorCode = Core::ErrorCode;
 
 template<typename T>
 constexpr int stringLength(const T* c) {
@@ -23,35 +24,35 @@ static c32 read(const char*& s) {
 static Error readUnicode(c32& u, const char*& s) {
     u = read(s);
     if((u & 0x80) == 0) {
-        return Error::NONE;
+        return ErrorCode::NONE;
     }
     if((u & 0xE0) == 0xC0) {
         c32 u2 = read(s);
         if(u2 == 0) {
-            return Error::INVALID_CHAR;
+            return ErrorCode::INVALID_CHAR;
         }
         u = ((u & 0x1F) << 6) | (u2 & 0x3F);
-        return Error::NONE;
+        return ErrorCode::NONE;
     } else if((u & 0xF0) == 0xE0) {
         c32 u2 = read(s);
         c32 u3 = read(s);
         if(u2 == 0 || u3 == 0) {
-            return Error::INVALID_CHAR;
+            return ErrorCode::INVALID_CHAR;
         }
         u = ((u & 0xF) << 12) | ((u2 & 0x3F) << 6) | (u3 & 0x3F);
-        return Error::NONE;
+        return ErrorCode::NONE;
     } else if((u & 0xF8) == 0xF0) {
         c32 u2 = read(s);
         c32 u3 = read(s);
         c32 u4 = read(s);
         if(u2 == 0 || u3 == 0 || u4 == 0) {
-            return Error::INVALID_CHAR;
+            return ErrorCode::INVALID_CHAR;
         }
         u = ((u & 0x07) << 18) | ((u2 & 0x3F) << 12) | ((u3 & 0x3F) << 6) |
             (u4 & 0x3F);
-        return Error::NONE;
+        return ErrorCode::NONE;
     }
-    return Error::INVALID_CHAR;
+    return ErrorCode::INVALID_CHAR;
 }
 
 template<unsigned int L>
@@ -136,12 +137,12 @@ int CharString::getCapacity() const {
 
 Error CharString::append(char c) {
     if(length >= capacity - 1) {
-        return Error::CAPACITY_REACHED;
+        return ErrorCode::CAPACITY_REACHED;
     }
     data[length++] = c;
     data[length] = '\0';
     addToHash(static_cast<c32>(c));
-    return Error::NONE;
+    return ErrorCode::NONE;
 }
 
 Error CharString::append(signed char c) {
@@ -167,7 +168,7 @@ Error CharString::append(const char* s) {
     for(int i = stringLength(s); i > 0; i--) {
         CORE_RETURN_ERROR(append(*(s++)));
     }
-    return Error::NONE;
+    return ErrorCode::NONE;
 }
 
 Error CharString::append(const c32* s) {
@@ -175,7 +176,7 @@ Error CharString::append(const c32* s) {
     for(int i = stringLength(s); i > 0; i--) {
         CORE_RETURN_ERROR(append(*(s++)));
     }
-    return Error::NONE;
+    return ErrorCode::NONE;
 }
 
 Error CharString::append(const signed char* s) {
@@ -190,16 +191,12 @@ Error CharString::append(bool b) {
     return b ? append("true") : append("false");
 }
 
-Error CharString::append(Error e) {
-    return append(getErrorName(e));
-}
-
 Error CharString::toString(CharString& s) const {
     int l = length; // length changes if &s == this
     for(int i = 0; i < l; i++) {
         CORE_RETURN_ERROR(s.append(data[i]));
     }
-    return Error::NONE;
+    return ErrorCode::NONE;
 }
 
 Error CharString::toString(Char32String& s) const {
@@ -220,13 +217,13 @@ Error CharString::print() const {
     for(int i = 0; i < length; i++) {
         CORE_RETURN_ERROR(Core::putChar(data[i]));
     }
-    return Error::NONE;
+    return ErrorCode::NONE;
 }
 
 Error CharString::printLine() const {
     CORE_RETURN_ERROR(print());
     CORE_RETURN_ERROR(Core::putChar('\n'));
-    return Error::NONE;
+    return ErrorCode::NONE;
 }
 
 bool CharString::startsWidth(const CharString& other, int from) const {
@@ -274,7 +271,7 @@ Error CharString::substring(CharString& s, int from, int to) const {
     for(int i = from; i <= to; i++) {
         CORE_RETURN_ERROR(s.append(data[i]));
     }
-    return Error::NONE;
+    return ErrorCode::NONE;
 }
 
 Error CharString::substring(CharString& s, int from) const {
@@ -383,12 +380,12 @@ Error Char32String::append(wchar_t c) {
 
 Error Char32String::append(c32 c) {
     if(length >= capacity - 1) {
-        return Error::CAPACITY_REACHED;
+        return ErrorCode::CAPACITY_REACHED;
     }
     data[length++] = c;
     data[length] = '\0';
     addToHash(static_cast<c32>(c));
-    return Error::NONE;
+    return ErrorCode::NONE;
 }
 
 Error Char32String::append(const char* s) {
@@ -396,7 +393,7 @@ Error Char32String::append(const char* s) {
         c32 u = 0;
         CORE_RETURN_ERROR(readUnicode(u, s));
         if(u == 0) {
-            return Error::NONE;
+            return ErrorCode::NONE;
         }
         CORE_RETURN_ERROR(append(u));
     }
@@ -407,7 +404,7 @@ Error Char32String::append(const c32* s) {
     for(int i = stringLength(s); i > 0; i--) {
         CORE_RETURN_ERROR(append(*(s++)));
     }
-    return Error::NONE;
+    return ErrorCode::NONE;
 }
 
 Error Char32String::append(const signed char* s) {
@@ -422,16 +419,12 @@ Error Char32String::append(bool b) {
     return b ? append("true") : append("false");
 }
 
-Error Char32String::append(Error e) {
-    return append(getErrorName(e));
-}
-
 Error Char32String::toString(CharString& s) const {
     int l = length; // length changes if &s == this
     for(int i = 0; i < l; i++) {
         CORE_RETURN_ERROR(s.append(data[i]));
     }
-    return Error::NONE;
+    return ErrorCode::NONE;
 }
 
 Error Char32String::toString(Char32String& s) const {
@@ -439,7 +432,7 @@ Error Char32String::toString(Char32String& s) const {
     for(int i = 0; i < l; i++) {
         CORE_RETURN_ERROR(s.append(data[i]));
     }
-    return Error::NONE;
+    return ErrorCode::NONE;
 }
 
 void Char32String::clear() {
@@ -471,13 +464,13 @@ Error Char32String::print() const {
             CORE_RETURN_ERROR(printChar(c, 0, 0x3F, 0x80));
         }
     }
-    return Error::NONE;
+    return ErrorCode::NONE;
 }
 
 Error Char32String::printLine() const {
     CORE_RETURN_ERROR(print());
     CORE_RETURN_ERROR(Core::putChar('\n'));
-    return Error::NONE;
+    return ErrorCode::NONE;
 }
 
 bool Char32String::startsWidth(const Char32String& other, int from) const {
@@ -525,7 +518,7 @@ Error Char32String::substring(Char32String& s, int from, int to) const {
     for(int i = from; i <= to; i++) {
         CORE_RETURN_ERROR(s.append(data[i]));
     }
-    return Error::NONE;
+    return ErrorCode::NONE;
 }
 
 Error Char32String::substring(Char32String& s, int from) const {

+ 4 - 4
src/BitArray.cpp

@@ -57,7 +57,7 @@ check_return Core::Error Core::BitArray::copyFrom(const BitArray& other) {
     for(u64 i = 0; i < length; i++) {
         set(i, other.get(i));
     }
-    return Error::NONE;
+    return ErrorCode::NONE;
 }
 
 Core::BitArray::BitArray(BitArray&& other) : BitArray() {
@@ -136,12 +136,12 @@ void Core::BitArray::fill(u64 value) {
 
 check_return Core::Error Core::BitArray::resize(u64 newLength, u64 newBits) {
     if(newLength == 0 || newBits == 0 || newBits > 64) {
-        return Error::INVALID_ARGUMENT;
+        return ErrorCode::INVALID_ARGUMENT;
     }
     u64 arrayLength = getArrayLength(newLength, newBits);
     u64* newData = new(noThrow) u64[arrayLength];
     if(newData == nullptr) {
-        return Error::OUT_OF_MEMORY;
+        return ErrorCode::OUT_OF_MEMORY;
     }
     Core::memorySet(newData, 0, static_cast<i64>(arrayLength) * CORE_SIZE(int));
 
@@ -155,7 +155,7 @@ check_return Core::Error Core::BitArray::resize(u64 newLength, u64 newBits) {
     delete[] data;
     data = newData;
     lengthBits = newLength | (newBits << LENGTH_BITS);
-    return Error::NONE;
+    return ErrorCode::NONE;
 }
 
 void Core::BitArray::swap(BitArray& other) {

+ 2 - 2
src/Buffer.cpp

@@ -34,7 +34,7 @@ Core::Error Core::Buffer::add(const void* data, int size) {
     }
     memoryCopy(buffer + length, data, size);
     length += size;
-    return Error::NONE;
+    return ErrorCode::NONE;
 }
 
 int Core::Buffer::getLength() const {
@@ -57,4 +57,4 @@ void Core::Buffer::swap(Buffer& other) {
 
 void Core::Buffer::clear() {
     length = 0;
-}
+}

+ 7 - 7
src/Clock.cpp

@@ -14,7 +14,7 @@ Core::Error Core::Clock::update(Clock::Nanos& n) {
     if(last == 0) {
         last = current;
         n = 0;
-        return Error::NONE;
+        return ErrorCode::NONE;
     }
     index = (index + 1) & (time.getLength() - 1);
     sum -= time[index];
@@ -22,7 +22,7 @@ Core::Error Core::Clock::update(Clock::Nanos& n) {
     sum += time[index];
     last = current;
     n = time[index];
-    return Error::NONE;
+    return ErrorCode::NONE;
 }
 
 float Core::Clock::getUpdatesPerSecond() const {
@@ -32,17 +32,17 @@ float Core::Clock::getUpdatesPerSecond() const {
 Core::Error Core::Clock::getNanos(Clock::Nanos& n) {
     timespec ts;
     if(timespec_get(&ts, TIME_UTC) == 0 || CORE_TIME_GET_FAIL) {
-        return Error::TIME_NOT_AVAILABLE;
+        return ErrorCode::TIME_NOT_AVAILABLE;
     }
     n = static_cast<Clock::Nanos>(ts.tv_sec) * 1'000'000'000L +
         static_cast<Clock::Nanos>(ts.tv_nsec);
-    return Error::NONE;
+    return ErrorCode::NONE;
 }
 
 Core::Error Core::Clock::wait(Nanos nanos) {
     timespec t;
     t.tv_nsec = nanos % 1'000'000'000;
     t.tv_sec = nanos / 1'000'000'000;
-    return thrd_sleep(&t, nullptr) != 0 ? Error::SLEEP_INTERRUPTED
-                                        : Error::NONE;
-}
+    return thrd_sleep(&t, nullptr) != 0 ? ErrorCode::SLEEP_INTERRUPTED
+                                        : ErrorCode::NONE;
+}

+ 17 - 24
src/Error.cpp

@@ -1,27 +1,20 @@
 #include "core/utils/Error.hpp"
 
-#define CASE_RETURN_ENUM_NAME(type)                                            \
-    case Error::type: return #type
-
-const char* Core::getErrorName(Error e) {
-    switch(e) {
-        CASE_RETURN_ENUM_NAME(NONE);
-        CASE_RETURN_ENUM_NAME(NEGATIVE_ARGUMENT);
-        CASE_RETURN_ENUM_NAME(CAPACITY_REACHED);
-        CASE_RETURN_ENUM_NAME(BLOCKED_STDOUT);
-        CASE_RETURN_ENUM_NAME(OUT_OF_MEMORY);
-        CASE_RETURN_ENUM_NAME(INVALID_CHAR);
-        CASE_RETURN_ENUM_NAME(NOT_FOUND);
-        CASE_RETURN_ENUM_NAME(INVALID_STATE);
-        CASE_RETURN_ENUM_NAME(INVALID_INDEX);
-        CASE_RETURN_ENUM_NAME(INVALID_ARGUMENT);
-        CASE_RETURN_ENUM_NAME(TIME_NOT_AVAILABLE);
-        CASE_RETURN_ENUM_NAME(SLEEP_INTERRUPTED);
-        CASE_RETURN_ENUM_NAME(THREAD_ERROR);
-        CASE_RETURN_ENUM_NAME(MUTEX_ERROR);
-        CASE_RETURN_ENUM_NAME(EXISTING_KEY);
-        CASE_RETURN_ENUM_NAME(CANNOT_OPEN_FILE);
-        CASE_RETURN_ENUM_NAME(END_OF_FILE);
+CError Core::toString(Error e, char* buffer, int size) {
+    int index = 0;
+    Error::Code c = e.code;
+    size--;
+    while(true) {
+        if(index >= size) {
+            buffer[index] = '\0';
+            return ErrorCode::CAPACITY_REACHED;
+        }
+        buffer[index++] = (c & 1) ? '1' : '0';
+        c >>= 1;
+        if(c == 0) {
+            break;
+        }
     }
-    return "?";
-}
+    buffer[index] = '\0';
+    return ErrorCode::NONE;
+}

+ 1 - 1
src/ErrorSimulator.cpp

@@ -14,4 +14,4 @@ bool Core::Fail::freeAndReturn(void* p) {
     return true;
 }
 
-#endif
+#endif

+ 1 - 1
src/ErrorSimulator.hpp

@@ -20,4 +20,4 @@ namespace Core::Fail {
 #define CORE_TIME_GET_FAIL false
 #endif
 
-#endif
+#endif

+ 9 - 9
src/FileReader.cpp

@@ -33,40 +33,40 @@ const Core::Path& Core::FileReader::getPath() const {
 
 Core::Error Core::FileReader::open(const Path& p) {
     if(file != nullptr) {
-        return Error::INVALID_STATE;
+        return ErrorCode::INVALID_STATE;
     }
     path = p;
     file = fopen(path, "rb");
-    return file != nullptr ? Error::NONE : Error::CANNOT_OPEN_FILE;
+    return file != nullptr ? ErrorCode::NONE : ErrorCode::CANNOT_OPEN_FILE;
 }
 
 Core::Error Core::FileReader::open(const char* p) {
     if(file != nullptr) {
-        return Error::INVALID_STATE;
+        return ErrorCode::INVALID_STATE;
     }
     CORE_RETURN_ERROR(path.append(p));
     file = fopen(path, "rb");
-    return file != nullptr ? Error::NONE : Error::CANNOT_OPEN_FILE;
+    return file != nullptr ? ErrorCode::NONE : ErrorCode::CANNOT_OPEN_FILE;
 }
 
 Core::Error Core::FileReader::readChar(int& c) {
     if(file == nullptr) {
-        return Error::INVALID_STATE;
+        return ErrorCode::INVALID_STATE;
     }
     c = fgetc(static_cast<FILE*>(file));
-    return c == EOF ? Error::END_OF_FILE : Error::NONE;
+    return c == EOF ? ErrorCode::END_OF_FILE : ErrorCode::NONE;
 }
 
 Core::Error Core::FileReader::readChars(char* buffer, int bufferSize) {
     if(file == nullptr) {
-        return Error::INVALID_STATE;
+        return ErrorCode::INVALID_STATE;
     } else if(bufferSize <= 0) {
-        return Error::INVALID_ARGUMENT;
+        return ErrorCode::INVALID_ARGUMENT;
     }
     size_t size = static_cast<size_t>(bufferSize - 1);
     size_t readBytes = fread(buffer, 1, size, static_cast<FILE*>(file));
     buffer[readBytes] = '\0';
-    return readBytes != size ? Error::END_OF_FILE : Error::NONE;
+    return readBytes != size ? ErrorCode::END_OF_FILE : ErrorCode::NONE;
 }
 
 void Core::FileReader::swap(FileReader& other) {

+ 1 - 1
src/Logger.cpp

@@ -11,4 +11,4 @@ const char* Core::Logger::getFileName(const char* path) {
         end--;
     }
     return path + end;
-}
+}

+ 1 - 1
src/Math.cpp

@@ -25,4 +25,4 @@ void Core::Math::sinCos(float a, float& s, float& c) {
 
 float Core::Math::squareRoot(float f) {
     return sqrtf(f);
-}
+}

+ 8 - 7
src/Mutex.cpp

@@ -27,19 +27,20 @@ Core::Mutex::~Mutex() {
 
 check_return Core::Error Core::Mutex::init() {
     if(doesExist(mutex.as<mtx_t>())) {
-        return Error::INVALID_STATE;
+        return ErrorCode::INVALID_STATE;
     }
     return mtx_init(mutex.as<mtx_t>(), mtx_plain) != thrd_success
-               ? Error::MUTEX_ERROR
-               : Error::NONE;
+               ? ErrorCode::MUTEX_ERROR
+               : ErrorCode::NONE;
 }
 
 check_return Core::Error Core::Mutex::lock() {
-    return mtx_lock(mutex.as<mtx_t>()) != thrd_success ? Error::MUTEX_ERROR
-                                                       : Error::NONE;
+    return mtx_lock(mutex.as<mtx_t>()) != thrd_success ? ErrorCode::MUTEX_ERROR
+                                                       : ErrorCode::NONE;
 }
 
 check_return Core::Error Core::Mutex::unlock() {
-    return mtx_unlock(mutex.as<mtx_t>()) != thrd_success ? Error::MUTEX_ERROR
-                                                         : Error::NONE;
+    return mtx_unlock(mutex.as<mtx_t>()) != thrd_success
+               ? ErrorCode::MUTEX_ERROR
+               : ErrorCode::NONE;
 }

+ 1 - 1
src/Plane.cpp

@@ -9,4 +9,4 @@ Core::Plane::Plane(const Vector3& a, const Vector3& b, const Vector3& c)
 
 float Core::Plane::getSignedDistance(const Vector3& v) const {
     return abc.dot(v) + d;
-}
+}

+ 1 - 1
src/Quaternion.cpp

@@ -40,4 +40,4 @@ Core::Vector3 Core::Quaternion::operator*(const Vector3& v) const {
     Vector3 qv = v * w + xyz.cross(v);
     Vector3 qvq = xyz * xyz.dot(v) + qv * w - qv.cross(xyz);
     return qvq;
-}
+}

+ 4 - 4
src/Thread.cpp

@@ -42,14 +42,14 @@ Core::Thread& Core::Thread::operator=(Thread&& other) {
 
 check_return Core::Error Core::Thread::start(Function f, void* p) {
     return thrd_create(thread.as<thrd_t>(), f, p) != thrd_success
-               ? Error::THREAD_ERROR
-               : Error::NONE;
+               ? ErrorCode::THREAD_ERROR
+               : ErrorCode::NONE;
 }
 
 check_return Core::Error Core::Thread::join(int* returnValue) {
     int e = thrd_join(*thread.as<thrd_t>(), returnValue);
     reset(thread.as<thrd_t>());
-    return e != thrd_success ? Error::THREAD_ERROR : Error::NONE;
+    return e != thrd_success ? ErrorCode::THREAD_ERROR : ErrorCode::NONE;
 }
 
 void Core::Thread::swap(Thread& other) {
@@ -57,4 +57,4 @@ void Core::Thread::swap(Thread& other) {
     memoryCopy(&tmp, thread.as<thrd_t>(), sizeof(thrd_t));
     memoryCopy(thread.as<thrd_t>(), other.thread.as<thrd_t>(), sizeof(thrd_t));
     memoryCopy(other.thread.as<thrd_t>(), &tmp, sizeof(thrd_t));
-}
+}

+ 8 - 8
src/Utility.cpp

@@ -30,12 +30,12 @@ void Core::setExitHandler(ExitHandler eh, void* data) {
 #define CORE_TO_STRING(type, cast, format)                                     \
     check_return Core::Error Core::toString(type t, char* buffer, int size) {  \
         if(size < 0) {                                                         \
-            return Error::NEGATIVE_ARGUMENT;                                   \
+            return ErrorCode::NEGATIVE_ARGUMENT;                               \
         }                                                                      \
         return snprintf(buffer, static_cast<unsigned int>(size), format,       \
                         static_cast<cast>(t)) >= size                          \
-                   ? Error::CAPACITY_REACHED                                   \
-                   : Error::NONE;                                              \
+                   ? ErrorCode::CAPACITY_REACHED                               \
+                   : ErrorCode::NONE;                                          \
     }
 
 CORE_TO_STRING(signed short, signed short, "%hd")
@@ -51,7 +51,7 @@ CORE_TO_STRING(double, double, "%.2lf")
 CORE_TO_STRING(long double, long double, "%.2Lf")
 
 Core::Error Core::putChar(int c) {
-    return putchar(c) == EOF ? Error::BLOCKED_STDOUT : Error::NONE;
+    return putchar(c) == EOF ? ErrorCode::BLOCKED_STDOUT : ErrorCode::NONE;
 }
 
 void Core::memorySet(void* p, int c, i64 n) {
@@ -76,16 +76,16 @@ Core::Error Core::reallocate(char*& p, i64 n) {
     if(n <= 0) {
         free(p);
         p = nullptr;
-        return Error::NONE;
+        return ErrorCode::NONE;
     }
     char* newP = static_cast<char*>(realloc(p, static_cast<u64>(n)));
     if(newP == nullptr || CORE_REALLOC_FAIL(newP)) {
-        return Error::OUT_OF_MEMORY;
+        return ErrorCode::OUT_OF_MEMORY;
     }
     p = newP;
-    return Error::NONE;
+    return ErrorCode::NONE;
 }
 
 void Core::free(void* p) {
     ::free(p);
-}
+}

+ 1 - 1
src/Vector.cpp

@@ -18,4 +18,4 @@ Core::Vector3 Core::Vector3::cross(const Vector3& other) const {
     return Vector3(values[1] * other.values[2] - values[2] * other.values[1],
                    values[2] * other.values[0] - values[0] * other.values[2],
                    values[0] * other.values[1] - values[1] * other.values[0]);
-}
+}

+ 1 - 2
test/Test.cpp

@@ -1,7 +1,6 @@
 #include "Test.hpp"
 
 namespace Internal = Core::Test::Internal;
-namespace Logger = Core::Logger;
 
 Core::HashMap<Internal::FileName, Internal::Result> Internal::results;
 
@@ -25,4 +24,4 @@ void Core::Test::finalize() {
                     e.value.successTests, e.value.tests);
     }
     Internal::results.clear();
-}
+}

+ 4 - 4
test/Test.hpp

@@ -20,7 +20,7 @@ namespace Core::Test {
         bool check(const char* file, int line, const T& wanted, const T& actual,
                    bool c) {
             file = Logger::getFileName(file);
-            Error e = Error::NONE;
+            Error e = ErrorCode::NONE;
             FileName fileName;
             if(checkError(e, fileName.append(file))) {
                 warn(file, line, e);
@@ -52,7 +52,7 @@ namespace Core::Test {
         template<typename A, typename B>
         bool checkString(const char* file, int line, const A& wanted,
                          const B& actual) {
-            Error e = Error::NONE;
+            Error e = ErrorCode::NONE;
             String32<2048> a;
             if(checkError(e, a.append(wanted))) {
                 warn(file, line, e);
@@ -91,7 +91,7 @@ namespace Core::Test {
     Core::Test::Internal::checkString(__FILE__, __LINE__, wanted, actual)
 #define CORE_TEST_FALSE(actual) CORE_TEST_EQUAL(false, actual)
 #define CORE_TEST_TRUE(actual) CORE_TEST_EQUAL(true, actual)
-#define CORE_TEST_ERROR(actual) CORE_TEST_EQUAL(Core::Error::NONE, actual)
+#define CORE_TEST_ERROR(actual) CORE_TEST_EQUAL(Core::ErrorCode::NONE, actual)
 #define CORE_TEST_NULL(actual) CORE_TEST_EQUAL(true, actual == nullptr)
 // double check to make the null check clear for the compiler
 #define CORE_TEST_NOT_NULL(actual)                                             \
@@ -102,4 +102,4 @@ namespace Core::Test {
     Core::Test::Internal::checkVector(__FILE__, __LINE__, wanted, actual,      \
                                       0.0001f)
 
-#endif
+#endif

+ 5 - 5
test/modules/ArrayListTests.cpp

@@ -45,7 +45,7 @@ static void testOverflow(bool light) {
     }
     int limit = light ? 1000 : 100000;
     for(int i = 0; i < limit; i++) {
-        CORE_TEST_EQUAL(Core::Error::CAPACITY_REACHED, list.add(i));
+        CORE_TEST_EQUAL(Core::ErrorCode::CAPACITY_REACHED, list.add(i));
     }
     for(int i = 0; i < list.getLength(); i++) {
         CORE_TEST_EQUAL(i, list[i]);
@@ -136,9 +136,9 @@ static void testRemove() {
     CORE_TEST_EQUAL(2, list[0]);
     CORE_TEST_EQUAL(3, list[1]);
     CORE_TEST_EQUAL(2, list.getLength());
-    CORE_TEST_EQUAL(Core::Error::INVALID_INDEX, list.removeBySwap(4));
-    CORE_TEST_EQUAL(Core::Error::INVALID_INDEX, list.removeBySwap(-1));
-    CORE_TEST_EQUAL(Core::Error::INVALID_INDEX, list.removeBySwap(-5));
+    CORE_TEST_EQUAL(Core::ErrorCode::INVALID_INDEX, list.removeBySwap(4));
+    CORE_TEST_EQUAL(Core::ErrorCode::INVALID_INDEX, list.removeBySwap(-1));
+    CORE_TEST_EQUAL(Core::ErrorCode::INVALID_INDEX, list.removeBySwap(-5));
     CORE_TEST_EQUAL(2, list[0]);
     CORE_TEST_EQUAL(3, list[1]);
     CORE_TEST_EQUAL(2, list.getLength());
@@ -177,4 +177,4 @@ void Core::testArrayList(bool light) {
     testToString3();
     testRemove();
     testForRange();
-}
+}

+ 14 - 14
test/modules/ArrayStringTests.cpp

@@ -53,7 +53,7 @@ static void testStringAppend8() {
 static void testStringAppendOverflow8() {
     Core::String8<6> s;
     CORE_TEST_ERROR(s.append("te"));
-    CORE_TEST_EQUAL(Core::Error::CAPACITY_REACHED, s.append("23334444"));
+    CORE_TEST_EQUAL(Core::ErrorCode::CAPACITY_REACHED, s.append("23334444"));
     CORE_TEST_TRUE(build("te23334444") != s);
 }
 
@@ -194,7 +194,7 @@ static void testBool8() {
 
 static void testIntOverflow8() {
     Core::String8<4> s;
-    CORE_TEST_EQUAL(Core::Error::CAPACITY_REACHED, s.append(123456));
+    CORE_TEST_EQUAL(Core::ErrorCode::CAPACITY_REACHED, s.append(123456));
 
     String8 o;
     for(int i = 0; i < s.getCapacity(); i++) {
@@ -469,8 +469,8 @@ static void testAppendUnsignedChar8() {
 
 static void testAppendError8() {
     String8 s;
-    CORE_TEST_ERROR(s.append(Core::Error::NONE));
-    CORE_TEST_TRUE(s == "NONE");
+    CORE_TEST_ERROR(s.append(Core::ErrorCode::NONE));
+    CORE_TEST_STRING("0", s);
 }
 
 static void testPrint8() {
@@ -535,7 +535,7 @@ static void testStringAppend32() {
 static void testStringAppendOverflow32() {
     Core::String32<6> s;
     CORE_TEST_ERROR(s.append(U"te"));
-    CORE_TEST_EQUAL(Core::Error::CAPACITY_REACHED, s.append(U"23334444"));
+    CORE_TEST_EQUAL(Core::ErrorCode::CAPACITY_REACHED, s.append(U"23334444"));
     CORE_TEST_TRUE(build(U"te23334444") != s);
 }
 
@@ -676,7 +676,7 @@ static void testBool32() {
 
 static void testIntOverflow32() {
     Core::String32<4> s;
-    CORE_TEST_EQUAL(Core::Error::CAPACITY_REACHED, s.append(123456));
+    CORE_TEST_EQUAL(Core::ErrorCode::CAPACITY_REACHED, s.append(123456));
 
     String32 o;
     for(int i = 0; i < s.getCapacity(); i++) {
@@ -962,8 +962,8 @@ static void testAppendUnsignedChar32() {
 
 static void testAppendError32() {
     String32 s;
-    CORE_TEST_ERROR(s.append(Core::Error::NONE));
-    CORE_TEST_TRUE(s == U"NONE");
+    CORE_TEST_ERROR(s.append(Core::ErrorCode::NONE));
+    CORE_TEST_STRING(U"0", s);
 }
 
 static void testPrint32() {
@@ -984,12 +984,12 @@ static void testVariousUnicode32() {
     const unsigned char buffer5[] = {0xF0, 1, 2, 3, 0};
     const unsigned char buffer6[] = {0xFF, 0};
     String32 s;
-    CORE_TEST_EQUAL(Core::Error::INVALID_CHAR, s.append(buffer));
-    CORE_TEST_EQUAL(Core::Error::INVALID_CHAR, s.append(buffer2));
-    CORE_TEST_EQUAL(Core::Error::NONE, s.append(buffer3));
-    CORE_TEST_EQUAL(Core::Error::INVALID_CHAR, s.append(buffer4));
-    CORE_TEST_EQUAL(Core::Error::NONE, s.append(buffer5));
-    CORE_TEST_EQUAL(Core::Error::INVALID_CHAR, s.append(buffer6));
+    CORE_TEST_EQUAL(Core::ErrorCode::INVALID_CHAR, s.append(buffer));
+    CORE_TEST_EQUAL(Core::ErrorCode::INVALID_CHAR, s.append(buffer2));
+    CORE_TEST_EQUAL(Core::ErrorCode::NONE, s.append(buffer3));
+    CORE_TEST_EQUAL(Core::ErrorCode::INVALID_CHAR, s.append(buffer4));
+    CORE_TEST_EQUAL(Core::ErrorCode::NONE, s.append(buffer5));
+    CORE_TEST_EQUAL(Core::ErrorCode::INVALID_CHAR, s.append(buffer6));
 }
 
 static void testKeepHash32() {

+ 1 - 1
test/modules/ArrayTests.cpp

@@ -46,4 +46,4 @@ void Core::testArray() {
     testToString2();
     testReadConst();
     testRangeFor();
-}
+}

+ 8 - 8
test/modules/BitArrayTests.cpp

@@ -136,25 +136,25 @@ static void testMoveAssignment() {
 
 static void testInvalidArgument() {
     Core::BitArray bits;
-    CORE_TEST_EQUAL(Core::Error::INVALID_ARGUMENT, bits.resize(0, 5));
-    CORE_TEST_EQUAL(Core::Error::INVALID_ARGUMENT, bits.resize(5, 0));
-    CORE_TEST_EQUAL(Core::Error::INVALID_ARGUMENT, bits.resize(0, 0));
-    CORE_TEST_EQUAL(Core::Error::INVALID_ARGUMENT, bits.resize(1, 65));
-    CORE_TEST_EQUAL(Core::Error::INVALID_ARGUMENT, bits.resize(5, 68));
+    CORE_TEST_EQUAL(Core::ErrorCode::INVALID_ARGUMENT, bits.resize(0, 5));
+    CORE_TEST_EQUAL(Core::ErrorCode::INVALID_ARGUMENT, bits.resize(5, 0));
+    CORE_TEST_EQUAL(Core::ErrorCode::INVALID_ARGUMENT, bits.resize(0, 0));
+    CORE_TEST_EQUAL(Core::ErrorCode::INVALID_ARGUMENT, bits.resize(1, 65));
+    CORE_TEST_EQUAL(Core::ErrorCode::INVALID_ARGUMENT, bits.resize(5, 68));
 }
 
 static void testOutOfMemory() {
 #ifdef ERROR_SIMULATOR
     Core::BitArray bits;
     Core::Fail::leftAllocations = 0;
-    CORE_TEST_EQUAL(Core::Error::OUT_OF_MEMORY, bits.resize(8, 4));
+    CORE_TEST_EQUAL(Core::ErrorCode::OUT_OF_MEMORY, bits.resize(8, 4));
     Core::Fail::leftAllocations = -1;
 #endif
 }
 
 static void testOutOfMemory2() {
     Core::BitArray bits;
-    CORE_TEST_EQUAL(Core::Error::OUT_OF_MEMORY,
+    CORE_TEST_EQUAL(Core::ErrorCode::OUT_OF_MEMORY,
                     bits.resize(0x01FF'FFFF'FFFF'FFFF, 64));
 }
 
@@ -175,4 +175,4 @@ void Core::testBitArray(bool outOfMemoryTest) {
         testOutOfMemory();
     }
     testOutOfMemory2();
-}
+}

+ 1 - 1
test/modules/BoxTests.cpp

@@ -57,4 +57,4 @@ void Core::testBox() {
     testCollidesWith();
     testExpand();
     testGrow();
-}
+}

+ 1 - 1
test/modules/BufferTests.cpp

@@ -66,4 +66,4 @@ void Core::testBuffer(bool light) {
     testCopy();
     testMoveConstruct();
     testMove();
-}
+}

+ 1 - 1
test/modules/BufferedValueTests.cpp

@@ -92,4 +92,4 @@ void Core::testBufferedValue() {
     testUpdate();
     testCalculate();
     testVector2();
-}
+}

+ 3 - 2
test/modules/ClockTests.cpp

@@ -41,7 +41,8 @@ static void testFail() {
 #ifdef ERROR_SIMULATOR
     Core::Clock::Nanos n = 0;
     Core::Fail::timeGet = true;
-    CORE_TEST_EQUAL(Core::Error::TIME_NOT_AVAILABLE, Core::Clock::getNanos(n));
+    CORE_TEST_EQUAL(Core::ErrorCode::TIME_NOT_AVAILABLE,
+                    Core::Clock::getNanos(n));
     Core::Fail::timeGet = false;
 #endif
 }
@@ -52,4 +53,4 @@ void Core::testClock(bool light) {
     testWait(light ? 5'000'000 : 50'000'000);
     testWait(light ? 50'000'000 : 1'300'000'000);
     testFail();
-}
+}

+ 1 - 1
test/modules/ColorTests.cpp

@@ -60,4 +60,4 @@ void Core::testColor() {
     testColor4<Core::Color4>();
     testColor4<const Core::Color4>();
     testColor4Empty();
-}
+}

+ 4 - 4
test/modules/ComponentsTests.cpp

@@ -145,9 +145,9 @@ static void testRemove() {
     CORE_TEST_ERROR(c.add(5, 20));
     CORE_TEST_ERROR(c.add(10, 30));
 
-    CORE_TEST_EQUAL(Core::Error::NOT_FOUND, c.remove(20));
+    CORE_TEST_EQUAL(Core::ErrorCode::NOT_FOUND, c.remove(20));
     CORE_TEST_ERROR(c.remove(5));
-    CORE_TEST_EQUAL(Core::Error::NOT_FOUND, c.remove(30));
+    CORE_TEST_EQUAL(Core::ErrorCode::NOT_FOUND, c.remove(30));
 
     CORE_TEST_ERROR(c.add(20, 40));
     CORE_TEST_ERROR(c.remove(20));
@@ -194,7 +194,7 @@ static void testOutOfMemory() {
     for(int i = 0; i < 40; i++) {
         Core::Fail::leftAllocations = 2;
         Core::Error e = c.put(i1, 1, 10);
-        if(e == Core::Error::OUT_OF_MEMORY) {
+        if(e == Core::ErrorCode::OUT_OF_MEMORY) {
             memFails++;
         }
     }
@@ -224,4 +224,4 @@ void Core::testComponents(bool outOfMemoryTest) {
         testOutOfMemory();
     }
     testConstSearch();
-}
+}

+ 29 - 23
test/modules/ErrorTests.cpp

@@ -1,27 +1,33 @@
 #include "../Tests.hpp"
 #include "core/utils/Error.hpp"
 
-static void test(Core::Error e, const char* s) {
-    CORE_TEST_STRING(getErrorName(e), s);
-}
-
 void Core::testError() {
-    test(Error::NONE, "NONE");
-    test(Error::NEGATIVE_ARGUMENT, "NEGATIVE_ARGUMENT");
-    test(Error::CAPACITY_REACHED, "CAPACITY_REACHED");
-    test(Error::BLOCKED_STDOUT, "BLOCKED_STDOUT");
-    test(Error::OUT_OF_MEMORY, "OUT_OF_MEMORY");
-    test(Error::INVALID_CHAR, "INVALID_CHAR");
-    test(Error::NOT_FOUND, "NOT_FOUND");
-    test(Error::INVALID_STATE, "INVALID_STATE");
-    test(Error::INVALID_INDEX, "INVALID_INDEX");
-    test(Error::INVALID_ARGUMENT, "INVALID_ARGUMENT");
-    test(Error::TIME_NOT_AVAILABLE, "TIME_NOT_AVAILABLE");
-    test(Error::SLEEP_INTERRUPTED, "SLEEP_INTERRUPTED");
-    test(Error::THREAD_ERROR, "THREAD_ERROR");
-    test(Error::MUTEX_ERROR, "MUTEX_ERROR");
-    test(Error::EXISTING_KEY, "EXISTING_KEY");
-    test(Error::CANNOT_OPEN_FILE, "CANNOT_OPEN_FILE");
-    test(Error::END_OF_FILE, "END_OF_FILE");
-    test(static_cast<Error>(200), "?");
-}
+    CORE_TEST_STRING("0", ErrorCode::NONE);
+    CORE_TEST_STRING("1", ErrorCode::NEGATIVE_ARGUMENT);
+    CORE_TEST_STRING("01", ErrorCode::CAPACITY_REACHED);
+    CORE_TEST_STRING("001", ErrorCode::BLOCKED_STDOUT);
+    CORE_TEST_STRING("0001", ErrorCode::OUT_OF_MEMORY);
+    CORE_TEST_STRING("00001", ErrorCode::INVALID_CHAR);
+    CORE_TEST_STRING("000001", ErrorCode::NOT_FOUND);
+    CORE_TEST_STRING("0000001", ErrorCode::INVALID_STATE);
+    CORE_TEST_STRING("00000001", ErrorCode::INVALID_INDEX);
+    CORE_TEST_STRING("000000001", ErrorCode::INVALID_ARGUMENT);
+    CORE_TEST_STRING("0000000001", ErrorCode::TIME_NOT_AVAILABLE);
+    CORE_TEST_STRING("00000000001", ErrorCode::SLEEP_INTERRUPTED);
+    CORE_TEST_STRING("000000000001", ErrorCode::THREAD_ERROR);
+    CORE_TEST_STRING("0000000000001", ErrorCode::MUTEX_ERROR);
+    CORE_TEST_STRING("00000000000001", ErrorCode::EXISTING_KEY);
+    CORE_TEST_STRING("000000000000001", ErrorCode::CANNOT_OPEN_FILE);
+    CORE_TEST_STRING("0000000000000001", ErrorCode::END_OF_FILE);
+
+    CORE_TEST_STRING(
+        "1111111111111111",
+        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);
+}

+ 10 - 10
test/modules/FileReaderTests.cpp

@@ -10,7 +10,7 @@ static void testReadChar() {
     Core::String8<128> s;
     while(true) {
         int c = 0;
-        if(r.readChar(c) != Core::Error::NONE) {
+        if(r.readChar(c) != Core::ErrorCode::NONE) {
             break;
         }
         CORE_TEST_ERROR(s.append(static_cast<c32>(c)));
@@ -26,7 +26,7 @@ static void testReadCharPath() {
     Core::String8<128> s;
     while(true) {
         int c = 0;
-        if(r.readChar(c) != Core::Error::NONE) {
+        if(r.readChar(c) != Core::ErrorCode::NONE) {
             break;
         }
         CORE_TEST_ERROR(s.append(static_cast<c32>(c)));
@@ -38,7 +38,7 @@ static void testReadChars() {
     Core::FileReader r;
     CORE_TEST_ERROR(r.open(TEST_FILE));
     char buffer[128];
-    CORE_TEST_EQUAL(Core::Error::END_OF_FILE,
+    CORE_TEST_EQUAL(Core::ErrorCode::END_OF_FILE,
                     r.readChars(buffer, sizeof(buffer)));
     CORE_TEST_STRING("abc\nBaum\n", buffer);
 }
@@ -59,7 +59,7 @@ static void testMoveConstruct() {
     CORE_TEST_STRING(TEST_FILE, r2.getPath());
 
     int c = 0;
-    CORE_TEST_EQUAL(Core::Error::INVALID_STATE, r.readChar(c));
+    CORE_TEST_EQUAL(Core::ErrorCode::INVALID_STATE, r.readChar(c));
     CORE_TEST_ERROR(r2.readChar(c));
     CORE_TEST_EQUAL('a', c);
 }
@@ -73,7 +73,7 @@ static void testMoveAssignment() {
     CORE_TEST_STRING(TEST_FILE, r2.getPath());
 
     int c = 0;
-    CORE_TEST_EQUAL(Core::Error::INVALID_STATE, r.readChar(c));
+    CORE_TEST_EQUAL(Core::ErrorCode::INVALID_STATE, r.readChar(c));
     CORE_TEST_ERROR(r2.readChar(c));
     CORE_TEST_EQUAL('a', c);
 }
@@ -81,11 +81,11 @@ static void testMoveAssignment() {
 static void testInvalidAccess() {
     char buffer[4];
     Core::FileReader r;
-    CORE_TEST_EQUAL(Core::Error::INVALID_STATE,
+    CORE_TEST_EQUAL(Core::ErrorCode::INVALID_STATE,
                     r.readChars(buffer, sizeof(buffer)));
     CORE_TEST_ERROR(r.open(TEST_FILE));
-    CORE_TEST_EQUAL(Core::Error::INVALID_ARGUMENT, r.readChars(buffer, -1));
-    CORE_TEST_EQUAL(Core::Error::INVALID_STATE, r.open(TEST_FILE));
+    CORE_TEST_EQUAL(Core::ErrorCode::INVALID_ARGUMENT, r.readChars(buffer, -1));
+    CORE_TEST_EQUAL(Core::ErrorCode::INVALID_STATE, r.open(TEST_FILE));
 }
 
 static void testInvalidAccessPath() {
@@ -93,7 +93,7 @@ static void testInvalidAccessPath() {
     Core::Path path;
     CORE_TEST_ERROR(path.append(TEST_FILE));
     CORE_TEST_ERROR(r.open(path));
-    CORE_TEST_EQUAL(Core::Error::INVALID_STATE, r.open(path));
+    CORE_TEST_EQUAL(Core::ErrorCode::INVALID_STATE, r.open(path));
 }
 
 static void testCloseFail() {
@@ -117,4 +117,4 @@ void Core::testFileReader() {
     testInvalidAccess();
     testInvalidAccessPath();
     testCloseFail();
-}
+}

+ 1 - 1
test/modules/FrustumTests.cpp

@@ -60,4 +60,4 @@ void Core::testFrustum() {
     testPointIsInside();
     testSphereIsInside();
     testUpdateProjection();
-}
+}

+ 6 - 5
test/modules/HashMapTests.cpp

@@ -95,7 +95,7 @@ struct HashMapTestStruct final {
         CORE_RETURN_ERROR(s.append(", "));
         CORE_RETURN_ERROR(s.append(b));
         CORE_RETURN_ERROR(s.append(")"));
-        return Core::Error::NONE;
+        return Core::ErrorCode::NONE;
     }
 };
 
@@ -106,8 +106,9 @@ static void testEmplace() {
     CORE_TEST_ERROR(map.tryEmplace(ar, 0, 3, 4));
     CORE_TEST_ERROR(map.tryEmplace(ar, 3, 4, 5));
     CORE_TEST_ERROR(map.tryEmplace(ar, 20, 5, 6));
-    CORE_TEST_EQUAL(Core::Error::EXISTING_KEY, map.tryEmplace(ar, 3, 6, 7));
-    CORE_TEST_EQUAL(Core::Error::EXISTING_KEY, map.tryEmplace(ar, 20, 7, 8));
+    CORE_TEST_EQUAL(Core::ErrorCode::EXISTING_KEY, map.tryEmplace(ar, 3, 6, 7));
+    CORE_TEST_EQUAL(Core::ErrorCode::EXISTING_KEY,
+                    map.tryEmplace(ar, 20, 7, 8));
 
     HashMapTestStruct* a = map.search(0);
     HashMapTestStruct* b = map.search(3);
@@ -215,7 +216,7 @@ static void testRemove() {
     CORE_TEST_ERROR(map.add(3, 5));
 
     CORE_TEST_ERROR(map.remove(2));
-    CORE_TEST_EQUAL(Core::Error::NOT_FOUND, map.remove(7));
+    CORE_TEST_EQUAL(Core::ErrorCode::NOT_FOUND, map.remove(7));
 
     int* a = map.search(1);
     int* b = map.search(2);
@@ -319,7 +320,7 @@ static void testOutOfMemory() {
         Core::Fail::leftAllocations = 2;
         int* v = nullptr;
         Core::Error e = map.put(v, 1, 1);
-        if(e == Core::Error::OUT_OF_MEMORY) {
+        if(e == Core::ErrorCode::OUT_OF_MEMORY) {
             memFails++;
         }
     }

+ 1 - 1
test/modules/LinkedListTests.cpp

@@ -281,7 +281,7 @@ static void testOutOfMemory() {
     for(int i = 0; i < 40; i++) {
         Core::Fail::leftAllocations = i;
         Core::Error e = list.add(1);
-        if(e == Core::Error::OUT_OF_MEMORY) {
+        if(e == Core::ErrorCode::OUT_OF_MEMORY) {
             memFails++;
         }
     }

+ 8 - 8
test/modules/ListTests.cpp

@@ -135,9 +135,9 @@ static void testRemoveBySwap() {
     CORE_TEST_ERROR(list.add(4));
     CORE_TEST_ERROR(list.add(3));
     CORE_TEST_ERROR(list.add(2));
-    CORE_TEST_EQUAL(Core::Error::INVALID_INDEX, list.removeBySwap(-1));
+    CORE_TEST_EQUAL(Core::ErrorCode::INVALID_INDEX, list.removeBySwap(-1));
     CORE_TEST_ERROR(list.removeBySwap(0));
-    CORE_TEST_EQUAL(Core::Error::INVALID_INDEX, list.removeBySwap(2));
+    CORE_TEST_EQUAL(Core::ErrorCode::INVALID_INDEX, list.removeBySwap(2));
     CORE_TEST_EQUAL(2, list[0]);
     CORE_TEST_EQUAL(3, list[1]);
     CORE_TEST_EQUAL(2, list.getLength());
@@ -146,7 +146,7 @@ static void testRemoveBySwap() {
     CORE_TEST_EQUAL(1, list.getLength());
     CORE_TEST_ERROR(list.removeBySwap(0));
     CORE_TEST_EQUAL(0, list.getLength());
-    CORE_TEST_EQUAL(Core::Error::INVALID_INDEX, list.removeBySwap(0));
+    CORE_TEST_EQUAL(Core::ErrorCode::INVALID_INDEX, list.removeBySwap(0));
 }
 
 static void testRemove() {
@@ -154,19 +154,19 @@ static void testRemove() {
     CORE_TEST_ERROR(list.add(4));
     CORE_TEST_ERROR(list.add(3));
     CORE_TEST_ERROR(list.add(2));
-    CORE_TEST_EQUAL(Core::Error::INVALID_INDEX, list.remove(-1));
+    CORE_TEST_EQUAL(Core::ErrorCode::INVALID_INDEX, list.remove(-1));
     CORE_TEST_ERROR(list.remove(0));
-    CORE_TEST_EQUAL(Core::Error::INVALID_INDEX, list.remove(2));
+    CORE_TEST_EQUAL(Core::ErrorCode::INVALID_INDEX, list.remove(2));
     CORE_TEST_EQUAL(3, list[0]);
     CORE_TEST_EQUAL(2, list[1]);
-    CORE_TEST_EQUAL(Core::Error::INVALID_INDEX, list.remove(2));
+    CORE_TEST_EQUAL(Core::ErrorCode::INVALID_INDEX, list.remove(2));
     CORE_TEST_EQUAL(2, list.getLength());
     CORE_TEST_ERROR(list.remove(1));
     CORE_TEST_EQUAL(3, list[0]);
     CORE_TEST_EQUAL(1, list.getLength());
     CORE_TEST_ERROR(list.remove(0));
     CORE_TEST_EQUAL(0, list.getLength());
-    CORE_TEST_EQUAL(Core::Error::INVALID_INDEX, list.remove(0));
+    CORE_TEST_EQUAL(Core::ErrorCode::INVALID_INDEX, list.remove(0));
 }
 
 static void testResize() {
@@ -233,4 +233,4 @@ void Core::testList(bool light) {
     testShrinkExact();
     testShrinkResize();
     testCopyEmpty();
-}
+}

+ 1 - 1
test/modules/MathTests.cpp

@@ -101,4 +101,4 @@ void Core::testMath() {
     testSinCos();
     testRadianToDegree();
     testDegreeToRadian();
-}
+}

+ 3 - 3
test/modules/MatrixStackTests.cpp

@@ -30,7 +30,7 @@ static void testPush(bool light) {
     }
     int limit = light ? 10000 : 1000000;
     for(int i = 0; i < limit; i++) {
-        CORE_TEST_EQUAL(Core::Error::CAPACITY_REACHED, stack.push());
+        CORE_TEST_EQUAL(Core::ErrorCode::CAPACITY_REACHED, stack.push());
     }
 }
 
@@ -101,7 +101,7 @@ static void testToString3() {
 
 static void testInvalidPop() {
     Matrices stack;
-    CORE_TEST_EQUAL(Core::Error::INVALID_STATE, stack.pop());
+    CORE_TEST_EQUAL(Core::ErrorCode::INVALID_STATE, stack.pop());
 }
 
 static void testConstPeek() {
@@ -123,4 +123,4 @@ void Core::testMatrixStack(bool light) {
     testToString3();
     testInvalidPop();
     testConstPeek();
-}
+}

+ 1 - 1
test/modules/PlaneTests.cpp

@@ -34,4 +34,4 @@ void Core::testPlane() {
     testToString1();
     testToString2();
     testSignedDistance();
-}
+}

+ 7 - 6
test/modules/ProbingHashMapTests.cpp

@@ -115,7 +115,7 @@ struct ProbingHashMapTestStruct final {
         CORE_RETURN_ERROR(s.append(", "));
         CORE_RETURN_ERROR(s.append(b));
         CORE_RETURN_ERROR(s.append(")"));
-        return Core::Error::NONE;
+        return Core::ErrorCode::NONE;
     }
 };
 
@@ -127,8 +127,9 @@ static void testEmplace() {
         CORE_TEST_ERROR(map.tryEmplace(ar, 0, 3, 4));
         CORE_TEST_ERROR(map.tryEmplace(ar, 3, 4, 5));
         CORE_TEST_ERROR(map.tryEmplace(ar, 20, 5, 6));
-        CORE_TEST_EQUAL(Core::Error::EXISTING_KEY, map.tryEmplace(ar, 3, 6, 7));
-        CORE_TEST_EQUAL(Core::Error::EXISTING_KEY,
+        CORE_TEST_EQUAL(Core::ErrorCode::EXISTING_KEY,
+                        map.tryEmplace(ar, 3, 6, 7));
+        CORE_TEST_EQUAL(Core::ErrorCode::EXISTING_KEY,
                         map.tryEmplace(ar, 20, 7, 8));
 
         ProbingHashMapTestStruct* a = map.search(0);
@@ -320,7 +321,7 @@ static void testOutOfMemory() {
         Core::Fail::leftAllocations = i;
         int* v = nullptr;
         Core::Error e = map.put(v, 1, 1);
-        if(e == Core::Error::OUT_OF_MEMORY) {
+        if(e == Core::ErrorCode::OUT_OF_MEMORY) {
             memFails++;
         }
     }
@@ -336,9 +337,9 @@ static void testOutOfMemory() {
 static void testInsertInvalid() {
     IntMap map;
     int* v;
-    CORE_TEST_EQUAL(Core::Error::INVALID_ARGUMENT,
+    CORE_TEST_EQUAL(Core::ErrorCode::INVALID_ARGUMENT,
                     map.tryEmplace(v, Core::emptyValue<int>(), 2));
-    CORE_TEST_EQUAL(Core::Error::INVALID_ARGUMENT,
+    CORE_TEST_EQUAL(Core::ErrorCode::INVALID_ARGUMENT,
                     map.put(v, Core::emptyValue<int>(), 2));
 }
 

+ 1 - 1
test/modules/RandomTests.cpp

@@ -87,4 +87,4 @@ void Core::testRandom(bool light) {
     testFloatAverage(light);
     testFloatCoin(light);
     testFloatDistribution(light);
-}
+}

+ 5 - 5
test/modules/RingBufferTests.cpp

@@ -64,8 +64,8 @@ static void testOverflow() {
     CORE_TEST_ERROR(buffer.add(1));
     CORE_TEST_ERROR(buffer.add(2));
     CORE_TEST_ERROR(buffer.add(3));
-    CORE_TEST_EQUAL(Core::Error::CAPACITY_REACHED, buffer.add(4));
-    CORE_TEST_EQUAL(Core::Error::CAPACITY_REACHED, buffer.add(5));
+    CORE_TEST_EQUAL(Core::ErrorCode::CAPACITY_REACHED, buffer.add(4));
+    CORE_TEST_EQUAL(Core::ErrorCode::CAPACITY_REACHED, buffer.add(5));
     CORE_TEST_EQUAL(3, buffer.getLength());
     CORE_TEST_EQUAL(1, buffer[0]);
     CORE_TEST_ERROR(buffer.remove());
@@ -84,7 +84,7 @@ static void testRefill() {
     CORE_TEST_ERROR(buffer.add(1));
     CORE_TEST_ERROR(buffer.add(2));
     CORE_TEST_ERROR(buffer.add(3));
-    CORE_TEST_EQUAL(Core::Error::CAPACITY_REACHED, buffer.add(4));
+    CORE_TEST_EQUAL(Core::ErrorCode::CAPACITY_REACHED, buffer.add(4));
     CORE_TEST_EQUAL(3, buffer.getLength());
     CORE_TEST_TRUE(buffer.canRemove());
     CORE_TEST_EQUAL(1, buffer[0]);
@@ -260,7 +260,7 @@ static void testOverall() {
 
 static void testInvalidRemove() {
     Core::RingBuffer<int, 3> buffer;
-    CORE_TEST_EQUAL(Core::Error::INVALID_STATE, buffer.remove());
+    CORE_TEST_EQUAL(Core::ErrorCode::INVALID_STATE, buffer.remove());
 }
 
 void Core::testRingBuffer() {
@@ -275,4 +275,4 @@ void Core::testRingBuffer() {
     testMoveAssignmentDestruct();
     testOverall();
     testInvalidRemove();
-}
+}

+ 2 - 2
test/modules/StackTests.cpp

@@ -60,7 +60,7 @@ template<typename T>
 static void testPop(int amount) {
     T stack;
     for(int i = 0; i < amount; i++) {
-        CORE_TEST_EQUAL(Core::Error::INVALID_STATE, stack.pop());
+        CORE_TEST_EQUAL(Core::ErrorCode::INVALID_STATE, stack.pop());
     }
 }
 
@@ -88,4 +88,4 @@ static void testType(int amount) {
 void Core::testStack(bool light) {
     testType<Core::ListStack<int>>(light ? 10000 : 100000);
     testType<Core::ArrayStack<int, 100>>(100);
-}
+}

+ 4 - 4
test/modules/ThreadTests.cpp

@@ -41,7 +41,7 @@ static void testLambda() {
 
 static void testJoinWithoutStart() {
     Core::Thread t;
-    CORE_TEST_EQUAL(Core::Error::THREAD_ERROR, t.join(nullptr));
+    CORE_TEST_EQUAL(Core::ErrorCode::THREAD_ERROR, t.join(nullptr));
 }
 
 static void testAutoJoin() {
@@ -75,7 +75,7 @@ static void testDoubleJoin() {
     Core::Thread t;
     CORE_TEST_ERROR(t.start([](void*) { return 0; }, nullptr));
     CORE_TEST_ERROR(t.join(nullptr));
-    CORE_TEST_EQUAL(Core::Error::THREAD_ERROR, t.join(nullptr));
+    CORE_TEST_EQUAL(Core::ErrorCode::THREAD_ERROR, t.join(nullptr));
 }
 
 struct MutexCounter {
@@ -96,7 +96,7 @@ static int incrementMutexCounter(void* p) {
 static void testMutex() {
     MutexCounter mc;
     CORE_TEST_ERROR(mc.m.init());
-    CORE_TEST_EQUAL(Core::Error::INVALID_STATE, mc.m.init());
+    CORE_TEST_EQUAL(Core::ErrorCode::INVALID_STATE, mc.m.init());
     Core::Thread t[2];
     CORE_TEST_ERROR(t[0].start(incrementMutexCounter, &mc));
     CORE_TEST_ERROR(t[1].start(incrementMutexCounter, &mc));
@@ -115,4 +115,4 @@ void Core::testThread() {
     testMoveIntoActive();
     testDoubleJoin();
     testMutex();
-}
+}

+ 3 - 2
test/modules/UtilityTests.cpp

@@ -41,7 +41,8 @@ static void testReallocateFail() {
 #ifdef ERROR_SIMULATOR
     char* buffer = nullptr;
     Core::Fail::realloc = true;
-    CORE_TEST_EQUAL(Core::Error::OUT_OF_MEMORY, Core::reallocate(buffer, 16));
+    CORE_TEST_EQUAL(Core::ErrorCode::OUT_OF_MEMORY,
+                    Core::reallocate(buffer, 16));
     CORE_TEST_TRUE(buffer == nullptr);
     Core::Fail::realloc = false;
 #endif
@@ -53,4 +54,4 @@ void Core::testUtility() {
     testNegativeArguments();
     testNegativeRellocate();
     testReallocateFail();
-}
+}

+ 1 - 1
test/modules/VectorTests.cpp

@@ -225,4 +225,4 @@ void Core::testVector() {
     testCast();
     testToString();
     testNormalizeIntVector();
-}
+}

+ 1 - 1
test/modules/ViewTests.cpp

@@ -38,4 +38,4 @@ void Core::testView() {
     testFromAngles();
     testFromQuaternion();
     testUpdateMatrix();
-}
+}