From aeb877f76a77d7f12b6aea5264a1b9b976e4f3ac Mon Sep 17 00:00:00 2001 From: Tycho Date: Wed, 5 Feb 2014 11:06:57 -0800 Subject: Modified automatic test for boundingBox --- src/BoundingBox.cpp | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) (limited to 'src/BoundingBox.cpp') diff --git a/src/BoundingBox.cpp b/src/BoundingBox.cpp index 86d4546c7..94a22465c 100644 --- a/src/BoundingBox.cpp +++ b/src/BoundingBox.cpp @@ -11,7 +11,7 @@ -#if 0 +#if SELF_TEST /// A simple self-test that is executed on program start, used to verify bbox functionality class SelfTest @@ -30,18 +30,37 @@ public: Vector3d(1.999, 0, 1.5), Vector3d(1.999, 4, 1.5), // Should intersect at 0.25, face 0 (YM) Vector3d(2.001, 0, 1.5), Vector3d(2.001, 4, 1.5), // Should not intersect } ; + bool Results[] = {true,true,true,false,true,false}; + double LineCoeffs[] = {2,0.25,0.5,0,0.25,0}; + for (size_t i = 0; i < ARRAYCOUNT(LineDefs) / 2; i++) { double LineCoeff; - char Face; + eBlockFace Face; Vector3d Line1 = LineDefs[2 * i]; Vector3d Line2 = LineDefs[2 * i + 1]; bool res = cBoundingBox::CalcLineIntersection(Min, Max, Line1, Line2, LineCoeff, Face); - printf("LineIntersection({%.02f, %.02f, %.02f}, {%.02f, %.02f, %.02f}) -> %d, %.05f, %d\n", - Line1.x, Line1.y, Line1.z, - Line2.x, Line2.y, Line2.z, - res ? 1 : 0, LineCoeff, Face - ); + if (res != Results[i]) + { + printf("LineIntersection({%.02f, %.02f, %.02f}, {%.02f, %.02f, %.02f}) -> %d, %.05f, %d\n", + Line1.x, Line1.y, Line1.z, + Line2.x, Line2.y, Line2.z, + res ? 1 : 0, LineCoeff, Face + ); + abort(); + } + if (res) + { + if (LineCoeff != LineCoeffs[i]) + { + printf("LineIntersection({%.02f, %.02f, %.02f}, {%.02f, %.02f, %.02f}) -> %d, %.05f, %d\n", + Line1.x, Line1.y, Line1.z, + Line2.x, Line2.y, Line2.z, + res ? 1 : 0, LineCoeff, Face + ); + abort(); + } + } } // for i - LineDefs[] printf("BoundingBox selftest complete."); } -- cgit v1.2.3 From 374fecf61f94e8df6bf60ea49df265dd19859bf7 Mon Sep 17 00:00:00 2001 From: worktycho Date: Wed, 5 Feb 2014 20:13:37 +0000 Subject: Change Output to stderr --- src/BoundingBox.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src/BoundingBox.cpp') diff --git a/src/BoundingBox.cpp b/src/BoundingBox.cpp index 94a22465c..47b135688 100644 --- a/src/BoundingBox.cpp +++ b/src/BoundingBox.cpp @@ -1,4 +1,3 @@ - // BoundingBox.cpp // Implements the cBoundingBox class representing an axis-aligned bounding box with floatingpoint coords @@ -42,7 +41,7 @@ public: bool res = cBoundingBox::CalcLineIntersection(Min, Max, Line1, Line2, LineCoeff, Face); if (res != Results[i]) { - printf("LineIntersection({%.02f, %.02f, %.02f}, {%.02f, %.02f, %.02f}) -> %d, %.05f, %d\n", + fprintf(stderr,"LineIntersection({%.02f, %.02f, %.02f}, {%.02f, %.02f, %.02f}) -> %d, %.05f, %d\n", Line1.x, Line1.y, Line1.z, Line2.x, Line2.y, Line2.z, res ? 1 : 0, LineCoeff, Face @@ -53,7 +52,7 @@ public: { if (LineCoeff != LineCoeffs[i]) { - printf("LineIntersection({%.02f, %.02f, %.02f}, {%.02f, %.02f, %.02f}) -> %d, %.05f, %d\n", + fprintf(stderr,"LineIntersection({%.02f, %.02f, %.02f}, {%.02f, %.02f, %.02f}) -> %d, %.05f, %d\n", Line1.x, Line1.y, Line1.z, Line2.x, Line2.y, Line2.z, res ? 1 : 0, LineCoeff, Face @@ -62,7 +61,7 @@ public: } } } // for i - LineDefs[] - printf("BoundingBox selftest complete."); + fprintf(stderr,"BoundingBox selftest complete."); } } Test; -- cgit v1.2.3