|
@@ -1,94 +1,87 @@
|
|
#include "../Tests.h"
|
|
#include "../Tests.h"
|
|
#include "core/Box.h"
|
|
#include "core/Box.h"
|
|
|
|
+#include "core/ToString.h"
|
|
|
|
|
|
-#define CV3(a, b, c) (&(CoreVector3){{a, b, c}})
|
|
+#define CV3(a, b, c) (&(Vector3){{a, b, c}})
|
|
|
|
|
|
static void testInit() {
|
|
static void testInit() {
|
|
- CoreBox box = CORE_BOX;
|
|
+ CoreBox box = BOX;
|
|
- coreSetBox(&box, CV3(1.0f, 2.0f, 3.0f));
|
|
+ setBox(&box, CV3(1.0f, 2.0f, 3.0f));
|
|
char buffer[128];
|
|
char buffer[128];
|
|
- coreToStringBox(&box, buffer, sizeof(buffer));
|
|
+ toString(&box, buffer, sizeof(buffer));
|
|
- CORE_TEST_STRING("Box([0.000, 0.000, 0.000], [1.000, 2.000, 3.000])",
|
|
+ TEST_STRING("Box([0.000, 0.000, 0.000], [1.000, 2.000, 3.000])", buffer);
|
|
- buffer);
|
|
+ toStringV3(&box.min, buffer, sizeof(buffer));
|
|
- coreToStringV3(&box.min, buffer, sizeof(buffer));
|
|
+ TEST_STRING("[0.000, 0.000, 0.000]", buffer);
|
|
- CORE_TEST_STRING("[0.000, 0.000, 0.000]", buffer);
|
|
+ toStringV3(&box.max, buffer, sizeof(buffer));
|
|
- coreToStringV3(&box.max, buffer, sizeof(buffer));
|
|
+ TEST_STRING("[1.000, 2.000, 3.000]", buffer);
|
|
- CORE_TEST_STRING("[1.000, 2.000, 3.000]", buffer);
|
|
|
|
|
|
|
|
- coreSetBox(&box, CV3(-1.0f, -2.0f, -3.0f));
|
|
+ setBox(&box, CV3(-1.0f, -2.0f, -3.0f));
|
|
- coreToStringBox(&box, buffer, sizeof(buffer));
|
|
+ toString(&box, buffer, sizeof(buffer));
|
|
- CORE_TEST_STRING("Box([-1.000, -2.000, -3.000], [0.000, 0.000, 0.000])",
|
|
+ TEST_STRING("Box([-1.000, -2.000, -3.000], [0.000, 0.000, 0.000])", buffer);
|
|
- buffer);
|
|
+ toStringV3(&box.min, buffer, sizeof(buffer));
|
|
- coreToStringV3(&box.min, buffer, sizeof(buffer));
|
|
+ TEST_STRING("[-1.000, -2.000, -3.000]", buffer);
|
|
- CORE_TEST_STRING("[-1.000, -2.000, -3.000]", buffer);
|
|
+ toStringV3(&box.max, buffer, sizeof(buffer));
|
|
- coreToStringV3(&box.max, buffer, sizeof(buffer));
|
|
+ TEST_STRING("[0.000, 0.000, 0.000]", buffer);
|
|
- CORE_TEST_STRING("[0.000, 0.000, 0.000]", buffer);
|
|
|
|
}
|
|
}
|
|
|
|
|
|
static void testOffset() {
|
|
static void testOffset() {
|
|
- CoreBox box = CORE_BOX;
|
|
+ CoreBox box = BOX;
|
|
- coreSetBox(&box, CV3(1.0f, 2.0f, 3.0f));
|
|
+ setBox(&box, CV3(1.0f, 2.0f, 3.0f));
|
|
- coreOffsetBox(&box, CV3(7.0f, -4.0f, 6.0f));
|
|
+ offsetBox(&box, CV3(7.0f, -4.0f, 6.0f));
|
|
char buffer[128];
|
|
char buffer[128];
|
|
- coreToStringBox(&box, buffer, sizeof(buffer));
|
|
+ toString(&box, buffer, sizeof(buffer));
|
|
- CORE_TEST_STRING("Box([7.000, -4.000, 6.000], [8.000, -2.000, 9.000])",
|
|
+ TEST_STRING("Box([7.000, -4.000, 6.000], [8.000, -2.000, 9.000])", buffer);
|
|
- buffer);
|
|
|
|
}
|
|
}
|
|
|
|
|
|
static void testCollidesWith() {
|
|
static void testCollidesWith() {
|
|
- CoreBox boxA = CORE_BOX;
|
|
+ CoreBox boxA = BOX;
|
|
- coreSetBox(&boxA, CV3(1.0f, 2.0f, 3.0f));
|
|
+ setBox(&boxA, CV3(1.0f, 2.0f, 3.0f));
|
|
- CoreBox boxB = CORE_BOX;
|
|
+ CoreBox boxB = BOX;
|
|
- coreSetBox(&boxB, CV3(-1.0f, -2.0f, -3.0f));
|
|
+ setBox(&boxB, CV3(-1.0f, -2.0f, -3.0f));
|
|
- CoreBox boxC = CORE_BOX;
|
|
+ CoreBox boxC = BOX;
|
|
- coreSetBox(&boxC, CV3(2.0f, 2.0f, 2.0f));
|
|
+ setBox(&boxC, CV3(2.0f, 2.0f, 2.0f));
|
|
- coreOffsetBox(&boxC, CV3(-1.0f, -1.0f, -1.0f));
|
|
+ offsetBox(&boxC, CV3(-1.0f, -1.0f, -1.0f));
|
|
|
|
|
|
- CORE_TEST_TRUE(coreCollidesWithBox(&boxC, &boxA));
|
|
+ TEST_TRUE(collidesWithBox(&boxC, &boxA));
|
|
- CORE_TEST_TRUE(coreCollidesWithBox(&boxC, &boxB));
|
|
+ TEST_TRUE(collidesWithBox(&boxC, &boxB));
|
|
- CORE_TEST_TRUE(coreCollidesWithBox(&boxA, &boxC));
|
|
+ TEST_TRUE(collidesWithBox(&boxA, &boxC));
|
|
- CORE_TEST_TRUE(coreCollidesWithBox(&boxB, &boxC));
|
|
+ TEST_TRUE(collidesWithBox(&boxB, &boxC));
|
|
- CORE_TEST_FALSE(coreCollidesWithBox(&boxA, &boxB));
|
|
+ TEST_FALSE(collidesWithBox(&boxA, &boxB));
|
|
- CORE_TEST_FALSE(coreCollidesWithBox(&boxB, &boxA));
|
|
+ TEST_FALSE(collidesWithBox(&boxB, &boxA));
|
|
}
|
|
}
|
|
|
|
|
|
static void testExpand() {
|
|
static void testExpand() {
|
|
- CoreBox box = CORE_BOX;
|
|
+ CoreBox box = BOX;
|
|
- coreSetBox(&box, CV3(1.0f, 2.0f, 3.0f));
|
|
+ setBox(&box, CV3(1.0f, 2.0f, 3.0f));
|
|
- coreExpandBox(&box, CV3(7.0f, -4.0f, 6.0f));
|
|
+ expandBox(&box, CV3(7.0f, -4.0f, 6.0f));
|
|
|
|
|
|
char buffer[128];
|
|
char buffer[128];
|
|
- coreToStringBox(&box, buffer, sizeof(buffer));
|
|
+ toString(&box, buffer, sizeof(buffer));
|
|
- CORE_TEST_STRING("Box([0.000, -4.000, 0.000], [8.000, 2.000, 9.000])",
|
|
+ TEST_STRING("Box([0.000, -4.000, 0.000], [8.000, 2.000, 9.000])", buffer);
|
|
- buffer);
|
|
|
|
|
|
|
|
- coreSetBox(&box, CV3(1.0f, 2.0f, 3.0f));
|
|
+ setBox(&box, CV3(1.0f, 2.0f, 3.0f));
|
|
- coreExpandBox(&box, CV3(-7.0f, 4.0f, -6.0f));
|
|
+ expandBox(&box, CV3(-7.0f, 4.0f, -6.0f));
|
|
- coreToStringBox(&box, buffer, sizeof(buffer));
|
|
+ toString(&box, buffer, sizeof(buffer));
|
|
- CORE_TEST_STRING("Box([-7.000, 0.000, -6.000], [1.000, 6.000, 3.000])",
|
|
+ TEST_STRING("Box([-7.000, 0.000, -6.000], [1.000, 6.000, 3.000])", buffer);
|
|
- buffer);
|
|
|
|
}
|
|
}
|
|
|
|
|
|
static void testGrow() {
|
|
static void testGrow() {
|
|
- CoreBox box = CORE_BOX;
|
|
+ CoreBox box = BOX;
|
|
- coreSetBox(&box, CV3(1.0f, 2.0f, 3.0f));
|
|
+ setBox(&box, CV3(1.0f, 2.0f, 3.0f));
|
|
- coreGrowBox(&box, CV3(4.0f, 2.0f, 6.0f));
|
|
+ growBox(&box, CV3(4.0f, 2.0f, 6.0f));
|
|
char buffer[128];
|
|
char buffer[128];
|
|
- coreToStringBox(&box, buffer, sizeof(buffer));
|
|
+ toString(&box, buffer, sizeof(buffer));
|
|
- CORE_TEST_STRING("Box([-2.000, -1.000, -3.000], [3.000, 3.000, 6.000])",
|
|
+ TEST_STRING("Box([-2.000, -1.000, -3.000], [3.000, 3.000, 6.000])", buffer);
|
|
- buffer);
|
|
|
|
|
|
|
|
- coreSetBox(&box, CV3(1.0f, 2.0f, 3.0f));
|
|
+ setBox(&box, CV3(1.0f, 2.0f, 3.0f));
|
|
- coreGrowBox(&box, CV3(-4.0f, -2.0f, -6.0f));
|
|
+ growBox(&box, CV3(-4.0f, -2.0f, -6.0f));
|
|
- coreToStringBox(&box, buffer, sizeof(buffer));
|
|
+ toString(&box, buffer, sizeof(buffer));
|
|
- CORE_TEST_STRING("Box([0.500, 1.000, 1.500], [0.500, 1.000, 1.500])",
|
|
+ TEST_STRING("Box([0.500, 1.000, 1.500], [0.500, 1.000, 1.500])", buffer);
|
|
- buffer);
|
|
|
|
|
|
|
|
- coreSetBox(&box, CV3(1.0f, 2.0f, 3.0f));
|
|
+ setBox(&box, CV3(1.0f, 2.0f, 3.0f));
|
|
- coreGrowBox(&box, CV3(-0.1f, -4.0f, -1.0f));
|
|
+ growBox(&box, CV3(-0.1f, -4.0f, -1.0f));
|
|
- coreToStringBox(&box, buffer, sizeof(buffer));
|
|
+ toString(&box, buffer, sizeof(buffer));
|
|
- CORE_TEST_STRING("Box([0.050, 1.000, 0.500], [0.950, 1.000, 2.500])",
|
|
+ TEST_STRING("Box([0.050, 1.000, 0.500], [0.950, 1.000, 2.500])", buffer);
|
|
- buffer);
|
|
|
|
}
|
|
}
|
|
|
|
|
|
void testBox() {
|
|
void testBox() {
|