KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_half_line.cpp File Reference
#include <qa_utils/wx_utils/unit_test_utils.h>
#include <boost/test/data/test_case.hpp>
#include <geometry/half_line.h>
#include <geometry/shape_utils.h>
#include "geom_test_utils.h"

Go to the source code of this file.

Classes

struct  HalfLineBoxClipCase
 
struct  HalfLineHalfLineIntersectionCase
 
struct  HalfLineContainsPointCase
 

Functions

 BOOST_TEST (contains==c.ExpectedContains)
 
 BOOST_REQUIRE (intersection.has_value()==c.ExpectedIntersection.has_value())
 
 if (intersection)
 
 BOOST_REQUIRE (clipped.has_value()==c.ExpectedClippedSeg.has_value())
 
 if (clipped)
 
 BOOST_AUTO_TEST_SUITE_END ()
 

Variables

const std::vector< HalfLineContainsPointCaseContains_cases
 
const std::vector< HalfLineHalfLineIntersectionCaseIntersect_cases
 
const std::vector< HalfLineBoxClipCaseClipToBox_cases
 

Function Documentation

◆ BOOST_AUTO_TEST_SUITE_END()

BOOST_AUTO_TEST_SUITE_END ( )

◆ BOOST_REQUIRE() [1/2]

BOOST_REQUIRE ( clipped.  has_value() = =c.ExpectedClippedSeg.has_value())

◆ BOOST_REQUIRE() [2/2]

◆ BOOST_TEST()

BOOST_TEST ( contains  = =c.ExpectedContains)

Referenced by BOOST_AUTO_TEST_CASE(), and if().

◆ if() [1/2]

if ( clipped  )

◆ if() [2/2]

if ( intersection  )

Definition at line 126 of file test_half_line.cpp.

References BOOST_TEST().

Referenced by LoadModel().

Variable Documentation

◆ ClipToBox_cases

const std::vector<HalfLineBoxClipCase> ClipToBox_cases
Initial value:
{
{
"Center to right edge",
HALF_LINE( SEG( VECTOR2I( 0, 0 ), VECTOR2I( 100, 0 ) ) ),
BOX2I{ VECTOR2{ -1000, -1000 }, VECTOR2{ 2000, 2000 } },
SEG( VECTOR2I( 0, 0 ), VECTOR2I( 1000, 0 ) ),
},
{
"Centre to corner",
HALF_LINE( SEG( VECTOR2I( 0, 0 ), VECTOR2I( 100, 100 ) ) ),
BOX2I{ VECTOR2{ -1000, -1000 }, VECTOR2{ 2000, 2000 } },
SEG( VECTOR2I( 0, 0 ), VECTOR2I( 1000, 1000 ) ),
},
{
"Ray not in the box",
HALF_LINE( SEG( VECTOR2I( 1500, 0 ), VECTOR2I( 1600, 0 ) ) ),
BOX2I{ VECTOR2{ -1000, -1000 }, VECTOR2{ 2000, 2000 } },
std::nullopt,
},
{
"Ray starts outside but crosses box",
HALF_LINE( SEG( VECTOR2I( -1500, 0 ), VECTOR2I( 0, 0 ) ) ),
BOX2I{ VECTOR2{ -1000, -1000 }, VECTOR2{ 2000, 2000 } },
SEG( VECTOR2I( -1000, 0 ), VECTOR2I( 1000, 0 ) ),
},
}
Definition: seg.h:42
Define a general 2D-vector/point.
Definition: vector2d.h:71
VECTOR2< int32_t > VECTOR2I
Definition: vector2d.h:695

Definition at line 133 of file test_half_line.cpp.

◆ Contains_cases

const std::vector<HalfLineContainsPointCase> Contains_cases

Definition at line 56 of file test_half_line.cpp.

◆ Intersect_cases

const std::vector<HalfLineHalfLineIntersectionCase> Intersect_cases
Initial value:
{
{
"Simple cross",
HALF_LINE( SEG( VECTOR2I( -100, -100 ), VECTOR2I( 0, 0 ) ) ),
HALF_LINE( SEG( VECTOR2I( 100, -100 ), VECTOR2I( 0, 0 ) ) ),
VECTOR2I( 0, 0 ),
},
{
"Parallel, no intersection",
HALF_LINE( SEG( VECTOR2I( -100, 0 ), VECTOR2I( -100, 100 ) ) ),
HALF_LINE( SEG( VECTOR2I( 100, 0 ), VECTOR2I( 100, 100 ) ) ),
std::nullopt,
}
}

Definition at line 104 of file test_half_line.cpp.