From c900adfe32ccd912fd57803217c8d7d3b5bab864 Mon Sep 17 00:00:00 2001 From: Jesse Talavera-Greenberg Date: Thu, 1 Oct 2015 19:45:26 -0400 Subject: [PATCH] Add tests for the functionality I implemented --- test/gtx/gtx_intersect.cpp | 14 ++++++++++++++ test/gtx/gtx_vector_query.cpp | 10 ++++++++++ 2 files changed, 24 insertions(+) diff --git a/test/gtx/gtx_intersect.cpp b/test/gtx/gtx_intersect.cpp index 10217cd0..83401913 100644 --- a/test/gtx/gtx_intersect.cpp +++ b/test/gtx/gtx_intersect.cpp @@ -57,12 +57,26 @@ int test_LineLineProper() { return Error; } +int test_overlapSegment() { + int Error(0); + + Error += !overlapSegment(vec2(0, 1), vec2(2, 1), vec2(1, 1), vec2(1, 2)) ? 0 : 1; + Error += !overlapSegment(vec2(0, 1), vec2(2, 1), vec2(1, 2), vec2(1, 1)) ? 0 : 1; + Error += !overlapSegment(vec2(0, 0), vec2(0, 1), vec2(0, 1), vec2(0, 2)) ? 0 : 1; + Error += overlapSegment(vec2(0, 0), vec2(0, 1), vec2(0, 0.5), vec2(0, 2)) ? 0 : 1; + Error += overlapSegment(vec2(0.5, 1), vec2(2, 2.5), vec2(1, 1.5), vec2(1.5, 2)) ? 0 : 1; + Error += !overlapSegment(vec2(0.5, 1), vec2(2, 2.5), vec2(1, 1.51), vec2(1.5, 2)) ? 0 : 1; + + return Error; +} + int main() { int Error(0); Error += test_LineLine(); Error += test_LineLineProper(); + Error += test_overlapSegment(); return Error; } diff --git a/test/gtx/gtx_vector_query.cpp b/test/gtx/gtx_vector_query.cpp index 7668c152..2d74ed8b 100644 --- a/test/gtx/gtx_vector_query.cpp +++ b/test/gtx/gtx_vector_query.cpp @@ -55,6 +55,16 @@ int test_areCollinear() Error += TestA ? 0 : 1; } + { + bool TestA = glm::areCollinear(glm::vec2(0, 0), glm::vec2(1, 1), glm::vec2(2, 2)); + Error += TestA ? 0 : 1; + } + + { + bool TestA = glm::areCollinear(glm::vec2(0, 0), glm::vec2(1, 1), glm::vec2(4, 2)); + Error += !TestA ? 0 : 1; + } + return Error; }