KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_pads_binary_import.cpp File Reference
#include <pcbnew_utils/board_test_utils.h>
#include <pcbnew_utils/board_file_utils.h>
#include <qa_utils/wx_utils/unit_test_utils.h>
#include <pcb_io/pads/pcb_io_pads_binary.h>
#include <pcb_io/pads/pcb_io_pads.h>
#include <layer_ids.h>
#include <padstack.h>
#include <board.h>
#include <pcb_text.h>
#include <pcb_shape.h>
#include <pcb_field.h>
#include <pad.h>
#include <pcb_track.h>
#include <footprint.h>
#include <zone.h>
#include <board_design_settings.h>
#include <set>

Go to the source code of this file.

Classes

struct  PADS_BINARY_BOARD_INFO
 

Macros

#define BINARY_LOAD_TEST(name, idx)
 
#define FOOTPRINT_COUNT_TEST(name, idx)
 
#define NET_COUNT_TEST(name, idx)
 
#define TRACK_COUNT_TEST(name, idx)
 
#define STRUCTURAL_INTEGRITY_TEST(name, idx)
 

Functions

static wxString GetBinaryPath (const PADS_BINARY_BOARD_INFO &aBoard)
 
static wxString GetAscPath (const PADS_BINARY_BOARD_INFO &aBoard)
 
static std::unique_ptr< BOARDLoadBinary (const PADS_BINARY_BOARD_INFO &aBoard)
 Load a binary .pcb file.
 
static std::unique_ptr< BOARDLoadAsc (const PADS_BINARY_BOARD_INFO &aBoard)
 
static int CountEdgeCutsShapes (const BOARD *aBoard)
 
static void CheckCountWithTolerance (const std::string &aLabel, size_t aBinaryCount, size_t aAscCount, bool aDifferentRevision)
 Compare counts with tolerance for binary/ASC differences.
 
static void RunStructuralChecks (const PADS_BINARY_BOARD_INFO &aBoard, const BOARD *aBinaryBoard)
 Structural integrity checks.
 
 BOOST_AUTO_TEST_CASE (BinaryFileDetection)
 
 BOOST_AUTO_TEST_CASE (AsciiFileRejection)
 
 BOOST_AUTO_TEST_CASE (BoardOutline_LCORE_4)
 
 BOOST_AUTO_TEST_CASE (BoardOutline_LCORE_2)
 
 BOOST_AUTO_TEST_CASE (BoardOutline_OtherVersions)
 

Variables

static const PADS_BINARY_BOARD_INFO PADS_BINARY_BOARDS []
 

Macro Definition Documentation

◆ BINARY_LOAD_TEST

#define BINARY_LOAD_TEST ( name,
idx )
Value:
BOOST_AUTO_TEST_CASE( BasicLoad_##name ) \
{ \
auto board = LoadBinary( PADS_BINARY_BOARDS[idx] ); \
\
if( board ) \
BOOST_CHECK( board->Footprints().size() > 0 ); \
}
const char * name
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
static std::unique_ptr< BOARD > LoadBinary(const PADS_BINARY_BOARD_INFO &aBoard)
Load a binary .pcb file.
static const PADS_BINARY_BOARD_INFO PADS_BINARY_BOARDS[]

Definition at line 276 of file test_pads_binary_import.cpp.

◆ FOOTPRINT_COUNT_TEST

#define FOOTPRINT_COUNT_TEST ( name,
idx )
Value:
BOOST_AUTO_TEST_CASE( FootprintCount_##name ) \
{ \
auto bin = LoadBinary( PADS_BINARY_BOARDS[idx] ); \
\
if( !bin ) \
return; \
\
auto asc = LoadAsc( PADS_BINARY_BOARDS[idx] ); \
\
CheckCountWithTolerance( #name " footprints", bin->Footprints().size(), \
asc->Footprints().size(), \
PADS_BINARY_BOARDS[idx].differentRevision ); \
}
static std::unique_ptr< BOARD > LoadAsc(const PADS_BINARY_BOARD_INFO &aBoard)

Definition at line 295 of file test_pads_binary_import.cpp.

◆ NET_COUNT_TEST

#define NET_COUNT_TEST ( name,
idx )
Value:
BOOST_AUTO_TEST_CASE( NetCount_##name ) \
{ \
auto bin = LoadBinary( PADS_BINARY_BOARDS[idx] ); \
\
if( !bin ) \
return; \
\
auto asc = LoadAsc( PADS_BINARY_BOARDS[idx] ); \
\
CheckCountWithTolerance( #name " nets", bin->GetNetCount(), asc->GetNetCount(), \
PADS_BINARY_BOARDS[idx].differentRevision ); \
}

Definition at line 320 of file test_pads_binary_import.cpp.

◆ STRUCTURAL_INTEGRITY_TEST

#define STRUCTURAL_INTEGRITY_TEST ( name,
idx )
Value:
BOOST_AUTO_TEST_CASE( StructuralIntegrity_##name ) \
{ \
auto board = LoadBinary( PADS_BINARY_BOARDS[idx] ); \
\
if( !board ) \
return; \
\
RunStructuralChecks( PADS_BINARY_BOARDS[idx], board.get() ); \
}

Definition at line 410 of file test_pads_binary_import.cpp.

◆ TRACK_COUNT_TEST

#define TRACK_COUNT_TEST ( name,
idx )
Value:
BOOST_AUTO_TEST_CASE( TrackCount_##name ) \
{ \
auto bin = LoadBinary( PADS_BINARY_BOARDS[idx] ); \
\
if( !bin ) \
return; \
\
auto asc = LoadAsc( PADS_BINARY_BOARDS[idx] ); \
\
BOOST_WARN_MESSAGE( bin->Tracks().size() > 0, \
#name " binary track parsing not supported for v0x2021" ); \
\
BOOST_WARN_EQUAL( bin->Tracks().size(), asc->Tracks().size() ); \
}

Definition at line 344 of file test_pads_binary_import.cpp.

Function Documentation

◆ BOOST_AUTO_TEST_CASE() [1/5]

BOOST_AUTO_TEST_CASE ( AsciiFileRejection )

◆ BOOST_AUTO_TEST_CASE() [2/5]

BOOST_AUTO_TEST_CASE ( BinaryFileDetection )

◆ BOOST_AUTO_TEST_CASE() [3/5]

BOOST_AUTO_TEST_CASE ( BoardOutline_LCORE_2 )

◆ BOOST_AUTO_TEST_CASE() [4/5]

BOOST_AUTO_TEST_CASE ( BoardOutline_LCORE_4 )

◆ BOOST_AUTO_TEST_CASE() [5/5]

BOOST_AUTO_TEST_CASE ( BoardOutline_OtherVersions )

◆ CheckCountWithTolerance()

static void CheckCountWithTolerance ( const std::string & aLabel,
size_t aBinaryCount,
size_t aAscCount,
bool aDifferentRevision )
static

Compare counts with tolerance for binary/ASC differences.

Different-revision files get BOOST_WARN only. Same-revision files allow up to 5% or off-by-2, with exact matches reported via BOOST_WARN.

Definition at line 152 of file test_pads_binary_import.cpp.

◆ CountEdgeCutsShapes()

static int CountEdgeCutsShapes ( const BOARD * aBoard)
static

◆ GetAscPath()

static wxString GetAscPath ( const PADS_BINARY_BOARD_INFO & aBoard)
static

◆ GetBinaryPath()

static wxString GetBinaryPath ( const PADS_BINARY_BOARD_INFO & aBoard)
static

◆ LoadAsc()

static std::unique_ptr< BOARD > LoadAsc ( const PADS_BINARY_BOARD_INFO & aBoard)
static

◆ LoadBinary()

static std::unique_ptr< BOARD > LoadBinary ( const PADS_BINARY_BOARD_INFO & aBoard)
static

Load a binary .pcb file.

Returns nullptr and issues a warning if the load throws, since the parser is under active development. Callers must null-check.

Definition at line 82 of file test_pads_binary_import.cpp.

References PCB_IO_PADS_BINARY::CanReadBoard(), PADS_BINARY_BOARD_INFO::dir, GetBinaryPath(), and PCB_IO_PADS_BINARY::LoadBoard().

Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and BOOST_AUTO_TEST_CASE().

◆ RunStructuralChecks()

static void RunStructuralChecks ( const PADS_BINARY_BOARD_INFO & aBoard,
const BOARD * aBinaryBoard )
static

Structural integrity checks.

Uses BOOST_CHECK for invariants and BOOST_WARN for in-progress features.

Definition at line 189 of file test_pads_binary_import.cpp.

References PADSTACK::ALL_LAYERS, PADS_BINARY_BOARD_INFO::dir, BOARD::Footprints(), IsCopperLayer(), pad, PCB_ARC_T, PCB_TRACE_T, THROUGH, BOARD::Tracks(), and via.

Variable Documentation

◆ PADS_BINARY_BOARDS

const PADS_BINARY_BOARD_INFO PADS_BINARY_BOARDS[]
static
Initial value:
= {
{ "TMS1mmX19", "TMS1mmX19.pcb", "TMS1mmX19.asc", false },
{ "MC4_PLUS_CSHAPE", "MC4_PLUS_CSHAPE.pcb", "MC4_PLUS_CSHAPE.asc", false },
{ "MC2_PLUS_REV1", "MC2_PLUS_REV1.pcb", "MC2_PLUS_REV1.asc", true },
{ "Ems4_Rev2", "Ems4_Rev2.pcb", "Ems4_Rev2.asc", false },
{ "LCORE_4", "LCORE_4.pcb", "LCORE_4.asc", false },
{ "LCORE_2", "LCORE_2.pcb", "LCORE_2.asc", false },
{ "Dexter_MotorCtrl", "Dexter_MotorCtrl.pcb", "Dexter_MotorCtrl.asc", true },
{ "MAIS_FC", "MAIS_FC.pcb", "MAIS_FC.asc", true },
}

Definition at line 53 of file test_pads_binary_import.cpp.

Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and BOOST_AUTO_TEST_CASE().