Commit 0b2eae94 authored by Dennis Gläser's avatar Dennis Gläser
Browse files

[test][constraints] test violation event type

parent 28707a55
......@@ -16,6 +16,7 @@ int main()
using Point = typename Disk::Point;
using Direction = typename Disk::Direction;
using Vector = typename Direction::Vector;
using Violation = Frackit::ConstraintsEvaluation::Violation;
// Basis Vectors
const Vector e1(1.0, 0.0, 0.0);
......@@ -35,6 +36,8 @@ int main()
// violates distance constraint
Disk disk1(Point(0.0, 0.0, 0.5), e1, e2, 0.4+1e-5, 0.25);
if (constraints.evaluate(cylSurface, disk1))
throw std::runtime_error("False positive detected");
if (constraints.evaluate(cylSurface, disk1).violation() != Violation::distance)
throw std::runtime_error("Did not detect distance violation");
std::cout << "Test 1 passed" << std::endl;
......@@ -42,30 +45,40 @@ int main()
Disk disk2(Point(0.0, 0.0, 0.5), e1, e2, 0.4-1e-5, 0.25);
if (!constraints.evaluate(cylSurface, disk2))
throw std::runtime_error("False positive distance violation");
if (constraints.evaluate(cylSurface, disk2).violation() != Violation::none)
throw std::runtime_error("False positive distance violation");
std::cout << "Test 2 passed" << std::endl;
// violates the intersection magnitude constraint
Disk disk3(Point(0.4, 0.0, 0.5), e1, e2, 0.11, 0.05);
if (constraints.evaluate(cylSurface, disk3))
throw std::runtime_error("Did not detect intersection magnitude violation");
if (constraints.evaluate(cylSurface, disk3).violation() != Violation::intersectionMagnitude)
throw std::runtime_error("Did not detect intersection magnitude violation");
std::cout << "Test 3 passed" << std::endl;
// does not violate the intersection magnitude constraint
Disk disk4(Point(0.4, 0.0, 0.5), e1, e2, 0.5, 0.5);
if (!constraints.evaluate(cylSurface, disk4))
throw std::runtime_error("False positive intersection magnitude violation");
if (constraints.evaluate(cylSurface, disk4).violation() != Violation::none)
throw std::runtime_error("False positive intersection magnitude violation");
std::cout << "Test 4 passed" << std::endl;
// violates the distance to boundary constraint
Disk disk5(Point(0.4, 0.0, 0.95 + 1e-6), e1, e2, 0.5, 0.5);
if (constraints.evaluate(cylSurface, disk5))
throw std::runtime_error("Did not detect distance to boundary violation");
if (constraints.evaluate(cylSurface, disk5).violation() != Violation::intersectionDistance)
throw std::runtime_error("Did not detect distance to boundary violation");
std::cout << "Test 5 passed" << std::endl;
// does not violate the distance to boundary constraint
Disk disk6(Point(0.4, 0.0, 0.95 - 1e-6), e1, e2, 0.5, 0.5);
if (!constraints.evaluate(cylSurface, disk6))
throw std::runtime_error("False positive intersection magnitude violation");
if (constraints.evaluate(cylSurface, disk6).violation() != Violation::none)
throw std::runtime_error("False positive intersection magnitude violation");
std::cout << "Test 6 passed" << std::endl;
// violates the intersection angle constraint
......@@ -73,12 +86,16 @@ int main()
Disk disk7(Point(0.4, 0.0, 0.5), e12, e2, 0.5, 0.5);
if (constraints.evaluate(cylSurface, disk7))
throw std::runtime_error("Did not detect intersection angle violation");
if (constraints.evaluate(cylSurface, disk7).violation() != Violation::intersectionAngle)
throw std::runtime_error("Did not detect intersection angle violation");
std::cout << "Test 7 passed" << std::endl;
// does not violate the distance to boundary constraint
Disk disk8(Point(0.4, 0.0, 0.95 - 1e-6), e1, e2, 0.5, 0.5);
if (!constraints.evaluate(cylSurface, disk6))
throw std::runtime_error("False positive intersection magnitude violation");
if (constraints.evaluate(cylSurface, disk6).violation() != Violation::none)
throw std::runtime_error("False positive intersection magnitude violation");
std::cout << "Test 6 passed" << std::endl;
// TODO: Test elliptical intersection
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment