KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_segment.cpp File Reference
#include <qa_utils/wx_utils/unit_test_utils.h>
#include <boost/test/data/test_case.hpp>
#include <geometry/seg.h>

Go to the source code of this file.

Classes

struct  SEG_SEG_DISTANCE_CASE
 
struct  SEG_VECTOR_DISTANCE_CASE
 
struct  SEG_SEG_COLLIDE_CASE
 Test cases for collisions (with clearance, for no clearance, it's just a SEG_SEG_DISTANCE_CASE of 0) More...
 
struct  SEG_SEG_BOOLEAN_CASE
 Struct to hold general cases for collinearity, parallelism and perpendicularity. More...
 
struct  SEG_VEC_CASE
 Struct to hold cases for operations with a SEG, and a VECTOR2I. More...
 
struct  SEG_SEG_INTERSECT_CASE
 Test cases for segment intersection. More...
 
struct  SEG_LINE_INTERSECT_CASE
 Test cases for segment-line intersection. More...
 

Functions

 BOOST_AUTO_TEST_CASE (EndpointCtorMod)
 Checks whether the construction of a segment referencing external points works and that the endpoints can be modified as normal points.
 
 BOOST_DATA_TEST_CASE (SegSegPerpendicular, boost::unit_test::data::make(seg_vec_perpendicular_cases), c)
 
 BOOST_DATA_TEST_CASE (SegCreateParallel, boost::unit_test::data::make(segment_and_point_cases), c)
 
 BOOST_DATA_TEST_CASE (SegCreatePerpendicular, boost::unit_test::data::make(segment_and_point_cases), c)
 
 BOOST_AUTO_TEST_CASE (LineDistance)
 
 BOOST_AUTO_TEST_CASE (LineDistanceSided)
 
bool SegIntersectCorrect (const SEG_SEG_INTERSECT_CASE &aCase)
 Predicate to check expected intersection between two segments.
 
 BOOST_AUTO_TEST_CASE (IntersectLargeCoordinates)
 
 BOOST_AUTO_TEST_CASE (IntersectOverflowDetection)
 
 BOOST_AUTO_TEST_CASE (IntersectPrecisionEdgeCases)
 
 BOOST_AUTO_TEST_CASE (IntersectIgnoreEndpointsEdgeCases)
 
 BOOST_AUTO_TEST_CASE (IntersectCollinearRegressionTests)
 
 BOOST_AUTO_TEST_CASE (IntersectBoundingBoxOptimization)
 
 BOOST_AUTO_TEST_CASE (IntersectLineVsSegmentMode)
 
 BOOST_AUTO_TEST_CASE (IntersectNumericalStability)
 
 BOOST_AUTO_TEST_CASE (IntersectZeroLengthSegments)
 
bool SegLineIntersectCorrect (const SEG &aSeg, double aSlope, double aOffset, bool aExpIntersect, const VECTOR2I &aExpPoint=VECTOR2I())
 Predicate to check expected intersection between a segment and an infinite line.
 
 BOOST_AUTO_TEST_CASE (IntersectLineVerticalSegments)
 
 BOOST_AUTO_TEST_CASE (IntersectLineVerticalSegmentsCorrection)
 
 BOOST_AUTO_TEST_CASE (IntersectLineParallelDetection)
 
 BOOST_AUTO_TEST_CASE (IntersectLinePrecisionEdgeCases)
 
 BOOST_AUTO_TEST_CASE (IntersectLineZeroLengthSegments)
 

Variables

static const std::vector< SEG_SEG_DISTANCE_CASEseg_seg_dist_cases
 
static const std::vector< SEG_VECTOR_DISTANCE_CASEseg_vec_dist_cases
 
static const std::vector< SEG_SEG_COLLIDE_CASEseg_seg_coll_cases
 
static const std::vector< SEG_SEG_BOOLEAN_CASEseg_vec_collinear_cases
 Test cases for collinearity.
 
static const std::vector< SEG_SEG_BOOLEAN_CASEseg_vec_parallel_cases
 Test cases for parallelism.
 
static const std::vector< SEG_SEG_BOOLEAN_CASEseg_vec_perpendicular_cases
 Test cases for perpendicularity.
 
static const std::vector< SEG_VEC_CASEsegment_and_point_cases
 Test cases to create segments passing through a point.
 
static const std::vector< SEG_SEG_INTERSECT_CASEseg_intersect_cases
 
static const std::vector< SEG_LINE_INTERSECT_CASEseg_line_intersect_cases
 

Function Documentation

◆ BOOST_AUTO_TEST_CASE() [1/17]

BOOST_AUTO_TEST_CASE ( EndpointCtorMod  )

Checks whether the construction of a segment referencing external points works and that the endpoints can be modified as normal points.

Definition at line 230 of file test_segment.cpp.

References SEG::A, SEG::B, and BOOST_CHECK_EQUAL().

◆ BOOST_AUTO_TEST_CASE() [2/17]

BOOST_AUTO_TEST_CASE ( IntersectBoundingBoxOptimization  )

Definition at line 1099 of file test_segment.cpp.

References BOOST_CHECK_EQUAL(), and SEG::Intersect().

◆ BOOST_AUTO_TEST_CASE() [3/17]

BOOST_AUTO_TEST_CASE ( IntersectCollinearRegressionTests  )

Definition at line 1044 of file test_segment.cpp.

References BOOST_CHECK_EQUAL(), and SEG::Intersect().

◆ BOOST_AUTO_TEST_CASE() [4/17]

BOOST_AUTO_TEST_CASE ( IntersectIgnoreEndpointsEdgeCases  )

Definition at line 1017 of file test_segment.cpp.

References BOOST_CHECK_EQUAL(), and SEG::Intersect().

◆ BOOST_AUTO_TEST_CASE() [5/17]

BOOST_AUTO_TEST_CASE ( IntersectLargeCoordinates  )

Definition at line 971 of file test_segment.cpp.

References BOOST_CHECK_EQUAL(), and SEG::Intersect().

◆ BOOST_AUTO_TEST_CASE() [6/17]

BOOST_AUTO_TEST_CASE ( IntersectLineParallelDetection  )

Definition at line 1500 of file test_segment.cpp.

References BOOST_CHECK_EQUAL(), and SEG::IntersectsLine().

◆ BOOST_AUTO_TEST_CASE() [7/17]

BOOST_AUTO_TEST_CASE ( IntersectLinePrecisionEdgeCases  )

Definition at line 1530 of file test_segment.cpp.

References BOOST_CHECK_EQUAL(), and SEG::IntersectsLine().

◆ BOOST_AUTO_TEST_CASE() [8/17]

BOOST_AUTO_TEST_CASE ( IntersectLineVerticalSegments  )

Definition at line 1463 of file test_segment.cpp.

References BOOST_CHECK_EQUAL().

◆ BOOST_AUTO_TEST_CASE() [9/17]

BOOST_AUTO_TEST_CASE ( IntersectLineVerticalSegmentsCorrection  )

Definition at line 1484 of file test_segment.cpp.

References BOOST_CHECK_EQUAL().

◆ BOOST_AUTO_TEST_CASE() [10/17]

BOOST_AUTO_TEST_CASE ( IntersectLineVsSegmentMode  )

Definition at line 1126 of file test_segment.cpp.

References BOOST_CHECK_EQUAL(), and SEG::Intersect().

◆ BOOST_AUTO_TEST_CASE() [11/17]

BOOST_AUTO_TEST_CASE ( IntersectLineZeroLengthSegments  )

Definition at line 1555 of file test_segment.cpp.

References BOOST_CHECK_EQUAL(), and SEG::IntersectsLine().

◆ BOOST_AUTO_TEST_CASE() [12/17]

BOOST_AUTO_TEST_CASE ( IntersectNumericalStability  )

Definition at line 1155 of file test_segment.cpp.

References BOOST_CHECK_EQUAL(), and SEG::Intersect().

◆ BOOST_AUTO_TEST_CASE() [13/17]

BOOST_AUTO_TEST_CASE ( IntersectOverflowDetection  )

Definition at line 984 of file test_segment.cpp.

References BOOST_TEST_MESSAGE(), and SEG::Intersect().

◆ BOOST_AUTO_TEST_CASE() [14/17]

BOOST_AUTO_TEST_CASE ( IntersectPrecisionEdgeCases  )

Definition at line 1003 of file test_segment.cpp.

References BOOST_CHECK_EQUAL(), and SEG::Intersect().

◆ BOOST_AUTO_TEST_CASE() [15/17]

BOOST_AUTO_TEST_CASE ( IntersectZeroLengthSegments  )

Definition at line 1186 of file test_segment.cpp.

References BOOST_CHECK_EQUAL(), and SEG::Intersect().

◆ BOOST_AUTO_TEST_CASE() [16/17]

BOOST_AUTO_TEST_CASE ( LineDistance  )

Definition at line 672 of file test_segment.cpp.

References BOOST_TEST().

◆ BOOST_AUTO_TEST_CASE() [17/17]

BOOST_AUTO_TEST_CASE ( LineDistanceSided  )

Definition at line 680 of file test_segment.cpp.

References BOOST_TEST().

◆ BOOST_DATA_TEST_CASE() [1/3]

BOOST_DATA_TEST_CASE ( SegCreateParallel  ,
boost::unit_test::data::make(segment_and_point_cases ,
 
)

Definition at line 654 of file test_segment.cpp.

References BOOST_CHECK_PREDICATE(), and SEG::ParallelSeg().

◆ BOOST_DATA_TEST_CASE() [2/3]

BOOST_DATA_TEST_CASE ( SegCreatePerpendicular  ,
boost::unit_test::data::make(segment_and_point_cases ,
 
)

Definition at line 663 of file test_segment.cpp.

References BOOST_CHECK_PREDICATE(), and SEG::PerpendicularSeg().

◆ BOOST_DATA_TEST_CASE() [3/3]

BOOST_DATA_TEST_CASE ( SegSegPerpendicular  ,
boost::unit_test::data::make(seg_vec_perpendicular_cases ,
 
)

Definition at line 598 of file test_segment.cpp.

References BOOST_CHECK_PREDICATE().

◆ SegIntersectCorrect()

bool SegIntersectCorrect ( const SEG_SEG_INTERSECT_CASE aCase)

Predicate to check expected intersection between two segments.

Parameters
aCasethe test case containing all parameters
Returns
does the intersection calculated agree?

Definition at line 902 of file test_segment.cpp.

References std::abs(), VECTOR2< T >::Format(), SEG::Intersect(), SEG_SEG_INTERSECT_CASE::m_exp_intersect, SEG_SEG_INTERSECT_CASE::m_exp_point, SEG_SEG_INTERSECT_CASE::m_ignore_endpoints, SEG_SEG_INTERSECT_CASE::m_lines, SEG_SEG_INTERSECT_CASE::m_seg_a, SEG_SEG_INTERSECT_CASE::m_seg_b, VECTOR2< T >::x, and VECTOR2< T >::y.

◆ SegLineIntersectCorrect()

bool SegLineIntersectCorrect ( const SEG aSeg,
double  aSlope,
double  aOffset,
bool  aExpIntersect,
const VECTOR2I aExpPoint = VECTOR2I() 
)

Predicate to check expected intersection between a segment and an infinite line.

Parameters
aSegthe segment
aSlopethe line slope
aOffsetthe line y-intercept
aExpIntersectexpected intersection result
aExpPointexpected intersection point (if intersection occurs)
Returns
does the intersection calculated agree?

Definition at line 1250 of file test_segment.cpp.

References std::abs(), VECTOR2< T >::Format(), SEG::IntersectsLine(), VECTOR2< T >::x, and VECTOR2< T >::y.

Variable Documentation

◆ seg_intersect_cases

const std::vector<SEG_SEG_INTERSECT_CASE> seg_intersect_cases
static

Definition at line 702 of file test_segment.cpp.

◆ seg_line_intersect_cases

const std::vector<SEG_LINE_INTERSECT_CASE> seg_line_intersect_cases
static

Definition at line 1288 of file test_segment.cpp.

◆ seg_seg_coll_cases

const std::vector<SEG_SEG_COLLIDE_CASE> seg_seg_coll_cases
static

Definition at line 388 of file test_segment.cpp.

◆ seg_seg_dist_cases

const std::vector<SEG_SEG_DISTANCE_CASE> seg_seg_dist_cases
static

Definition at line 259 of file test_segment.cpp.

◆ seg_vec_collinear_cases

const std::vector<SEG_SEG_BOOLEAN_CASE> seg_vec_collinear_cases
static

Test cases for collinearity.

Definition at line 449 of file test_segment.cpp.

◆ seg_vec_dist_cases

const std::vector<SEG_VECTOR_DISTANCE_CASE> seg_vec_dist_cases
static

Definition at line 315 of file test_segment.cpp.

◆ seg_vec_parallel_cases

const std::vector<SEG_SEG_BOOLEAN_CASE> seg_vec_parallel_cases
static

Test cases for parallelism.

Definition at line 494 of file test_segment.cpp.

◆ seg_vec_perpendicular_cases

const std::vector<SEG_SEG_BOOLEAN_CASE> seg_vec_perpendicular_cases
static

Test cases for perpendicularity.

Definition at line 539 of file test_segment.cpp.

◆ segment_and_point_cases

const std::vector<SEG_VEC_CASE> segment_and_point_cases
static

Test cases to create segments passing through a point.

Definition at line 619 of file test_segment.cpp.