mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-09-14 18:23:15 +02:00
Adds BOOST tests to the qa folder included in the geometry subdirectory. The tests check whether the refactored code is consistent with the legacy code. They also check some of the new code, as the family of ITERATOR classes.
60 lines
2.0 KiB
C++
60 lines
2.0 KiB
C++
/*
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
*
|
|
* Copyright (C) 2017 CERN
|
|
* @author Alejandro García Montoro <alejandro.garciamontoro@gmail.com>
|
|
*
|
|
* This program is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU General Public License
|
|
* as published by the Free Software Foundation; either version 2
|
|
* of the License, or (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; if not, you may find one here:
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
*/
|
|
|
|
#include <boost/test/unit_test.hpp>
|
|
#include <boost/test/test_case_template.hpp>
|
|
#include <geometry/seg.h>
|
|
|
|
#include <qa/data/fixtures_geometry.h>
|
|
|
|
/**
|
|
* Declares the IteratorFixture as the boost test suite fixture.
|
|
*/
|
|
BOOST_FIXTURE_TEST_SUITE( SegmentReference, CommonTestData )
|
|
|
|
/**
|
|
* Checks whether the construction of a segment referencing external points works.
|
|
*/
|
|
BOOST_AUTO_TEST_CASE( SegmentReference )
|
|
{
|
|
VECTOR2I A( 10, 20 );
|
|
VECTOR2I B( 100, 200 );
|
|
|
|
// Build a segment referencing the previous points
|
|
SEG segment(A, B);
|
|
|
|
BOOST_CHECK_EQUAL( A, VECTOR2I( 10, 20) );
|
|
BOOST_CHECK_EQUAL( B, VECTOR2I( 100, 200) );
|
|
|
|
// Modify the ends of the segments
|
|
segment.A += VECTOR2I( 10, 10 );
|
|
segment.B += VECTOR2I( 100, 100 );
|
|
|
|
// Check that the original points are also modified
|
|
BOOST_CHECK_EQUAL( A, VECTOR2I( 20, 30) );
|
|
BOOST_CHECK_EQUAL( B, VECTOR2I( 200, 300) );
|
|
}
|
|
|
|
BOOST_AUTO_TEST_SUITE_END()
|