Add tests for the functionality I implemented

This commit is contained in:
Jesse Talavera-Greenberg 2015-10-01 19:45:26 -04:00
parent 4b9b39f1db
commit c900adfe32
2 changed files with 24 additions and 0 deletions

View File

@ -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;
}

View File

@ -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;
}