KiCad PCB EDA Suite
test_shape_poly_set_iterator.cpp File Reference

Go to the source code of this file.

Classes

struct  IteratorFixture
 Fixture for the Iterator test suite. More...
 

Functions

 BOOST_AUTO_TEST_CASE (VertexIterator)
 Declares the IteratorFixture as the boost test suite fixture. More...
 
 BOOST_AUTO_TEST_CASE (SegmentIterator)
 Checks whether the iteration on the segments of a common polygon is correct. More...
 
 BOOST_AUTO_TEST_CASE (EmptyPolygon)
 Checks whether the iteration on the segments of an empty polygon is correct. More...
 
 BOOST_AUTO_TEST_CASE (UniqueVertex)
 Checks whether the iteration on the segments of a polygon with one vertex is correct. More...
 
 BOOST_AUTO_TEST_CASE (TotalVertices)
 Checks whether the counting of the total number of vertices is correct. More...
 
 BOOST_AUTO_TEST_CASE (RemoveNullSegments)
 Checks whether the removal of null segments, wherever they are placed, is correct. More...
 

Function Documentation

◆ BOOST_AUTO_TEST_CASE() [1/6]

BOOST_AUTO_TEST_CASE ( VertexIterator  )

Declares the IteratorFixture as the boost test suite fixture.

Checks whether the iteration on the vertices of a common polygon is correct.

Definition at line 98 of file test_shape_poly_set_iterator.cpp.

99 {
100  SHAPE_POLY_SET::ITERATOR iterator;
101  int vertexIndex = 0;
102 
103  for( iterator = common.holeyPolySet.IterateWithHoles(); iterator; iterator++ )
104  {
105  BOOST_CHECK_EQUAL( common.holeyPoints[vertexIndex], *iterator );
106  vertexIndex++;
107  }
108 }
Base class for iterating over all vertices in a given SHAPE_POLY_SET.

◆ BOOST_AUTO_TEST_CASE() [2/6]

BOOST_AUTO_TEST_CASE ( SegmentIterator  )

Checks whether the iteration on the segments of a common polygon is correct.

Definition at line 113 of file test_shape_poly_set_iterator.cpp.

114 {
116  int segmentIndex = 0;
117 
118  for( iterator = common.holeyPolySet.IterateSegmentsWithHoles(); iterator; iterator++ )
119  {
120  SEG segment = *iterator;
121 
122  BOOST_CHECK_EQUAL( common.holeySegments[segmentIndex].A, segment.A );
123  BOOST_CHECK_EQUAL( common.holeySegments[segmentIndex].B, segment.B );
124 
125  segmentIndex++;
126  }
127 }
Base class for iterating over all segments in a given SHAPE_POLY_SET.
Definition: seg.h:41
VECTOR2I A
Definition: seg.h:49
VECTOR2I B
Definition: seg.h:50

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

◆ BOOST_AUTO_TEST_CASE() [3/6]

BOOST_AUTO_TEST_CASE ( EmptyPolygon  )

Checks whether the iteration on the segments of an empty polygon is correct.

Definition at line 132 of file test_shape_poly_set_iterator.cpp.

133 {
135 
136  for( iterator = common.emptyPolySet.IterateSegmentsWithHoles(); iterator; iterator++ )
137  {
138  BOOST_FAIL( "Empty set is being iterated!" );
139  }
140 }
Base class for iterating over all segments in a given SHAPE_POLY_SET.

◆ BOOST_AUTO_TEST_CASE() [4/6]

BOOST_AUTO_TEST_CASE ( UniqueVertex  )

Checks whether the iteration on the segments of a polygon with one vertex is correct.

Definition at line 145 of file test_shape_poly_set_iterator.cpp.

146 {
148  iterator = common.uniqueVertexPolySet.IterateSegmentsWithHoles();
149 
150  SEG segment = *iterator;
151  BOOST_CHECK_EQUAL( segment.A, common.uniquePoints[0] );
152  BOOST_CHECK_EQUAL( segment.B, common.uniquePoints[0] );
153 
154  iterator++;
155 
156  BOOST_CHECK( !iterator );
157 }
Base class for iterating over all segments in a given SHAPE_POLY_SET.
BOOST_CHECK(v2.Cross(v1)==1)
Definition: seg.h:41
VECTOR2I A
Definition: seg.h:49
VECTOR2I B
Definition: seg.h:50

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

◆ BOOST_AUTO_TEST_CASE() [5/6]

BOOST_AUTO_TEST_CASE ( TotalVertices  )

Checks whether the counting of the total number of vertices is correct.

Definition at line 162 of file test_shape_poly_set_iterator.cpp.

163 {
164  BOOST_CHECK_EQUAL( common.emptyPolySet.TotalVertices(), 0 );
165  BOOST_CHECK_EQUAL( common.uniqueVertexPolySet.TotalVertices(), 1 );
166  BOOST_CHECK_EQUAL( common.solidPolySet.TotalVertices(), 0 );
167  BOOST_CHECK_EQUAL( common.holeyPolySet.TotalVertices(), 12 );
168 }

◆ BOOST_AUTO_TEST_CASE() [6/6]

BOOST_AUTO_TEST_CASE ( RemoveNullSegments  )

Checks whether the removal of null segments, wherever they are placed, is correct.

Definition at line 173 of file test_shape_poly_set_iterator.cpp.

174 {
175  SHAPE_POLY_SET polygonSets[3] = { lastNullSegmentPolySet, firstNullSegmentPolySet,
176  insideNullSegmentPolySet };
177 
178  for( SHAPE_POLY_SET polygonSet : polygonSets )
179  {
180  BOOST_CHECK_EQUAL( polygonSet.TotalVertices(), 4 );
181  BOOST_CHECK_EQUAL( polygonSet.RemoveNullSegments(), 1 );
182  BOOST_CHECK_EQUAL( polygonSet.TotalVertices(), 3 );
183 
184  BOOST_CHECK_EQUAL( polygonSet.CVertex( 0 ), nullPoints[0] );
185  BOOST_CHECK_EQUAL( polygonSet.CVertex( 1 ), nullPoints[1] );
186  BOOST_CHECK_EQUAL( polygonSet.CVertex( 2 ), nullPoints[2] );
187  }
188 }
Represent a set of closed polygons.