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)
 

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/9]

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

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

◆ BOOST_AUTO_TEST_CASE() [2/9]

BOOST_AUTO_TEST_CASE ( SegCreateParallel  )

◆ BOOST_AUTO_TEST_CASE() [3/9]

BOOST_AUTO_TEST_CASE ( SegCreatePerpendicular  )

◆ BOOST_AUTO_TEST_CASE() [4/9]

BOOST_AUTO_TEST_CASE ( SegSegCollinear  )

◆ BOOST_AUTO_TEST_CASE() [5/9]

BOOST_AUTO_TEST_CASE ( SegSegCollision  )

Definition at line 416 of file test_segment.cpp.

References BOOST_TEST_CONTEXT, seg_seg_coll_cases, and SegCollideCorrect().

◆ BOOST_AUTO_TEST_CASE() [6/9]

BOOST_AUTO_TEST_CASE ( SegSegDistance  )

Definition at line 292 of file test_segment.cpp.

References BOOST_TEST_CONTEXT, seg_seg_dist_cases, and SegDistanceCorrect().

◆ BOOST_AUTO_TEST_CASE() [7/9]

BOOST_AUTO_TEST_CASE ( SegSegParallel  )

◆ BOOST_AUTO_TEST_CASE() [8/9]

BOOST_AUTO_TEST_CASE ( SegSegPerpendicular  )

◆ BOOST_AUTO_TEST_CASE() [9/9]

BOOST_AUTO_TEST_CASE ( SegVecDistance  )

Definition at line 349 of file test_segment.cpp.

References BOOST_TEST_CONTEXT, 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 BOOST_TEST_INFO, and 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 127 of file test_segment.cpp.

References BOOST_TEST_INFO, and 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 BOOST_TEST_INFO, 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 159 of file test_segment.cpp.

References SEG::ApproxParallel(), and BOOST_TEST_INFO.

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

References SEG::ApproxPerpendicular(), and BOOST_TEST_INFO.

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 BOOST_TEST_INFO, and SEG::Distance().

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 376 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 251 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 444 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 314 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 496 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 548 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 635 of file test_segment.cpp.

Referenced by BOOST_AUTO_TEST_CASE().