2019-01-11 22:03:45 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2021-10-06 02:46:53 +00:00
|
|
|
* Copyright (C) 2018 KiCad Developers, see AUTHORS.TXT for contributors.
|
2019-01-11 22:03:45 +00:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
2021-02-06 22:20:31 +00:00
|
|
|
#include <qa_utils/wx_utils/unit_test_utils.h>
|
2019-01-11 22:03:45 +00:00
|
|
|
|
|
|
|
#include <pcbnew_utils/board_construction_utils.h>
|
|
|
|
#include <pcbnew_utils/board_file_utils.h>
|
2020-11-12 20:19:22 +00:00
|
|
|
#include <board.h>
|
2021-06-06 19:33:45 +00:00
|
|
|
#include <board_design_settings.h>
|
2020-11-12 20:19:22 +00:00
|
|
|
#include <footprint.h>
|
2020-11-14 18:11:28 +00:00
|
|
|
#include <pcb_marker.h>
|
2020-03-16 11:05:01 +00:00
|
|
|
#include <drc/drc_item.h>
|
2020-09-14 17:54:14 +00:00
|
|
|
#include <drc/drc_engine.h>
|
2020-02-28 00:05:40 +00:00
|
|
|
#include <widgets/ui_common.h>
|
2019-01-11 22:03:45 +00:00
|
|
|
|
|
|
|
#include "../board_test_utils.h"
|
|
|
|
#include "drc_test_utils.h"
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Simple definition of a rectangle, can be rounded
|
|
|
|
*/
|
|
|
|
struct RECT_DEFINITION
|
|
|
|
{
|
|
|
|
VECTOR2I m_centre;
|
|
|
|
VECTOR2I m_size;
|
|
|
|
int m_corner_rad;
|
|
|
|
|
|
|
|
// On front or back layer (the exact layer is context-dependent)
|
|
|
|
bool m_front;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2020-11-13 15:15:52 +00:00
|
|
|
* A simple mock footprint with a set of courtyard rectangles and some other information
|
2019-01-11 22:03:45 +00:00
|
|
|
*/
|
2020-11-13 15:15:52 +00:00
|
|
|
struct COURTYARD_TEST_FP
|
2019-01-11 22:03:45 +00:00
|
|
|
{
|
|
|
|
std::string m_refdes;
|
|
|
|
std::vector<RECT_DEFINITION> m_rects;
|
|
|
|
VECTOR2I m_pos;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Struct holding information about a courtyard collision
|
|
|
|
*/
|
|
|
|
struct COURTYARD_COLLISION
|
|
|
|
{
|
|
|
|
// The two colliding parts
|
|
|
|
std::string m_refdes_a;
|
|
|
|
std::string m_refdes_b;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
std::ostream& operator<<( std::ostream& os, const COURTYARD_COLLISION& aColl )
|
|
|
|
{
|
|
|
|
os << "COURTYARD_COLLISION[ " << aColl.m_refdes_a << " -> " << aColl.m_refdes_b << "]";
|
|
|
|
return os;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2020-10-21 03:48:06 +00:00
|
|
|
* A complete courtyard overlap test case: a name, the board footprint list
|
2019-01-11 22:03:45 +00:00
|
|
|
* and the expected collisions.
|
|
|
|
*/
|
|
|
|
struct COURTYARD_OVERLAP_TEST_CASE
|
|
|
|
{
|
2020-11-13 15:15:52 +00:00
|
|
|
std::string m_case_name;
|
|
|
|
std::vector<COURTYARD_TEST_FP> m_fpDefs; // The footprint in the test case
|
|
|
|
std::vector<COURTYARD_COLLISION> m_collisions; // The expected number of collisions
|
2019-01-11 22:03:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2020-11-13 15:15:52 +00:00
|
|
|
* Add a rectangular courtyard outline to a footprint.
|
2019-01-11 22:03:45 +00:00
|
|
|
*/
|
2020-11-13 15:15:52 +00:00
|
|
|
void AddRectCourtyard( FOOTPRINT& aFootprint, const RECT_DEFINITION& aRect )
|
2019-01-11 22:03:45 +00:00
|
|
|
{
|
|
|
|
const PCB_LAYER_ID layer = aRect.m_front ? F_CrtYd : B_CrtYd;
|
|
|
|
|
|
|
|
const int width = Millimeter2iu( 0.1 );
|
|
|
|
|
2020-11-13 15:15:52 +00:00
|
|
|
KI_TEST::DrawRect( aFootprint, aRect.m_centre, aRect.m_size, aRect.m_corner_rad, width, layer );
|
2019-01-11 22:03:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2020-11-13 15:15:52 +00:00
|
|
|
* Construct a #FOOTPRINT to use in a courtyard test from a #COURTYARD_TEST_FP definition.
|
2019-01-11 22:03:45 +00:00
|
|
|
*/
|
2020-11-13 15:15:52 +00:00
|
|
|
std::unique_ptr<FOOTPRINT> MakeCourtyardTestFP( BOARD& aBoard, const COURTYARD_TEST_FP& aFPDef )
|
2019-01-11 22:03:45 +00:00
|
|
|
{
|
2020-11-13 15:15:52 +00:00
|
|
|
std::unique_ptr<FOOTPRINT> footprint = std::make_unique<FOOTPRINT>( &aBoard );
|
2019-01-11 22:03:45 +00:00
|
|
|
|
2020-11-13 15:15:52 +00:00
|
|
|
for( const RECT_DEFINITION& rect : aFPDef.m_rects )
|
|
|
|
AddRectCourtyard( *footprint, rect );
|
2019-01-11 22:03:45 +00:00
|
|
|
|
2020-11-13 15:15:52 +00:00
|
|
|
footprint->SetReference( aFPDef.m_refdes );
|
2019-01-11 22:03:45 +00:00
|
|
|
|
2020-11-13 15:15:52 +00:00
|
|
|
// This has to go after adding the courtyards, or all the poly sets are empty when DRC'd
|
2022-01-02 02:06:40 +00:00
|
|
|
footprint->SetPosition( aFPDef.m_pos );
|
2019-01-11 22:03:45 +00:00
|
|
|
|
2020-11-13 15:15:52 +00:00
|
|
|
return footprint;
|
2019-01-11 22:03:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Make a board for courtyard testing.
|
|
|
|
*
|
2020-11-13 15:15:52 +00:00
|
|
|
* @param aFPDefs the list of footprint definitions to add to the board
|
2019-01-11 22:03:45 +00:00
|
|
|
*/
|
2020-11-13 15:15:52 +00:00
|
|
|
std::unique_ptr<BOARD> MakeBoard( const std::vector<COURTYARD_TEST_FP>& aFPDefs )
|
2019-01-11 22:03:45 +00:00
|
|
|
{
|
2020-11-13 15:15:52 +00:00
|
|
|
std::unique_ptr<BOARD> board = std::make_unique<BOARD>();
|
2019-01-11 22:03:45 +00:00
|
|
|
|
2020-11-13 15:15:52 +00:00
|
|
|
for( const COURTYARD_TEST_FP& fpDef : aFPDefs )
|
2019-01-11 22:03:45 +00:00
|
|
|
{
|
2020-11-13 15:15:52 +00:00
|
|
|
std::unique_ptr<FOOTPRINT> footprint = MakeCourtyardTestFP( *board, fpDef );
|
2019-01-11 22:03:45 +00:00
|
|
|
|
2020-11-13 15:15:52 +00:00
|
|
|
board->Add( footprint.release() );
|
2019-01-11 22:03:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return board;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
struct COURTYARD_TEST_FIXTURE
|
|
|
|
{
|
|
|
|
const KI_TEST::BOARD_DUMPER m_dumper;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
BOOST_FIXTURE_TEST_SUITE( DrcCourtyardOverlap, COURTYARD_TEST_FIXTURE )
|
|
|
|
|
|
|
|
// clang-format off
|
|
|
|
static std::vector<COURTYARD_OVERLAP_TEST_CASE> courtyard_cases = {
|
|
|
|
{
|
|
|
|
"empty board",
|
2020-10-21 03:48:06 +00:00
|
|
|
{}, // no footprint
|
2019-01-11 22:03:45 +00:00
|
|
|
{}, // no collisions
|
|
|
|
},
|
|
|
|
{
|
2020-10-21 03:48:06 +00:00
|
|
|
"single empty footprint",
|
2019-01-11 22:03:45 +00:00
|
|
|
{
|
|
|
|
{
|
|
|
|
"U1",
|
|
|
|
{}, // no courtyard
|
|
|
|
{ 0, 0 }, // at origin
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{}, // no collisions
|
|
|
|
},
|
|
|
|
{
|
2020-10-21 03:48:06 +00:00
|
|
|
// A single footprint can't overlap itself
|
|
|
|
"single footprint, single courtyard",
|
2019-01-11 22:03:45 +00:00
|
|
|
{
|
|
|
|
{
|
|
|
|
"U1",
|
|
|
|
{
|
|
|
|
{
|
|
|
|
{ 0, 0 },
|
|
|
|
{ Millimeter2iu( 1 ), Millimeter2iu( 1 ) },
|
|
|
|
0,
|
|
|
|
true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{ 0, 0 },
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{}, // no collisions
|
|
|
|
},
|
|
|
|
{
|
2020-10-21 03:48:06 +00:00
|
|
|
"two footprint, no overlap",
|
2019-01-11 22:03:45 +00:00
|
|
|
{
|
|
|
|
{
|
|
|
|
"U1",
|
|
|
|
{
|
|
|
|
{
|
|
|
|
{ 0, 0 },
|
|
|
|
{ Millimeter2iu( 1 ), Millimeter2iu( 1 ) },
|
|
|
|
0,
|
|
|
|
true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{ 0, 0 },
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"U2",
|
|
|
|
{
|
|
|
|
{
|
|
|
|
{ 0, 0 },
|
|
|
|
{ Millimeter2iu( 1 ), Millimeter2iu( 1 ) },
|
|
|
|
0,
|
|
|
|
true,
|
|
|
|
},
|
|
|
|
},
|
2020-11-13 15:15:52 +00:00
|
|
|
{ Millimeter2iu( 3 ), Millimeter2iu( 1 ) }, // One footprint is far from the other
|
2019-01-11 22:03:45 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{}, // no collisions
|
|
|
|
},
|
|
|
|
{
|
2020-10-21 03:48:06 +00:00
|
|
|
"two footprints, touching, no overlap",
|
2019-01-11 22:03:45 +00:00
|
|
|
{
|
|
|
|
{
|
|
|
|
"U1",
|
|
|
|
{
|
|
|
|
{
|
|
|
|
{ 0, 0 },
|
|
|
|
{ Millimeter2iu( 1 ), Millimeter2iu( 1 ) },
|
|
|
|
0,
|
|
|
|
true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{ 0, 0 },
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"U2",
|
|
|
|
{
|
|
|
|
{
|
|
|
|
{ 0, 0 },
|
|
|
|
{ Millimeter2iu( 1 ), Millimeter2iu( 1 ) },
|
|
|
|
0,
|
|
|
|
true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{ Millimeter2iu( 1 ), Millimeter2iu( 0 ) }, // Just touching
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{}, // Touching means not colliding
|
|
|
|
},
|
|
|
|
{
|
2020-10-21 03:48:06 +00:00
|
|
|
"two footprints, overlap",
|
2019-01-11 22:03:45 +00:00
|
|
|
{
|
|
|
|
{
|
|
|
|
"U1",
|
|
|
|
{
|
|
|
|
{
|
|
|
|
{ 0, 0 },
|
|
|
|
{ Millimeter2iu( 1 ), Millimeter2iu( 1 ) },
|
|
|
|
0,
|
|
|
|
true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{ 0, 0 },
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"U2",
|
|
|
|
{
|
|
|
|
{
|
|
|
|
{ 0, 0 },
|
|
|
|
{ Millimeter2iu( 1 ), Millimeter2iu( 1 ) },
|
|
|
|
0,
|
|
|
|
true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{ Millimeter2iu( 0.5 ), Millimeter2iu( 0 ) }, // Partial overlap
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{ "U1", "U2" }, // These two collide
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2020-10-21 03:48:06 +00:00
|
|
|
"two footprints, overlap, different sides",
|
2019-01-11 22:03:45 +00:00
|
|
|
{
|
|
|
|
{
|
|
|
|
"U1",
|
|
|
|
{
|
|
|
|
{
|
|
|
|
{ 0, 0 },
|
|
|
|
{ Millimeter2iu( 1 ), Millimeter2iu( 1 ) },
|
|
|
|
0,
|
|
|
|
true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{ 0, 0 },
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"U2",
|
|
|
|
{
|
|
|
|
{
|
|
|
|
{ 0, 0 },
|
|
|
|
{ Millimeter2iu( 1 ), Millimeter2iu( 1 ) },
|
|
|
|
0,
|
|
|
|
false,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{ 0, 0 }, // complete overlap
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{}, // but on different sides
|
|
|
|
},
|
|
|
|
{
|
2020-10-21 03:48:06 +00:00
|
|
|
"two footprints, multiple courtyards, overlap",
|
2019-01-11 22:03:45 +00:00
|
|
|
{
|
|
|
|
{
|
|
|
|
"U1",
|
|
|
|
{
|
|
|
|
{
|
|
|
|
{ 0, 0 },
|
|
|
|
{ Millimeter2iu( 1 ), Millimeter2iu( 1 ) },
|
|
|
|
0,
|
|
|
|
true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{ Millimeter2iu( 2 ), Millimeter2iu( 0 ) },
|
|
|
|
{ Millimeter2iu( 1 ), Millimeter2iu( 1 ) },
|
|
|
|
0,
|
|
|
|
true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{ 0, 0 },
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"U2",
|
|
|
|
{
|
|
|
|
{
|
|
|
|
{ 0, 0 },
|
|
|
|
{ Millimeter2iu( 1 ), Millimeter2iu( 1 ) },
|
|
|
|
0,
|
|
|
|
true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{ 0, 0 }, // complete overlap with one of the others
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{ "U1", "U2" },
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
// The courtyards do not overlap, but their bounding boxes do
|
2020-10-21 03:48:06 +00:00
|
|
|
"two footprints, no overlap, bbox overlap",
|
2019-01-11 22:03:45 +00:00
|
|
|
{
|
|
|
|
{
|
|
|
|
"U1",
|
|
|
|
{
|
|
|
|
{
|
|
|
|
{ 0, 0 },
|
|
|
|
{ Millimeter2iu( 1 ), Millimeter2iu( 1 ) },
|
|
|
|
Millimeter2iu( 0.5 ),
|
|
|
|
true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{ 0, 0 },
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"U2",
|
|
|
|
{
|
|
|
|
{
|
|
|
|
{ Millimeter2iu( 0.9 ), Millimeter2iu( 0.9 ) },
|
|
|
|
{ Millimeter2iu( 1 ), Millimeter2iu( 1 ) },
|
|
|
|
Millimeter2iu( 0.5 ),
|
|
|
|
true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{ 0, 0 },
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
// clang-format on
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2020-11-14 18:11:28 +00:00
|
|
|
* Check if a #PCB_MARKER is described by a particular #COURTYARD_COLLISION object.
|
2019-01-11 22:03:45 +00:00
|
|
|
*/
|
2020-11-14 18:11:28 +00:00
|
|
|
static bool CollisionMatchesExpected( BOARD& aBoard, const PCB_MARKER& aMarker,
|
2020-03-16 11:05:01 +00:00
|
|
|
const COURTYARD_COLLISION& aCollision )
|
2019-01-11 22:03:45 +00:00
|
|
|
{
|
2020-08-11 13:33:16 +00:00
|
|
|
auto reporter = std::static_pointer_cast<DRC_ITEM>( aMarker.GetRCItem() );
|
2019-01-11 22:03:45 +00:00
|
|
|
|
2020-11-13 15:15:52 +00:00
|
|
|
const FOOTPRINT* item_a = dynamic_cast<FOOTPRINT*>( aBoard.GetItem( reporter->GetMainItemID() ) );
|
|
|
|
const FOOTPRINT* item_b = dynamic_cast<FOOTPRINT*>( aBoard.GetItem( reporter->GetAuxItemID() ) );
|
2019-01-11 22:03:45 +00:00
|
|
|
|
2021-06-09 19:32:58 +00:00
|
|
|
// can't find the items!
|
2019-01-11 22:03:45 +00:00
|
|
|
if( !item_a || !item_b )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
const bool ref_match_aa_bb = ( item_a->GetReference() == aCollision.m_refdes_a )
|
|
|
|
&& ( item_b->GetReference() == aCollision.m_refdes_b );
|
|
|
|
|
|
|
|
const bool ref_match_ab_ba = ( item_a->GetReference() == aCollision.m_refdes_b )
|
|
|
|
&& ( item_b->GetReference() == aCollision.m_refdes_a );
|
|
|
|
|
|
|
|
// Doesn't matter which way around it is, but both have to match somehow
|
|
|
|
return ref_match_aa_bb || ref_match_ab_ba;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2020-04-24 13:36:10 +00:00
|
|
|
* Check that the produced markers match the expected. This does NOT check ordering,
|
|
|
|
* as that is not part of the contract of the DRC function.
|
2019-01-11 22:03:45 +00:00
|
|
|
*
|
|
|
|
* @param aMarkers list of markers produced by the DRC
|
|
|
|
* @param aCollisions list of expected collisions
|
|
|
|
*/
|
2020-05-17 14:40:06 +00:00
|
|
|
static void CheckCollisionsMatchExpected( BOARD& aBoard,
|
2020-11-14 18:11:28 +00:00
|
|
|
const std::vector<std::unique_ptr<PCB_MARKER>>& aMarkers,
|
2020-05-17 14:40:06 +00:00
|
|
|
const std::vector<COURTYARD_COLLISION>& aExpCollisions )
|
2019-01-11 22:03:45 +00:00
|
|
|
{
|
|
|
|
for( const auto& marker : aMarkers )
|
|
|
|
{
|
|
|
|
BOOST_CHECK_PREDICATE(
|
|
|
|
KI_TEST::IsDrcMarkerOfType, ( *marker )( DRCE_OVERLAPPING_FOOTPRINTS ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
KI_TEST::CheckUnorderedMatches( aExpCollisions, aMarkers,
|
2020-11-14 18:11:28 +00:00
|
|
|
[&]( const COURTYARD_COLLISION& aColl, const std::unique_ptr<PCB_MARKER>& aMarker )
|
2020-04-24 13:36:10 +00:00
|
|
|
{
|
2019-01-11 22:03:45 +00:00
|
|
|
return CollisionMatchesExpected( aBoard, *aMarker, aColl );
|
|
|
|
} );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Run a single courtyard overlap testcase
|
|
|
|
* @param aCase The testcase to run.
|
|
|
|
*/
|
2020-05-17 14:40:06 +00:00
|
|
|
static void DoCourtyardOverlapTest( const COURTYARD_OVERLAP_TEST_CASE& aCase,
|
|
|
|
const KI_TEST::BOARD_DUMPER& aDumper )
|
2019-01-11 22:03:45 +00:00
|
|
|
{
|
2020-11-13 15:15:52 +00:00
|
|
|
auto board = MakeBoard( aCase.m_fpDefs );
|
2019-01-11 22:03:45 +00:00
|
|
|
|
|
|
|
// Dump if env var set
|
|
|
|
aDumper.DumpBoardToFile( *board, aCase.m_case_name );
|
|
|
|
|
2020-05-31 21:42:04 +00:00
|
|
|
BOARD_DESIGN_SETTINGS& bds = board->GetDesignSettings();
|
|
|
|
|
|
|
|
bds.m_DRCSeverities[ DRCE_OVERLAPPING_FOOTPRINTS ] = RPT_SEVERITY_ERROR;
|
|
|
|
|
|
|
|
// we might not always have courtyards - that's a separate test
|
|
|
|
bds.m_DRCSeverities[ DRCE_MISSING_COURTYARD ] = RPT_SEVERITY_IGNORE;
|
2019-01-11 22:03:45 +00:00
|
|
|
|
|
|
|
// list of markers to collect
|
2020-11-14 18:11:28 +00:00
|
|
|
std::vector<std::unique_ptr<PCB_MARKER>> markers;
|
2019-01-11 22:03:45 +00:00
|
|
|
|
2020-09-14 17:54:14 +00:00
|
|
|
DRC_ENGINE drcEngine( board.get(), &board->GetDesignSettings() );
|
|
|
|
|
|
|
|
drcEngine.InitEngine( wxFileName() );
|
|
|
|
|
|
|
|
drcEngine.SetViolationHandler(
|
2022-01-01 06:04:08 +00:00
|
|
|
[&]( const std::shared_ptr<DRC_ITEM>& aItem, VECTOR2I aPos, PCB_LAYER_ID aLayer )
|
2020-02-28 00:05:40 +00:00
|
|
|
{
|
2020-09-14 17:54:14 +00:00
|
|
|
if( aItem->GetErrorCode() == DRCE_OVERLAPPING_FOOTPRINTS
|
2020-09-15 20:49:51 +00:00
|
|
|
|| aItem->GetErrorCode() == DRCE_MALFORMED_COURTYARD
|
2020-09-14 17:54:14 +00:00
|
|
|
|| aItem->GetErrorCode() == DRCE_MISSING_COURTYARD )
|
|
|
|
{
|
2020-11-14 18:11:28 +00:00
|
|
|
markers.push_back( std::make_unique<PCB_MARKER>( aItem, aPos ) );
|
2020-09-14 17:54:14 +00:00
|
|
|
}
|
2020-02-28 00:05:40 +00:00
|
|
|
} );
|
2019-01-11 22:03:45 +00:00
|
|
|
|
2020-10-28 17:55:57 +00:00
|
|
|
drcEngine.RunTests( EDA_UNITS::MILLIMETRES, true, false );
|
2019-01-11 22:03:45 +00:00
|
|
|
|
|
|
|
CheckCollisionsMatchExpected( *board, markers, aCase.m_collisions );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE( OverlapCases )
|
|
|
|
{
|
|
|
|
for( const auto& c : courtyard_cases )
|
|
|
|
{
|
|
|
|
BOOST_TEST_CONTEXT( c.m_case_name )
|
|
|
|
{
|
|
|
|
DoCourtyardOverlapTest( c, m_dumper );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-21 03:48:06 +00:00
|
|
|
BOOST_AUTO_TEST_SUITE_END()
|