Procházet zdrojové kódy

Remove namespace from internal test functions

Kajetan Johannes Hammerle před 11 měsíci
rodič
revize
93a72be666

+ 23 - 23
test/Main.c

@@ -21,37 +21,37 @@ int main(int argAmount, const char** args) {
         if(strcmp(args[i], "light") == 0) {
             light = true;
         } else if(strcmp(args[i], "alloc") == 0) {
-            coreTestInvalidAllocate();
+            testInvalidAllocate();
         } else if(strcmp(args[i], "realloc") == 0) {
-            coreTestInvalidReallocate();
+            testInvalidReallocate();
         } else if(strcmp(args[i], "pre_canary") == 0) {
-            coreTestPreCanary();
+            testPreCanary();
         } else if(strcmp(args[i], "post_canary") == 0) {
-            coreTestPostCanary();
+            testPostCanary();
         } else if(strcmp(args[i], "test") == 0) {
-            coreTestTest();
+            testTest();
             return 0;
         }
     }
 
-    coreTestBitArray();
-    coreTestBox();
-    coreTestBuffer(light);
-    coreTestComponents();
-    coreTestFrustum();
-    coreTestHashMap(light);
-    coreTestLinkedList(light);
-    coreTestList(light);
-    coreTestMatrix();
-    coreTestPlane();
-    coreTestQuaternion();
-    coreTestRandom(light);
-    coreTestReadLine();
-    coreTestRingBuffer();
-    coreTestSpinLock();
-    coreTestUtility(light);
-    coreTestVector();
-    coreTestView();
+    testBitArray();
+    testBox();
+    testBuffer(light);
+    testComponents();
+    testFrustum();
+    testHashMap(light);
+    testLinkedList(light);
+    testList(light);
+    testMatrix();
+    testPlane();
+    testQuaternion();
+    testRandom(light);
+    testReadLine();
+    testRingBuffer();
+    testSpinLock();
+    testUtility(light);
+    testVector();
+    testView();
 
     coreLogLevel = CORE_LOG_WARNING;
     CORE_LOG_DEBUG("You won't see this!");

+ 23 - 23
test/Tests.h

@@ -3,28 +3,28 @@
 
 #include "core/Test.h"
 
-[[noreturn]] void coreTestInvalidAllocate(void);
-[[noreturn]] void coreTestInvalidReallocate(void);
-void coreTestBitArray(void);
-void coreTestBox(void);
-void coreTestBuffer(bool light);
-void coreTestComponents(void);
-void coreTestFrustum(void);
-void coreTestHashMap(bool light);
-void coreTestLinkedList(bool light);
-void coreTestList(bool light);
-void coreTestMatrix(void);
-void coreTestPlane(void);
-void coreTestPostCanary(void);
-void coreTestPreCanary(void);
-void coreTestQuaternion(void);
-void coreTestRandom(bool light);
-void coreTestReadLine(void);
-void coreTestRingBuffer(void);
-void coreTestSpinLock(void);
-void coreTestTest(void);
-void coreTestUtility(bool light);
-void coreTestVector(void);
-void coreTestView(void);
+[[noreturn]] void testInvalidAllocate(void);
+[[noreturn]] void testInvalidReallocate(void);
+void testBitArray(void);
+void testBox(void);
+void testBuffer(bool light);
+void testComponents(void);
+void testFrustum(void);
+void testHashMap(bool light);
+void testLinkedList(bool light);
+void testList(bool light);
+void testMatrix(void);
+void testPlane(void);
+void testPostCanary(void);
+void testPreCanary(void);
+void testQuaternion(void);
+void testRandom(bool light);
+void testReadLine(void);
+void testRingBuffer(void);
+void testSpinLock(void);
+void testTest(void);
+void testUtility(bool light);
+void testVector(void);
+void testView(void);
 
 #endif

+ 1 - 1
test/modules/BitArrayTests.c

@@ -179,7 +179,7 @@ static void testInvalidArgument() {
     destroyBitArray(&bits);
 }
 
-void coreTestBitArray() {
+void testBitArray() {
     testSetRead();
     testBigSetRead();
     testRandomSetReadResize();

+ 1 - 1
test/modules/BoxTests.c

@@ -91,7 +91,7 @@ static void testGrow() {
                      buffer);
 }
 
-void coreTestBox() {
+void testBox() {
     testInit();
     testOffset();
     testCollidesWith();

+ 1 - 1
test/modules/BufferTests.c

@@ -4,7 +4,7 @@
 static const size_t SIZE_TYPES =
     sizeof(int) + sizeof(long) + sizeof(float) + sizeof(double);
 
-void coreTestBuffer(bool light) {
+void testBuffer(bool light) {
     CoreBuffer buffer;
     coreInitBuffer(&buffer);
     size_t limit = light ? 1000 : 100000;

+ 1 - 1
test/modules/ComponentsTests.c

@@ -113,7 +113,7 @@ static void testRemove() {
     coreDestroyComponents(&c);
 }
 
-void coreTestComponents() {
+void testComponents() {
     testAddForEach();
     testAddComponentForEach();
     testRemove();

+ 1 - 1
test/modules/FrustumTests.c

@@ -66,7 +66,7 @@ static void testUpdateProjection() {
                      buffer);
 }
 
-void coreTestFrustum() {
+void testFrustum() {
     testToString();
     testPointIsInside();
     testSphereIsInside();

+ 1 - 1
test/modules/HashMapTests.c

@@ -270,7 +270,7 @@ static void testSearchSize() {
     coreDestroyHashMap(&map);
 }
 
-void coreTestHashMap(bool light) {
+void testHashMap(bool light) {
     testAdd();
     testMultipleAdd();
     testSearch();

+ 1 - 1
test/modules/LinkedListTests.c

@@ -241,7 +241,7 @@ static void testSwap() {
     coreDestroyLinkedList(&list);
 }
 
-void coreTestLinkedList(bool light) {
+void testLinkedList(bool light) {
     testAdd();
     testMultipleAdd();
     testClear();

+ 1 - 1
test/modules/ListTests.c

@@ -268,7 +268,7 @@ static void testStruct() {
     coreDestroyList(&list);
 }
 
-void coreTestList(bool light) {
+void testList(bool light) {
     testAdd();
     testMultipleAdd();
     testAddLast();

+ 1 - 1
test/modules/MatrixTests.c

@@ -204,7 +204,7 @@ static void testToString() {
     CORE_TEST_STRING("[[1.000, 2.000, 3.0", buffer);
 }
 
-void coreTestMatrix() {
+void testMatrix() {
     testInit();
     testTranspose();
     testScale();

+ 1 - 1
test/modules/PlaneTests.c

@@ -26,7 +26,7 @@ static void testSignedDistance() {
     CORE_TEST_FLOAT(0.911684612f, coreSignedDistance(&p, CV3(3, 2, 1)), eps);
 }
 
-void coreTestPlane() {
+void testPlane() {
     testToString();
     testSignedDistance();
 }

+ 1 - 1
test/modules/QuaternionTests.c

@@ -98,7 +98,7 @@ static void testMulVector() {
     CORE_TEST_V3(CV3(0.0f, 0.0f, 1.0f), coreMulQV3(CV30, &q3, &v3));
 }
 
-void coreTestQuaternion() {
+void testQuaternion() {
     testInit();
     testAxisAndDegreesInit();
     testLerp();

+ 1 - 1
test/modules/RandomTests.c

@@ -93,7 +93,7 @@ static void testRandomI32() {
     }
 }
 
-void coreTestRandom(bool light) {
+void testRandom(bool light) {
     testAverage(light);
     testCoin(light);
     testDistribution(light);

+ 1 - 1
test/modules/ReadLineTests.c

@@ -36,7 +36,7 @@ static void testString(int line, const char* s) {
     }
 }
 
-void coreTestReadLine(void) {
+void testReadLine(void) {
 #ifdef ERROR_SIMULATOR
     coreFailMutexInit = true;
     if(!CORE_TEST_TRUE(coreStartReadLine())) {

+ 1 - 1
test/modules/RingBufferTests.c

@@ -116,7 +116,7 @@ static void testOverall() {
     coreDestroyRingBuffer(&ri);
 }
 
-void coreTestRingBuffer() {
+void testRingBuffer() {
     testReadAndWrite();
     testOverflow();
     testRefill();

+ 3 - 3
test/modules/SpinLockTests.c

@@ -51,7 +51,7 @@ static int incrementSpinLockCounter(void* p) {
     return 0;
 }
 
-static void testSpinLock() {
+static void testSpinLockLoop() {
     i64 n = -coreGetNanos();
 
     SpinLockCounter sc = {.counter = 0};
@@ -67,7 +67,7 @@ static void testSpinLock() {
     printf("%ldns SpinLock\n", n);
 }
 
-void coreTestSpinLock() {
+void testSpinLock() {
     testMutex();
-    testSpinLock();
+    testSpinLockLoop();
 }

+ 1 - 1
test/modules/TestTests.c

@@ -1,7 +1,7 @@
 #include "../Tests.h"
 #include "core/Vector.h"
 
-void coreTestTest() {
+void testTest() {
     TEST_BOOL(false, true);
     TEST_INT(0, 1);
     TEST_I64(0, 1);

+ 45 - 45
test/modules/UtilityTests.c

@@ -5,21 +5,21 @@
 static const float eps = 0.0001f;
 
 static void testPopCount() {
-    CORE_TEST_U64(4, popCount(0xF));
-    CORE_TEST_U64(0, popCount(0x0));
-    CORE_TEST_U64(2, popCount(0x6));
-    CORE_TEST_U64(7, popCount(0x7F));
-    CORE_TEST_U64(3, popCount(0x2A));
-    CORE_TEST_U64(32, popCount(0xFFFFFFFF));
-    CORE_TEST_U64(64, popCount(0xFFFFFFFFFFFFFFFF));
-    CORE_TEST_U64(44, popCount(0xFFFF0FFFFFFF));
+    TEST_U64(4, popCount(0xF));
+    TEST_U64(0, popCount(0x0));
+    TEST_U64(2, popCount(0x6));
+    TEST_U64(7, popCount(0x7F));
+    TEST_U64(3, popCount(0x2A));
+    TEST_U64(32, popCount(0xFFFFFFFF));
+    TEST_U64(64, popCount(0xFFFFFFFFFFFFFFFF));
+    TEST_U64(44, popCount(0xFFFF0FFFFFFF));
 }
 
 static void testZeroRellocate() {
     void* buffer = cReallocate(nullptr, 16);
-    CORE_TEST_NOT_NULL(buffer);
+    TEST_NOT_NULL(buffer);
     buffer = cReallocate(buffer, 0);
-    CORE_TEST_NULL(buffer);
+    TEST_NULL(buffer);
 }
 
 static void testMemoryInfoList() {
@@ -35,43 +35,43 @@ static void testMemoryInfoList() {
 }
 
 static void testInterpolate() {
-    CORE_TEST_FLOAT(7.5f, interpolate(5.0f, 10.0f, 0.5f), eps);
-    CORE_TEST_FLOAT(-2.0, interpolate(-10.0f, 10.0f, 0.4f), eps);
-    CORE_TEST_FLOAT(10.0f, interpolate(-3.0f, 10.0f, 1.0f), eps);
-    CORE_TEST_FLOAT(7.0f, interpolate(7.0f, 10.0f, 0.0f), eps);
-    CORE_TEST_FLOAT(6.0f, interpolate(0.0f, 10.0f, 0.6f), eps);
+    TEST_FLOAT(7.5f, interpolate(5.0f, 10.0f, 0.5f), eps);
+    TEST_FLOAT(-2.0, interpolate(-10.0f, 10.0f, 0.4f), eps);
+    TEST_FLOAT(10.0f, interpolate(-3.0f, 10.0f, 1.0f), eps);
+    TEST_FLOAT(7.0f, interpolate(7.0f, 10.0f, 0.0f), eps);
+    TEST_FLOAT(6.0f, interpolate(0.0f, 10.0f, 0.6f), eps);
 }
 
 static void testRadianToDegree() {
-    CORE_TEST_FLOAT(45.0f, radianToDegree(CORE_PI * 0.25f), eps);
-    CORE_TEST_FLOAT(90.0f, radianToDegree(CORE_PI * 0.5f), eps);
-    CORE_TEST_FLOAT(180.0f, radianToDegree(CORE_PI), eps);
-    CORE_TEST_FLOAT(360.0f, radianToDegree(CORE_PI * 2.0f), eps);
+    TEST_FLOAT(45.0f, radianToDegree(PI * 0.25f), eps);
+    TEST_FLOAT(90.0f, radianToDegree(PI * 0.5f), eps);
+    TEST_FLOAT(180.0f, radianToDegree(PI), eps);
+    TEST_FLOAT(360.0f, radianToDegree(PI * 2.0f), eps);
 }
 
 static void testDegreeToRadian() {
-    CORE_TEST_FLOAT(CORE_PI * 0.25f, degreeToRadian(45.0f), eps);
-    CORE_TEST_FLOAT(CORE_PI * 0.5f, degreeToRadian(90.0f), eps);
-    CORE_TEST_FLOAT(CORE_PI, degreeToRadian(180.0f), eps);
-    CORE_TEST_FLOAT(CORE_PI * 2.0f, degreeToRadian(360.0f), eps);
+    TEST_FLOAT(PI * 0.25f, degreeToRadian(45.0f), eps);
+    TEST_FLOAT(PI * 0.5f, degreeToRadian(90.0f), eps);
+    TEST_FLOAT(PI, degreeToRadian(180.0f), eps);
+    TEST_FLOAT(PI * 2.0f, degreeToRadian(360.0f), eps);
 }
 
 static void testSleep(i64 nanos) {
     i64 time = -getNanos();
-    CORE_TEST_FALSE(sleepNanos(nanos));
+    TEST_FALSE(sleepNanos(nanos));
     time += getNanos();
-    CORE_TEST_TRUE(time >= nanos && time <= (nanos * 13) / 10);
+    TEST_TRUE(time >= nanos && time <= (nanos * 13) / 10);
 }
 
 static void testFail() {
 #ifdef ERROR_SIMULATOR
     coreFailTimeGet = true;
-    CORE_TEST_I64(-1, getNanos());
+    TEST_I64(-1, getNanos());
     coreFailTimeGet = false;
 #endif
 }
 
-void coreTestUtility(bool light) {
+void testUtility(bool light) {
     testPopCount();
     testZeroRellocate();
     testMemoryInfoList();
@@ -87,42 +87,42 @@ static void outOfMemory(void*) {
     setOutOfMemoryHandler(nullptr, nullptr);
 }
 
-void coreTestInvalidAllocate(void) {
+void testInvalidAllocate(void) {
     setOutOfMemoryHandler(outOfMemory, nullptr);
     cAllocate(0xFFFFFFFFFFF);
-    CORE_TEST_TRUE(false);
-    coreFinalizeTests();
-    CORE_EXIT(0);
+    TEST_TRUE(false);
+    finalizeTests();
+    EXIT(0);
 }
 
-void coreTestInvalidReallocate(void) {
+void testInvalidReallocate(void) {
     setOutOfMemoryHandler(outOfMemory, nullptr);
     void* p = cAllocate(0xFF);
     printMemoryReport();
     cReallocate(p, 0xFFFFFFFFFFF);
-    CORE_TEST_TRUE(false);
-    coreFinalizeTests();
-    CORE_EXIT(0);
+    TEST_TRUE(false);
+    finalizeTests();
+    EXIT(0);
 }
 
-[[noreturn]] void coreTestPreCanary(void) {
-#ifdef CORE_CHECK_MEMORY
+[[noreturn]] void testPreCanary(void) {
+#ifdef CHECK_MEMORY
     char* p = cAllocate(16);
     p[-1] = 0;
     cFree(p);
-    CORE_TEST_TRUE(false);
+    TEST_TRUE(false);
 #endif
-    coreFinalizeTests();
-    CORE_EXIT(0);
+    finalizeTests();
+    EXIT(0);
 }
 
-[[noreturn]] void coreTestPostCanary(void) {
-#ifdef CORE_CHECK_MEMORY
+[[noreturn]] void testPostCanary(void) {
+#ifdef CHECK_MEMORY
     char* p = cAllocate(16);
     p[17] = 0;
     cFree(p);
-    CORE_TEST_TRUE(false);
+    TEST_TRUE(false);
 #endif
-    coreFinalizeTests();
-    CORE_EXIT(0);
+    finalizeTests();
+    EXIT(0);
 }

+ 1 - 1
test/modules/VectorTests.c

@@ -289,7 +289,7 @@ static void testToString() {
     CORE_TEST_STRING("[4, 5, 6, 7]", buffer);
 }
 
-void coreTestVector() {
+void testVector() {
     testSetAngles();
     testCross();
     testSetAdd();

+ 1 - 1
test/modules/ViewTests.c

@@ -39,7 +39,7 @@ static void testUpdateMatrix() {
                      buffer);
 }
 
-void coreTestView() {
+void testView() {
     testFromAngles();
     testFromQuaternion();
     testUpdateMatrix();