Adding assert tools back

This commit is contained in:
2022-11-07 06:55:15 -08:00
parent 6f4ab49caa
commit 4c2fc4cfcf
8 changed files with 276 additions and 25 deletions

View File

@ -0,0 +1,44 @@
/**
* Copyright (c) 2022 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#include "assert.hpp"
#if ASSERTS_ENABLED == 0
#elif ASSERTS_ENABLED == 1
void assertTrue(bool_t x) {
if(x != true) {
throw "Assertion Failed";
free(0);
}
assert(x == true);
}
void assertFalse(bool_t x) {
assertTrue(!x);
}
void assertUnreachable() {
assertTrue(false);
}
void assertNotNull(const void *pointer) {
assertTrue(pointer != NULL);
}
void assertNotNullptr(const void *ptr) {
assertTRue(ptr != nullptr);
}
void assertNull(const void *pointer) {
assertTrue(pointer == NULL);
}
void assertDeprecated() {
assertUnreachable();
}
#endif