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

Go to the source code of this file.

Classes

struct  CIR_PT_BOOL_CASE
 Struct to hold test cases for a given circle, a point and an expected return boolean. More...
 
struct  CIR_PT_PT_CASE
 Struct to hold test cases for a given circle, a point and an expected return point. More...
 
struct  CIR_CIR_VECPT_CASE
 Struct to hold test cases for two circles, and an vector of points. More...
 
struct  CIR_SEG_VECPT_CASE
 Struct to hold test cases for two lines, a point and an expected returned circle. More...
 

Functions

bool CompareLength (int aLengthA, int aLengthB)
 
bool CompareVector2I (const VECTOR2I &aVecA, const VECTOR2I &aVecB)
 
 BOOST_AUTO_TEST_CASE (ParameterCtorMod)
 Checks whether the construction of a circle referencing external parameters works and that the parameters can be modified directly.
 
 BOOST_CHECK_EQUAL (ret, c.m_exp_result)
 
 BOOST_CHECK_EQUAL (c.m_exp_result.size(), ret.size())
 
 BOOST_DATA_TEST_CASE (ConstructFromTanTanPt, boost::unit_test::data::make(construct_tan_tan_pt_cases), c)
 

Variables

const int MIN_PRECISION_45DEG = KiROUND( (double) SHAPE::MIN_PRECISION_IU * 0.7071 )
 
static const std::vector< CIR_PT_BOOL_CASEcontains_cases
 Test cases for CIRCLE::Contains.
 
static const std::vector< CIR_PT_PT_CASEnearest_point_cases
 Test cases for CIRCLE::NearestPoint.
 
static const std::vector< CIR_CIR_VECPT_CASEintersect_circle_cases
 Test cases for #CIRCLE::Intersect( const CIRCLE& aCircle )
 
static const std::vector< SEG_SEG_VECPT_CASE > intersect_seg_cases
 Test cases for #CIRCLE::Intersect( const SEG& aSeg )
 
static const std::vector< SEG_SEG_VECPT_CASE > intersect_line_cases
 Test cases for #CIRCLE::IntersectLine( const SEG& aSeg )
 
static const std::vector< CIR_SEG_VECPT_CASEconstruct_tan_tan_pt_cases
 Test cases for #CIRCLE::Intersect( const SEG& aSeg )
 

Function Documentation

◆ BOOST_AUTO_TEST_CASE()

BOOST_AUTO_TEST_CASE ( ParameterCtorMod  )

Checks whether the construction of a circle referencing external parameters works and that the parameters can be modified directly.

Definition at line 57 of file test_circle.cpp.

References BOOST_CHECK_EQUAL(), CIRCLE::Center, center, CIRCLE::Radius, and radius.

◆ BOOST_CHECK_EQUAL() [1/2]

BOOST_CHECK_EQUAL ( c.m_exp_result.  size(),
ret.  size() 
)
Initial value:
{
std::vector<VECTOR2I> ret = c.m_circle.IntersectLine( c.m_seg )

◆ BOOST_CHECK_EQUAL() [2/2]

◆ BOOST_DATA_TEST_CASE()

BOOST_DATA_TEST_CASE ( ConstructFromTanTanPt  ,
boost::unit_test::data::make(construct_tan_tan_pt_cases ,
 
)

◆ CompareLength()

bool CompareLength ( int  aLengthA,
int  aLengthB 
)

Definition at line 30 of file test_circle.cpp.

References SHAPE::MIN_PRECISION_IU.

Referenced by BOOST_DATA_TEST_CASE(), and CompareVector2I().

◆ CompareVector2I()

bool CompareVector2I ( const VECTOR2I aVecA,
const VECTOR2I aVecB 
)

Definition at line 40 of file test_circle.cpp.

References CompareLength(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by BOOST_DATA_TEST_CASE().

Variable Documentation

◆ construct_tan_tan_pt_cases

const std::vector<CIR_SEG_VECPT_CASE> construct_tan_tan_pt_cases
static

Test cases for #CIRCLE::Intersect( const SEG& aSeg )

Definition at line 491 of file test_circle.cpp.

◆ contains_cases

const std::vector<CIR_PT_BOOL_CASE> contains_cases
static

Test cases for CIRCLE::Contains.

Definition at line 92 of file test_circle.cpp.

◆ intersect_circle_cases

const std::vector<CIR_CIR_VECPT_CASE> intersect_circle_cases
static

Test cases for #CIRCLE::Intersect( const CIRCLE& aCircle )

Definition at line 240 of file test_circle.cpp.

◆ intersect_line_cases

const std::vector<SEG_SEG_VECPT_CASE> intersect_line_cases
static

Test cases for #CIRCLE::IntersectLine( const SEG& aSeg )

Definition at line 419 of file test_circle.cpp.

◆ intersect_seg_cases

const std::vector<SEG_SEG_VECPT_CASE> intersect_seg_cases
static

Test cases for #CIRCLE::Intersect( const SEG& aSeg )

Definition at line 360 of file test_circle.cpp.

◆ MIN_PRECISION_45DEG

const int MIN_PRECISION_45DEG = KiROUND( (double) SHAPE::MIN_PRECISION_IU * 0.7071 )

Definition at line 28 of file test_circle.cpp.

◆ nearest_point_cases

const std::vector<CIR_PT_PT_CASE> nearest_point_cases
static
Initial value:
= {
{
"on center",
{ { 10, 10 }, 20 },
{ 10, 10 },
{ 30, 10 },
},
{
"inside",
{ { 10, 10 }, 20 },
{ 10, 20 },
{ 10, 30 },
},
{
"outside",
{ { 10, 10 }, 20 },
{ 10, 50 },
{ 10, 30 },
},
{
"angled",
{ { 10, 10 }, 20 },
{ 50, 50 },
{ 24, 24 },
},
}

Test cases for CIRCLE::NearestPoint.

Definition at line 190 of file test_circle.cpp.