KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_segment.cpp File Reference

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...
 

Functions

bool SegCollideCorrect (const SEG &aSegA, const SEG &aSegB, int aClearance, bool aExp)
 Predicate to check expected collision between two segments.
 
bool SegDistanceCorrect (const SEG &aSegA, const SEG &aSegB, int aExp)
 Predicate to check expected distance between two segments.
 
bool SegVecDistanceCorrect (const SEG &aSeg, const VECTOR2I &aVec, int aExp)
 Predicate to check expected distance between a segment and a point.
 
bool SegCollinearCorrect (const SEG &aSegA, const SEG &aSegB, bool aExp)
 Predicate to check expected collision between two segments.
 
bool SegParallelCorrect (const SEG &aSegA, const SEG &aSegB, bool aExp)
 Predicate to check expected parallelism between two segments.
 
bool SegPerpendicularCorrect (const SEG &aSegA, const SEG &aSegB, bool aExp)
 Predicate to check expected perpendicularity between two segments.
 
 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_AUTO_TEST_CASE (SegSegDistance)
 
 BOOST_AUTO_TEST_CASE (SegVecDistance)
 
 BOOST_AUTO_TEST_CASE (SegSegCollision)
 
 BOOST_AUTO_TEST_CASE (SegSegCollinear)
 
 BOOST_AUTO_TEST_CASE (SegSegParallel)
 
 BOOST_AUTO_TEST_CASE (SegSegPerpendicular)
 
 BOOST_AUTO_TEST_CASE (SegCreateParallel)
 
 BOOST_AUTO_TEST_CASE (SegCreatePerpendicular)
 
 BOOST_AUTO_TEST_CASE (LineDistance)
 
 BOOST_AUTO_TEST_CASE (LineDistanceSided)
 

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.
 

Function Documentation

◆ BOOST_AUTO_TEST_CASE() [1/11]

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 224 of file test_segment.cpp.

References SEG::A, and SEG::B.

◆ BOOST_AUTO_TEST_CASE() [2/11]

BOOST_AUTO_TEST_CASE ( LineDistance  )

Definition at line 719 of file test_segment.cpp.

References BOOST_TEST().

◆ BOOST_AUTO_TEST_CASE() [3/11]

BOOST_AUTO_TEST_CASE ( LineDistanceSided  )

Definition at line 727 of file test_segment.cpp.

References BOOST_TEST().

◆ BOOST_AUTO_TEST_CASE() [4/11]

BOOST_AUTO_TEST_CASE ( SegCreateParallel  )

◆ BOOST_AUTO_TEST_CASE() [5/11]

BOOST_AUTO_TEST_CASE ( SegCreatePerpendicular  )

◆ BOOST_AUTO_TEST_CASE() [6/11]

BOOST_AUTO_TEST_CASE ( SegSegCollinear  )

Definition at line 500 of file test_segment.cpp.

References seg_vec_collinear_cases, and SegCollinearCorrect().

◆ BOOST_AUTO_TEST_CASE() [7/11]

BOOST_AUTO_TEST_CASE ( SegSegCollision  )

Definition at line 437 of file test_segment.cpp.

References seg_seg_coll_cases, and SegCollideCorrect().

◆ BOOST_AUTO_TEST_CASE() [8/11]

BOOST_AUTO_TEST_CASE ( SegSegDistance  )

Definition at line 295 of file test_segment.cpp.

References seg_seg_dist_cases, and SegDistanceCorrect().

◆ BOOST_AUTO_TEST_CASE() [9/11]

BOOST_AUTO_TEST_CASE ( SegSegParallel  )

Definition at line 552 of file test_segment.cpp.

References seg_vec_parallel_cases, and SegParallelCorrect().

◆ BOOST_AUTO_TEST_CASE() [10/11]

BOOST_AUTO_TEST_CASE ( SegSegPerpendicular  )

Definition at line 628 of file test_segment.cpp.

References seg_vec_perpendicular_cases, and SegPerpendicularCorrect().

◆ BOOST_AUTO_TEST_CASE() [11/11]

BOOST_AUTO_TEST_CASE ( SegVecDistance  )

Definition at line 370 of file test_segment.cpp.

References seg_vec_dist_cases, and SegVecDistanceCorrect().

◆ SegCollideCorrect()

bool SegCollideCorrect ( const SEG aSegA,
const SEG aSegB,
int  aClearance,
bool  aExp 
)

Predicate to check expected collision between two segments.

Parameters
aSegAthe first SEG
aSegBthe second SEG
aClearancethe collision clearance
aExpexpected collision
Returns
does the distance calculated agree?

Definition at line 38 of file test_segment.cpp.

References SEG::Collide().

Referenced by BOOST_AUTO_TEST_CASE(), and SegDistanceCorrect().

◆ SegCollinearCorrect()

bool SegCollinearCorrect ( const SEG aSegA,
const SEG aSegB,
bool  aExp 
)

Predicate to check expected collision between two segments.

Parameters
aSegAthe first SEG
sSegBthe second SEG
aExpexpected collinearity
Returns
does the collinearity calculated agree?

Definition at line 130 of file test_segment.cpp.

References SEG::Collinear().

Referenced by BOOST_AUTO_TEST_CASE().

◆ SegDistanceCorrect()

bool SegDistanceCorrect ( const SEG aSegA,
const SEG aSegB,
int  aExp 
)

Predicate to check expected distance between two segments.

Parameters
aSegAthe first SEG
aSegBthe second SEG
aExpexpected distance
Returns
does the distance calculated agree?

Definition at line 70 of file test_segment.cpp.

References SEG::Distance(), and SegCollideCorrect().

Referenced by BOOST_AUTO_TEST_CASE().

◆ SegParallelCorrect()

bool SegParallelCorrect ( const SEG aSegA,
const SEG aSegB,
bool  aExp 
)

Predicate to check expected parallelism between two segments.

Parameters
aSegAthe first SEG
sSegBthe second SEG
aExpexpected parallelism: true = segments are parallel false = segments are not parallel
Returns
does the parallelism calculated agree?

Definition at line 162 of file test_segment.cpp.

References SEG::ApproxParallel().

Referenced by BOOST_AUTO_TEST_CASE().

◆ SegPerpendicularCorrect()

bool SegPerpendicularCorrect ( const SEG aSegA,
const SEG aSegB,
bool  aExp 
)

Predicate to check expected perpendicularity between two segments.

Parameters
aSegAthe first SEG
sSegBthe second SEG
aExpexpected perpendicularity: true = segments are perpendicular false = segments are not perpendicular
Returns
does the perpendicularity calculated agree?

Definition at line 194 of file test_segment.cpp.

References SEG::ApproxPerpendicular().

Referenced by BOOST_AUTO_TEST_CASE().

◆ SegVecDistanceCorrect()

bool SegVecDistanceCorrect ( const SEG aSeg,
const VECTOR2I aVec,
int  aExp 
)

Predicate to check expected distance between a segment and a point.

Parameters
aSegAthe segment
aVecthe vector (point)
aExpexpected distance
Returns
does the distance calculated agree?

Definition at line 104 of file test_segment.cpp.

References SEG::Distance(), and SEG::SquaredDistance().

Referenced by BOOST_AUTO_TEST_CASE().

Variable Documentation

◆ seg_seg_coll_cases

const std::vector<SEG_SEG_COLLIDE_CASE> seg_seg_coll_cases
static

Definition at line 397 of file test_segment.cpp.

Referenced by BOOST_AUTO_TEST_CASE().

◆ seg_seg_dist_cases

const std::vector<SEG_SEG_DISTANCE_CASE> seg_seg_dist_cases
static

Definition at line 254 of file test_segment.cpp.

Referenced by BOOST_AUTO_TEST_CASE().

◆ seg_vec_collinear_cases

const std::vector<SEG_SEG_BOOLEAN_CASE> seg_vec_collinear_cases
static

Test cases for collinearity.

Definition at line 465 of file test_segment.cpp.

Referenced by BOOST_AUTO_TEST_CASE().

◆ seg_vec_dist_cases

const std::vector<SEG_VECTOR_DISTANCE_CASE> seg_vec_dist_cases
static

Definition at line 317 of file test_segment.cpp.

Referenced by BOOST_AUTO_TEST_CASE().

◆ seg_vec_parallel_cases

const std::vector<SEG_SEG_BOOLEAN_CASE> seg_vec_parallel_cases
static

Test cases for parallelism.

Definition at line 517 of file test_segment.cpp.

Referenced by BOOST_AUTO_TEST_CASE().

◆ seg_vec_perpendicular_cases

const std::vector<SEG_SEG_BOOLEAN_CASE> seg_vec_perpendicular_cases
static

Test cases for perpendicularity.

Definition at line 569 of file test_segment.cpp.

Referenced by BOOST_AUTO_TEST_CASE().

◆ 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 656 of file test_segment.cpp.

Referenced by BOOST_AUTO_TEST_CASE().