40 const bool AtoB = aSegA.
Collide( aSegB, aClearance );
41 const bool BtoA = aSegB.
Collide( aSegA, aClearance );
43 const bool ok = ( AtoB == aExp ) && ( BtoA == aExp );
48 ss <<
"Segment collision is not the same in both directions: expected " << aExp <<
", got "
49 << AtoB <<
" & " << BtoA;
55 ss <<
"Collision incorrect: expected " << aExp <<
", got " << AtoB;
72 const int AtoB = aSegA.
Distance( aSegB );
73 const int BtoA = aSegB.
Distance( aSegA );
75 bool ok = ( AtoB == aExp ) && ( BtoA == aExp );
80 ss <<
"Segment distance is not the same in both directions: expected " << aExp <<
", got "
81 << AtoB <<
" & " << BtoA;
87 ss <<
"Distance incorrect: expected " << aExp <<
", got " << AtoB;
106 const int dist = aSeg.
Distance( aVec );
108 bool ok = ( dist == aExp );
112 std::stringstream ss;
113 ss <<
"Distance incorrect: expected " << aExp <<
", got " << dist;
129 const bool AtoB = aSegA.
Collinear( aSegB );
130 const bool BtoA = aSegB.
Collinear( aSegA );
132 const bool ok = ( AtoB == aExp ) && ( BtoA == aExp );
136 std::stringstream ss;
137 ss <<
"Segment collinearity is not the same in both directions: expected " << aExp
138 <<
", got " << AtoB <<
" & " << BtoA;
143 std::stringstream ss;
144 ss <<
"Collinearity incorrect: expected " << aExp <<
", got " << AtoB;
164 const bool ok = ( AtoB == aExp ) && ( BtoA == aExp );
168 std::stringstream ss;
169 ss <<
"Segment parallelism is not the same in both directions: expected " << aExp
170 <<
", got AtoB: " << AtoB <<
" BtoA:" << BtoA;
175 std::stringstream ss;
176 ss <<
"Parallelism incorrect: expected " << aExp <<
", got " << AtoB;
196 const bool ok = ( AtoB == aExp ) && ( BtoA == aExp );
200 std::stringstream ss;
201 ss <<
"Segment perpendicularity is not the same in both directions: expected " << aExp
202 <<
", got AtoB: " << AtoB <<
" BtoA:" << BtoA;
207 std::stringstream ss;
208 ss <<
"Perpendicularity incorrect: expected " << aExp <<
", got " << AtoB;
227 SEG segment( pointA, pointB );
229 BOOST_CHECK_EQUAL( pointA,
VECTOR2I( 10, 20 ) );
230 BOOST_CHECK_EQUAL( pointB,
VECTOR2I( 100, 200 ) );
237 BOOST_CHECK_EQUAL( segment.
A,
VECTOR2I( 20, 30 ) );
238 BOOST_CHECK_EQUAL( segment.
B,
VECTOR2I( 200, 300 ) );
253 "Parallel, 10 apart",
254 { { 0, 0 }, { 10, 0 } },
255 { { 0, 10 }, { 10, 10 } },
259 "Non-parallel, 10 apart",
260 { { 0, -5 }, { 10, 0 } },
261 { { 0, 10 }, { 10, 10 } },
266 { { 0, 0 }, { 30, 0 } },
267 { { 10, 0 }, { 20, 0 } },
272 { { 0, -10 }, { 0, 10 } },
273 { { -20, 0 }, { 20, 0 } },
278 { { 0, -10 }, { 0, 10 } },
279 { { -20, 0 }, { 0, 0 } },
283 "T-junction (no touch)",
284 { { 0, -10 }, { 0, 10 } },
285 { { -20, 0 }, { -2, 0 } },
298 BOOST_CHECK_PREDICATE(
SegDistanceCorrect, ( c.m_seg_a )( c.m_seg_b )( c.m_exp_dist ) );
317 { { 0, 0 }, { 10, 0 } },
323 { { 0, 0 }, { 10, 0 } },
329 { { 0, 0 }, { 10, 0 } },
334 "At end (collinear)",
335 { { 0, 0 }, { 10, 0 } },
340 "At end (not collinear)",
341 { { 0, 0 }, { 1000, 0 } },
378 "Parallel, 10 apart, 5 clear",
379 { { 0, 0 }, { 10, 0 } },
380 { { 0, 10 }, { 10, 10 } },
385 "Parallel, 10 apart, 10 clear",
386 { { 0, 0 }, { 10, 0 } },
387 { { 0, 10 }, { 10, 10 } },
392 "Parallel, 10 apart, 11 clear",
393 { { 0, 0 }, { 10, 0 } },
394 { { 0, 10 }, { 10, 10 } },
399 "T-junction, 2 apart, 2 clear",
400 { { 0, -10 }, { 0, 0 } },
401 { { -20, 0 }, { -2, 0 } },
406 "T-junction, 2 apart, 3 clear",
407 { { 0, -10 }, { 0, 0 } },
408 { { -20, 0 }, { -2, 0 } },
423 ( c.m_seg_a )( c.m_seg_b )( c.m_clearance )( c.m_exp_coll ) );
447 { { 0, 0 }, { 10, 0 } },
448 { { 0, 0 }, { 10, 0 } },
453 { { 0, 0 }, { 10, 0 } },
454 { { 10, 0 }, { 20, 0 } },
459 { { 0, 0 }, { 10, 0 } },
460 { { 4, 0 }, { 7, 0 } },
465 { { 0, 0 }, { 10, 0 } },
466 { { 4, 1 }, { 7, 1 } },
471 { { 0, 0 }, { 10, 0 } },
472 { { 5, -5 }, { 5, 5 } },
486 ( c.m_seg_a )( c.m_seg_b )( c.m_exp_result ) );
499 { { 0, 0 }, { 10, 0 } },
500 { { 0, 0 }, { 10, 0 } },
505 { { 0, 0 }, { 10, 0 } },
506 { { 10, 0 }, { 20, 0 } },
511 { { 0, 0 }, { 10, 0 } },
512 { { 4, 0 }, { 7, 0 } },
517 { { 0, 0 }, { 10, 0 } },
518 { { 4, 1 }, { 7, 1 } },
523 { { 0, 0 }, { 10, 0 } },
524 { { 5, -5 }, { 5, 5 } },
538 ( c.m_seg_a )( c.m_seg_b )( c.m_exp_result ) );
551 { { 0, 0 }, { 10, 0 } },
552 { { 0, 0 }, { 10, 0 } },
557 { { 0, 0 }, { 10, 0 } },
558 { { 10, 0 }, { 20, 0 } },
563 { { 0, 0 }, { 10, 0 } },
564 { { 4, 0 }, { 7, 0 } },
569 { { 0, 0 }, { 10, 0 } },
570 { { 4, 1 }, { 7, 1 } },
575 { { 0, 0 }, { 10, 0 } },
576 { { 0, 0 }, { 5, 5 } },
580 "very nearly perpendicular",
581 { { 0, 0 }, { 10, 0 } },
582 { { 0, 0 }, { 1, 10 } },
586 "not really perpendicular",
587 { { 0, 0 }, { 10, 0 } },
588 { { 0, 0 }, { 3, 10 } },
593 { { 0, 0 }, { 10, 0 } },
594 { { 0, 0 }, { 0, 10 } },
598 "perpendicular not intersecting",
599 { { 0, 0 }, { 10, 0 } },
600 { { 15, 5 }, { 15, 10 } },
614 ( c.m_seg_a )( c.m_seg_b )( c.m_exp_result ) );
637 "Horizontal: point on edge of seg",
638 { { 0, 0 }, { 10, 0 } },
642 "Horizontal: point in middle of seg",
643 { { 0, 0 }, { 10, 0 } },
647 "Horizontal: point outside seg",
648 { { 0, 0 }, { 10, 0 } },
652 "Vertical: point on edge of seg",
653 { { 0, 0 }, { 0, 10 } },
657 "Vertical: point in middle of seg",
658 { { 0, 0 }, { 0, 10 } },
662 "Vertical: point outside seg",
663 { { 0, 0 }, { 0, 10 } },
698BOOST_AUTO_TEST_SUITE_END()
bool Collide(const SEG &aSeg, int aClearance, int *aActual=nullptr) const
bool ApproxParallel(const SEG &aSeg, int aDistanceThreshold=1) const
bool Collinear(const SEG &aSeg) const
Check if segment aSeg lies on the same line as (this).
SEG ParallelSeg(const VECTOR2I &aP) const
Compute a segment parallel to this one, passing through point aP.
bool ApproxPerpendicular(const SEG &aSeg) const
int Distance(const SEG &aSeg) const
Compute minimum Euclidean distance to segment aSeg.
SEG PerpendicularSeg(const VECTOR2I &aP) const
Compute a segment perpendicular to this one, passing through point aP.
Struct to hold general cases for collinearity, parallelism and perpendicularity.
Test cases for collisions (with clearance, for no clearance, it's just a SEG_SEG_DISTANCE_CASE of 0)
Struct to hold cases for operations with a SEG, and a VECTOR2I.
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
static const std::vector< SEG_SEG_BOOLEAN_CASE > seg_vec_perpendicular_cases
Test cases for perpendicularity.
BOOST_AUTO_TEST_CASE(EndpointCtorMod)
Checks whether the construction of a segment referencing external points works and that the endpoints...
static const std::vector< SEG_SEG_BOOLEAN_CASE > seg_vec_collinear_cases
Test cases for collinearity.
static const std::vector< SEG_VEC_CASE > segment_and_point_cases
Test cases to create segments passing through a point.
static const std::vector< SEG_SEG_DISTANCE_CASE > seg_seg_dist_cases
bool SegDistanceCorrect(const SEG &aSegA, const SEG &aSegB, int aExp)
Predicate to check expected distance between two segments.
static const std::vector< SEG_VECTOR_DISTANCE_CASE > seg_vec_dist_cases
bool SegParallelCorrect(const SEG &aSegA, const SEG &aSegB, bool aExp)
Predicate to check expected parallelism between two segments.
bool SegCollideCorrect(const SEG &aSegA, const SEG &aSegB, int aClearance, bool aExp)
Predicate to check expected collision between two segments.
static const std::vector< SEG_SEG_COLLIDE_CASE > seg_seg_coll_cases
bool SegVecDistanceCorrect(const SEG &aSeg, const VECTOR2I &aVec, int aExp)
Predicate to check expected distance between a segment and a point.
bool SegPerpendicularCorrect(const SEG &aSegA, const SEG &aSegB, bool aExp)
Predicate to check expected perpendicularity between two segments.
static const std::vector< SEG_SEG_BOOLEAN_CASE > seg_vec_parallel_cases
Test cases for parallelism.
bool SegCollinearCorrect(const SEG &aSegA, const SEG &aSegB, bool aExp)
Predicate to check expected collision between two segments.
#define BOOST_TEST_CONTEXT(A)
#define BOOST_TEST_INFO(A)
If HAVE_EXPECTED_FAILURES is defined, this means that boost::unit_test::expected_failures is availabl...