KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_pads_binary_import.cpp File Reference
#include <memory>
#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 <pcb_io/pads/pads_binary_parser.h>
#include <pcb_io/pads/pads_parser.h>
#include <pcb_io/pads/pads_pcb_converter.h>
#include <io/pads/pads_unit_converter.h>
#include <pcb_io/pads/pads_sdb.h>
#include <io/pads/pads_binary_utils.h>
#include <io/pads/pads_common.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 <pcb_group.h>
#include <pcb_dimension.h>
#include <footprint.h>
#include <netinfo.h>
#include <zone.h>
#include <board_design_settings.h>
#include <board_stackup_manager/board_stackup.h>
#include <netclass.h>
#include <project/net_settings.h>
#include <algorithm>
#include <array>
#include <chrono>
#include <cstdlib>
#include <filesystem>
#include <fstream>
#include <functional>
#include <iomanip>
#include <map>
#include <optional>
#include <set>
#include <sstream>
#include <tuple>
#include <utility>
#include <vector>
#include <wx/filename.h>
#include <wx/ffile.h>

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 NET_NAMES_EXACT_TEST(name, idx)
 
#define ROUTED_TRACKS_TEST(name, idx)
 
#define STRUCTURAL_INTEGRITY_TEST(name, idx)
 
#define ZONE_COUNT_TEST(name, idx)
 
#define FREE_TEXT_COUNT_TEST(name, idx)
 
#define FREE_TEXT_EXACT_TEST(name, idx)
 Free-text extraction is solved for these boards (sec5/sec8 text-header stream with metadata lagging geometry by one record slot).
 
#define PAD_COUNT_TEST(name, idx)
 
#define PER_FOOTPRINT_CONTENT_TEST(name, idx, maxNameWrong, maxCountWrong)
 Per-footprint content correctness over the RESOLVED set.
 
#define WIDTH_VARIETY_TEST(name, idx)
 Verify that the binary import produces multiple distinct track widths when the ASCII reference file has multiple widths.
 

Functions

static wxString GetBinaryPath (const PADS_BINARY_BOARD_INFO &aBoard)
 
static wxString GetAscPath (const PADS_BINARY_BOARD_INFO &aBoard)
 
static std::shared_ptr< BOARDCachedLoad (const wxString &aFilename, bool aBinary)
 Load a binary .pcb file.
 
static std::shared_ptr< BOARDLoadBinary (const PADS_BINARY_BOARD_INFO &aBoard)
 
static std::shared_ptr< BOARDLoadBinaryPath (const wxString &aFilename, const std::string &aLabel)
 
static std::shared_ptr< BOARDLoadAsc (const PADS_BINARY_BOARD_INFO &aBoard)
 
static std::shared_ptr< BOARDLoadAscPath (const wxString &aFilename, const std::string &aLabel)
 
static std::pair< size_t, size_t > ExactLayeredTrackMatches (const wxString &aBinaryPath, const wxString &aAsciiPath, const std::string &aLabel)
 
static std::pair< size_t, size_t > ExactNettedTrackMatches (const wxString &aBinaryPath, const wxString &aAsciiPath, const std::string &aLabel)
 
static std::pair< size_t, size_t > ExactViaMatches (const wxString &aBinaryPath, const wxString &aAsciiPath, const std::string &aLabel)
 
static int CountEdgeCutsShapes (const BOARD *aBoard)
 
static size_t CountVias (const std::shared_ptr< BOARD > &aBoard)
 
static size_t CountTraces (const std::shared_ptr< BOARD > &aBoard)
 
static FOOTPRINTFindFootprintByReference (const BOARD *aBoard, const wxString &aReference)
 
static std::set< wxString > BoardNetNames (const BOARD *aBoard)
 
static wxString JoinNetSet (const std::set< wxString > &aNames)
 
static std::vector< std::string > CanonicalGeometryRows (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 (CanonicalGeometryRowsCoverPadsTracksAndVias)
 
 BOOST_AUTO_TEST_CASE (RouteObjectClassDoesNotDependOnCachedBounds)
 
 BOOST_AUTO_TEST_CASE (BinaryFileDetection)
 
 BOOST_AUTO_TEST_CASE (AsciiFileRejection)
 
 BOOST_AUTO_TEST_CASE (UnroutedBoardHasNoTracksOrVias_TMS1mmX19)
 
 BOOST_AUTO_TEST_CASE (UnroutedBoardHasNoTracksOrVias_MC4_PLUS_CSHAPE)
 
static size_t DistinctPadGeometries (BOARD *aBoard)
 
 BOOST_AUTO_TEST_CASE (PerPinPadStackGeometry_MC4_PLUS_CSHAPE)
 
 BOOST_AUTO_TEST_CASE (StructuralRoutesAndVias_LCORE_4)
 
 BOOST_AUTO_TEST_CASE (StructuralRoutesAndVias_LCORE_2)
 
 BOOST_AUTO_TEST_CASE (ViaCountAtLeast_Ems4_Rev2)
 
 BOOST_AUTO_TEST_CASE (BoardOutline_LCORE_4)
 
 BOOST_AUTO_TEST_CASE (BoardOutline_LCORE_2)
 
 BOOST_AUTO_TEST_CASE (BoardOutline_OtherVersions)
 
static BOX2I EdgeCutsBBox (const BOARD *aBoard)
 
static int CountEdgeCutsArcs (const BOARD *aBoard)
 
static void CheckArcOutlineMatchesAsc (int aIdx)
 
 BOOST_AUTO_TEST_CASE (ArcBoardOutline_MC4_PLUS_CSHAPE)
 
 BOOST_AUTO_TEST_CASE (ArcBoardOutline_LCORE_4)
 
 BOOST_AUTO_TEST_CASE (ArcBoardOutline_LCORE_2)
 
 BOOST_AUTO_TEST_CASE (BoardOutlineCorrectOrAbsent)
 
 BOOST_AUTO_TEST_CASE (ZoneCountExact_MC4_PLUS_CSHAPE)
 
 BOOST_AUTO_TEST_CASE (ZoneCountExact_Ems4_Rev2)
 
 BOOST_AUTO_TEST_CASE (CopperShapeLevelsUseSerializedSuccessorField)
 
 BOOST_AUTO_TEST_CASE (ZoneCountExact_LCORE_4)
 
 BOOST_AUTO_TEST_CASE (ZoneCountExact_LCORE_2)
 
static size_t CountFreeTexts (const BOARD *aBoard)
 
static bool HasFreeText (const BOARD *aBoard, const wxString &aText)
 
 BOOST_AUTO_TEST_CASE (FreeTextRejectsClusterNames_MC4_PLUS_CSHAPE)
 
 BOOST_AUTO_TEST_CASE (FreeTextUsesDeclaredSection8Ring)
 
 BOOST_AUTO_TEST_CASE (SectionBoundaryPlacement_TMS1mmX19_SM3)
 
 BOOST_AUTO_TEST_CASE (V2021_PadImport_MAIS_FC)
 v0x2021 pad import (Dexter_MotorCtrl, MAIS_FC).
 
 BOOST_AUTO_TEST_CASE (V2021_PadImport_Dexter_MotorCtrl)
 
 BOOST_AUTO_TEST_CASE (V2021_PartPlacement_MAIS_FC)
 Verify the v0x2021 placement Y coordinate, orientation and side.
 
 BOOST_AUTO_TEST_CASE (PadCountExact_MC4_PLUS_CSHAPE)
 
 BOOST_AUTO_TEST_CASE (PadCountExact_Ems4_Rev2)
 
 BOOST_AUTO_TEST_CASE (PadCountExact_LCORE_4)
 
 BOOST_AUTO_TEST_CASE (StructuralZoneVertices)
 Geometric regression guard for the structural copper/keepout vertex link.
 
 BOOST_AUTO_TEST_CASE (FixedStringKeepsHighBytes)
 
 BOOST_AUTO_TEST_CASE (FixedStringRejectsControlAndKeepsLeadingSpace)
 
 BOOST_AUTO_TEST_CASE (DecalNameTableRejectsOversizedCount)
 
 BOOST_AUTO_TEST_CASE (PadStackShapeEnum_OblongDecoded)
 Section-4 pad-shape enum decode.
 
 BOOST_AUTO_TEST_CASE (DedupePoolTerminalPositions_MC4)
 De-duplicated passive terminal positions (the sec14 trailer pool + sec15 unified stream, addressed by the per-decal +68 cursor in the decal-name header table).
 
 BOOST_AUTO_TEST_CASE (ClusterGroups_MC4_PLUS_CSHAPE)
 PADS CLUSTER part groups become KiCad PCB_GROUPs.
 
 BOOST_AUTO_TEST_CASE (ModernConnectionsUseDeclaredSection24Ring)
 
 BOOST_AUTO_TEST_CASE (ModernConnectionsRequireSerializedFinalEdgeHead)
 
 BOOST_AUTO_TEST_CASE (LegacyConnectionsRequireDeclaredRingMarker)
 
 BOOST_AUTO_TEST_CASE (SdbContainerDecode)
 Direct coverage of the SDB database container: the header, the section directory and the coordinate origin decoded from a known board, independent of the board-level import.
 
 BOOST_AUTO_TEST_CASE (SdbPagedControllersUseSerializedPageCounts)
 
 BOOST_AUTO_TEST_CASE (SdbRouteRuleSlotLivenessUsesSerializedSlotState)
 
 BOOST_AUTO_TEST_CASE (SdbStringPoolUsesDeclaredSection57Extent)
 
 BOOST_AUTO_TEST_CASE (SdbGraphicControllersUseDeclaredCircularExtents)
 
 BOOST_AUTO_TEST_CASE (PourOwnersUseDeclaredSection52Array)
 
 BOOST_AUTO_TEST_CASE (SdbCorpusVersionsAreRecognized)
 
 BOOST_AUTO_TEST_CASE (SdbRejectsUnclaimedBodyByte)
 
 BOOST_AUTO_TEST_CASE (RouteObjectsRejectZeroCountWithSerializedBytes)
 
 BOOST_AUTO_TEST_CASE (VersionedLayerTablesUseSerializedNamesAndCounts)
 
 BOOST_AUTO_TEST_CASE (DirectPlacementArraysUseSerializedCountsAndOrder)
 
 BOOST_AUTO_TEST_CASE (SdbFooterStoresContainerItemBackPointer)
 
 BOOST_AUTO_TEST_CASE (SdbRejectsContainerBackPointerInsideFooter)
 
 BOOST_AUTO_TEST_CASE (OriginBaseIsDeclaredNotSearched)
 The board-setup block is reached by arithmetic on two declared counts, not by sweeping section 1 for a field-range signature.
 
 BOOST_AUTO_TEST_CASE (CorruptDeclaredOriginDoesNotRelocateToDftMarker)
 
static std::string FlattenPath (const std::filesystem::path &aRoot, const std::filesystem::path &aFile)
 
 BOOST_AUTO_TEST_CASE (ExactViaGeometryMatchesAscii)
 
 BOOST_AUTO_TEST_CASE (ViaSpanSurvivesOnlyWhenTypeSetFirst)
 
 BOOST_AUTO_TEST_CASE (BinaryPadConnectionMatchesAsc)
 A PADS pour connects solid and an individual pad asks for plane relief through an RT/ST padstack row, so relief is a per-pad property.
 
 BOOST_AUTO_TEST_CASE (PadstackRowsMatchAsciiAcross2022And2027)
 
 BOOST_AUTO_TEST_CASE (ThroughHolePadsAreNotTented)
 A PADS through-hole pad opens the soldermask on both outer layers.
 
 BOOST_AUTO_TEST_CASE (ThermalReliefRowsReachBinaryPads)
 RT/ST rows say the pad connects to a plane through relief spokes and RA/SA rows are anti-pad clearances.
 
 BOOST_AUTO_TEST_CASE (DimensionLeaderWidthIsUnitModeIndependent)
 A dimension leader is a real line on the board.
 
 BOOST_AUTO_TEST_CASE (AsciiCodePageNetclassNamesSurvive)
 PADS ASCII is an 8-bit codepage file.
 

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] ); \
\
BOOST_CHECK( board->Footprints().size() > 0 ); \
}
const char * name
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
static std::shared_ptr< BOARD > LoadBinary(const PADS_BINARY_BOARD_INFO &aBoard)
static const PADS_BINARY_BOARD_INFO PADS_BINARY_BOARDS[]

Definition at line 824 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] ); \
\
auto asc = LoadAsc( PADS_BINARY_BOARDS[idx] ); \
\
CheckCountWithTolerance( #name " footprints", bin->Footprints().size(), asc->Footprints().size(), \
PADS_BINARY_BOARDS[idx].differentRevision ); \
}
static std::shared_ptr< BOARD > LoadAsc(const PADS_BINARY_BOARD_INFO &aBoard)

Definition at line 842 of file test_pads_binary_import.cpp.

◆ FREE_TEXT_COUNT_TEST

#define FREE_TEXT_COUNT_TEST ( name,
idx )
Value:
BOOST_AUTO_TEST_CASE( FreeTextCount_##name ) \
{ \
auto bin = LoadBinary( PADS_BINARY_BOARDS[idx] ); \
\
auto asc = LoadAsc( PADS_BINARY_BOARDS[idx] ); \
\
size_t binTexts = CountFreeTexts( bin.get() ); \
size_t ascTexts = CountFreeTexts( asc.get() ); \
\
BOOST_WARN_MESSAGE( binTexts == ascTexts, \
#name " free text count: binary=" << binTexts << " asc=" << ascTexts \
<< " (text extraction incomplete)" ); \
}
static size_t CountFreeTexts(const BOARD *aBoard)

Definition at line 1375 of file test_pads_binary_import.cpp.

◆ FREE_TEXT_EXACT_TEST

#define FREE_TEXT_EXACT_TEST ( name,
idx )
Value:
BOOST_AUTO_TEST_CASE( FreeTextExact_##name ) \
{ \
auto bin = LoadBinary( PADS_BINARY_BOARDS[idx] ); \
\
auto asc = LoadAsc( PADS_BINARY_BOARDS[idx] ); \
\
BOOST_CHECK_EQUAL( CountFreeTexts( bin.get() ), CountFreeTexts( asc.get() ) ); \
}

Free-text extraction is solved for these boards (sec5/sec8 text-header stream with metadata lagging geometry by one record slot).

The binary importer reproduces the ASCII free-text count exactly, so lock it in with a hard check to catch regressions. Boards still under development stay on BOOST_WARN above.

Definition at line 1406 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] ); \
\
auto asc = LoadAsc( PADS_BINARY_BOARDS[idx] ); \
\
CheckCountWithTolerance( #name " nets", bin->GetNetCount(), asc->GetNetCount(), \
PADS_BINARY_BOARDS[idx].differentRevision ); \
}

Definition at line 863 of file test_pads_binary_import.cpp.

◆ NET_NAMES_EXACT_TEST

#define NET_NAMES_EXACT_TEST ( name,
idx )
Value:
BOOST_AUTO_TEST_CASE( NetNamesExact_##name ) \
{ \
auto bin = LoadBinary( PADS_BINARY_BOARDS[idx] ); \
\
auto binNames = BoardNetNames( bin.get() ); \
auto asc = LoadAsc( PADS_BINARY_BOARDS[idx] ); \
auto ascNames = BoardNetNames( asc.get() ); \
\
std::set<wxString> missing; \
std::set_difference( ascNames.begin(), ascNames.end(), binNames.begin(), binNames.end(), \
std::inserter( missing, missing.begin() ) ); \
\
std::set<wxString> extra; \
std::set_difference( binNames.begin(), binNames.end(), ascNames.begin(), ascNames.end(), \
std::inserter( extra, extra.begin() ) ); \
\
BOOST_CHECK_MESSAGE( missing.empty(), #name " missing binary nets: " << JoinNetSet( missing ) ); \
BOOST_CHECK_MESSAGE( extra.empty(), #name " extra binary nets: " << JoinNetSet( extra ) ); \
}
static wxString JoinNetSet(const std::set< wxString > &aNames)
static std::set< wxString > BoardNetNames(const BOARD *aBoard)

Definition at line 884 of file test_pads_binary_import.cpp.

◆ PAD_COUNT_TEST

#define PAD_COUNT_TEST ( name,
idx )
Value:
BOOST_AUTO_TEST_CASE( PadCount_##name ) \
{ \
auto bin = LoadBinary( PADS_BINARY_BOARDS[idx] ); \
\
auto asc = LoadAsc( PADS_BINARY_BOARDS[idx] ); \
\
size_t binPads = 0; \
size_t ascPads = 0; \
\
for( FOOTPRINT * fp : bin->Footprints() ) \
binPads += fp->Pads().size(); \
\
for( FOOTPRINT * fp : asc->Footprints() ) \
ascPads += fp->Pads().size(); \
\
BOOST_WARN_MESSAGE( binPads == ascPads, \
#name " pad count: binary=" << binPads << " asc=" << ascPads \
<< " (part-to-decal linking incomplete)" ); \
}

Definition at line 1473 of file test_pads_binary_import.cpp.

◆ PER_FOOTPRINT_CONTENT_TEST

#define PER_FOOTPRINT_CONTENT_TEST ( name,
idx,
maxNameWrong,
maxCountWrong )

Per-footprint content correctness over the RESOLVED set.

A binary footprint is "resolved" when the placement -> parttype -> decal chain assigned it a decal, i.e. its library name differs from its own reference designator (the graceful fallback used for the small constant set of placements that are absent from section 22).

For each resolved footprint that also exists in the ASCII import, the binary decal (footprint library name) must match the ASCII decal, and the binary pad count must equal the ASCII pad count. This proves the chain is content-correct, not merely that aggregate totals happen to line up.

Definition at line 1505 of file test_pads_binary_import.cpp.

◆ ROUTED_TRACKS_TEST

#define ROUTED_TRACKS_TEST ( name,
idx )
Value:
BOOST_AUTO_TEST_CASE( RoutedTracks_##name ) \
{ \
auto bin = LoadBinary( PADS_BINARY_BOARDS[idx] ); \
\
BOOST_CHECK_GT( CountTraces( bin ), 0u ); \
}
static size_t CountTraces(const std::shared_ptr< BOARD > &aBoard)

Definition at line 912 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] ); \
\
RunStructuralChecks( PADS_BINARY_BOARDS[idx], board.get() ); \
}

Definition at line 1209 of file test_pads_binary_import.cpp.

◆ WIDTH_VARIETY_TEST

#define WIDTH_VARIETY_TEST ( name,
idx )
Value:
BOOST_AUTO_TEST_CASE( TrackWidthVariety_##name ) \
{ \
auto bin = LoadBinary( PADS_BINARY_BOARDS[idx] ); \
\
auto asc = LoadAsc( PADS_BINARY_BOARDS[idx] ); \
\
std::set<int> binWidths; \
std::set<int> ascWidths; \
\
for( PCB_TRACK * trk : bin->Tracks() ) \
{ \
if( trk->Type() == PCB_TRACE_T ) \
binWidths.insert( trk->GetWidth() ); \
} \
\
for( PCB_TRACK * trk : asc->Tracks() ) \
{ \
if( trk->Type() == PCB_TRACE_T ) \
ascWidths.insert( trk->GetWidth() ); \
} \
\
if( ascWidths.size() > 1 ) \
{ \
BOOST_WARN_MESSAGE( binWidths.size() > 1, #name " binary should have multiple distinct track widths " \
"(found " \
<< binWidths.size() << ", ASCII has " \
<< ascWidths.size() << ")" ); \
} \
}
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)
Definition typeinfo.h:88

Verify that the binary import produces multiple distinct track widths when the ASCII reference file has multiple widths.

This validates per-segment width resolution from sec62 rather than defaulting everything to one width.

Definition at line 1852 of file test_pads_binary_import.cpp.

◆ ZONE_COUNT_TEST

#define ZONE_COUNT_TEST ( name,
idx )
Value:
BOOST_AUTO_TEST_CASE( ZoneCount_##name ) \
{ \
auto bin = LoadBinary( PADS_BINARY_BOARDS[idx] ); \
\
auto asc = LoadAsc( PADS_BINARY_BOARDS[idx] ); \
\
size_t binZones = bin->Zones().size(); \
size_t ascZones = asc->Zones().size(); \
\
if( PADS_BINARY_BOARDS[idx].differentRevision ) \
{ \
BOOST_WARN_MESSAGE( binZones > 0, #name " binary zone count: " << binZones << " (different revision)" ); \
} \
else \
{ \
BOOST_WARN_MESSAGE( binZones == ascZones, \
#name " zone count: binary=" << binZones << " asc=" << ascZones ); \
} \
}

Definition at line 1217 of file test_pads_binary_import.cpp.

Function Documentation

◆ BoardNetNames()

static std::set< wxString > BoardNetNames ( const BOARD * aBoard)
static

Definition at line 502 of file test_pads_binary_import.cpp.

References BOARD::GetNetInfo().

◆ BOOST_AUTO_TEST_CASE() [1/64]

BOOST_AUTO_TEST_CASE ( ArcBoardOutline_LCORE_2 )

Definition at line 1144 of file test_pads_binary_import.cpp.

References CheckArcOutlineMatchesAsc().

◆ BOOST_AUTO_TEST_CASE() [2/64]

BOOST_AUTO_TEST_CASE ( ArcBoardOutline_LCORE_4 )

Definition at line 1138 of file test_pads_binary_import.cpp.

References CheckArcOutlineMatchesAsc().

◆ BOOST_AUTO_TEST_CASE() [3/64]

BOOST_AUTO_TEST_CASE ( ArcBoardOutline_MC4_PLUS_CSHAPE )

Definition at line 1132 of file test_pads_binary_import.cpp.

References CheckArcOutlineMatchesAsc().

◆ BOOST_AUTO_TEST_CASE() [4/64]

BOOST_AUTO_TEST_CASE ( AsciiCodePageNetclassNamesSurvive )

PADS ASCII is an 8-bit codepage file.

wxString::FromUTF8 returns an empty string on the first high byte, so a net class named in CP1252 imports under a blank key and swallows its nets.

Definition at line 3308 of file test_pads_binary_import.cpp.

References BOOST_REQUIRE(), KI_TEST::GetPcbnewTestDataDir(), LoadAscPath(), name, and path.

◆ BOOST_AUTO_TEST_CASE() [5/64]

BOOST_AUTO_TEST_CASE ( AsciiFileRejection )

◆ BOOST_AUTO_TEST_CASE() [6/64]

BOOST_AUTO_TEST_CASE ( BinaryFileDetection )

◆ BOOST_AUTO_TEST_CASE() [7/64]

BOOST_AUTO_TEST_CASE ( BinaryPadConnectionMatchesAsc )

A PADS pour connects solid and an individual pad asks for plane relief through an RT/ST padstack row, so relief is a per-pad property.

Both dialects describe the same design and must agree on which pads carry it, and on how each pour connects.

Before the binary reader decoded RT/ST it dropped those rows and compensated by making every pour THERMAL, forcing relief onto pads that PADS connects solid.

Definition at line 3017 of file test_pads_binary_import.cpp.

References BOOST_AUTO_TEST_CASE(), BOOST_REQUIRE(), BOOST_TEST_CONTEXT(), FULL, LoadAsc(), LoadBinary(), pad, PADS_BINARY_BOARDS, and THERMAL.

◆ BOOST_AUTO_TEST_CASE() [8/64]

BOOST_AUTO_TEST_CASE ( BoardOutline_LCORE_2 )

◆ BOOST_AUTO_TEST_CASE() [9/64]

BOOST_AUTO_TEST_CASE ( BoardOutline_LCORE_4 )

◆ BOOST_AUTO_TEST_CASE() [10/64]

BOOST_AUTO_TEST_CASE ( BoardOutline_OtherVersions )

◆ BOOST_AUTO_TEST_CASE() [11/64]

◆ BOOST_AUTO_TEST_CASE() [12/64]

BOOST_AUTO_TEST_CASE ( CanonicalGeometryRowsCoverPadsTracksAndVias )

◆ BOOST_AUTO_TEST_CASE() [13/64]

BOOST_AUTO_TEST_CASE ( ClusterGroups_MC4_PLUS_CSHAPE )

PADS CLUSTER part groups become KiCad PCB_GROUPs.

MC4_PLUS_CSHAPE (v0x2027) carries two clusters in its .asc CLUSTER section: CLU_DCDC5V (CLSTID 1, 16 parts) and CLU_DCDC3V3 (CLSTID 2, 16 parts). The binary decode (sec22 +108 CLSTID -> 60-byte cluster-table ordinal -> name) must reproduce both named groups with their exact 16-member footprint sets.

Definition at line 2152 of file test_pads_binary_import.cpp.

References BOOST_REQUIRE(), group, LoadBinary(), and PCB_FOOTPRINT_T.

◆ BOOST_AUTO_TEST_CASE() [14/64]

BOOST_AUTO_TEST_CASE ( CopperShapeLevelsUseSerializedSuccessorField )

◆ BOOST_AUTO_TEST_CASE() [15/64]

◆ BOOST_AUTO_TEST_CASE() [16/64]

BOOST_AUTO_TEST_CASE ( DecalNameTableRejectsOversizedCount )

◆ BOOST_AUTO_TEST_CASE() [17/64]

BOOST_AUTO_TEST_CASE ( DedupePoolTerminalPositions_MC4 )

De-duplicated passive terminal positions (the sec14 trailer pool + sec15 unified stream, addressed by the per-decal +68 cursor in the decal-name header table).

The high-volume 2-pin passives (0402/0603/...) are de-duplicated out of section 15 and previously imported with their pads stacked at the origin (the synthesizePlaceholderTerminals fallback). The +68 cursor recovers each decal's exact decal-local terminal window. Values here are the binary-decoded positions, independently confirmed against the MC4 ASC PARTDECAL terminals.

Definition at line 2099 of file test_pads_binary_import.cpp.

References BOOST_CHECK_EQUAL(), BOOST_TEST_CONTEXT(), PADS_IO::BINARY_PARSER::GetPartDecals(), KI_TEST::GetPcbnewTestDataDir(), name, and PADS_IO::BINARY_PARSER::Parse().

◆ BOOST_AUTO_TEST_CASE() [18/64]

BOOST_AUTO_TEST_CASE ( DimensionLeaderWidthIsUnitModeIndependent )

A dimension leader is a real line on the board.

Its default width must not depend on which unit mode the shared converter happens to be in: the binary reader runs it in BASIC units, where a mils-valued constant scales down to a few nanometres.

Definition at line 3270 of file test_pads_binary_import.cpp.

References PADS_UNIT_CONVERTER::BASIC_TO_NM, BOOST_CHECK_EQUAL(), BOOST_REQUIRE(), BOOST_TEST_CONTEXT(), PADS_IO::DIMENSION::crossbar_pos, BOARD::Drawings(), PCB_DIMENSION_BASE::GetLineThickness(), PADS_IO::DIMENSION::is_horizontal, PADS_PCB_CONVERTER::LoadDimensions(), PADS_UNIT_CONVERTER::MILS_TO_NM, pcbIUScale, PADS_IO::DIMENSION::points, PADS_UNIT_CONVERTER::SetBasicUnitsMode(), PADS_PCB_CONVERTER::SetScaleFactor(), and PADS_PCB_CONVERTER::UnitConverter().

◆ BOOST_AUTO_TEST_CASE() [19/64]

BOOST_AUTO_TEST_CASE ( DirectPlacementArraysUseSerializedCountsAndOrder )

◆ BOOST_AUTO_TEST_CASE() [20/64]

BOOST_AUTO_TEST_CASE ( ExactViaGeometryMatchesAscii )

◆ BOOST_AUTO_TEST_CASE() [21/64]

BOOST_AUTO_TEST_CASE ( FixedStringKeepsHighBytes )

◆ BOOST_AUTO_TEST_CASE() [22/64]

BOOST_AUTO_TEST_CASE ( FixedStringRejectsControlAndKeepsLeadingSpace )

◆ BOOST_AUTO_TEST_CASE() [23/64]

BOOST_AUTO_TEST_CASE ( FreeTextRejectsClusterNames_MC4_PLUS_CSHAPE )

◆ BOOST_AUTO_TEST_CASE() [24/64]

◆ BOOST_AUTO_TEST_CASE() [25/64]

◆ BOOST_AUTO_TEST_CASE() [26/64]

◆ BOOST_AUTO_TEST_CASE() [27/64]

◆ BOOST_AUTO_TEST_CASE() [28/64]

BOOST_AUTO_TEST_CASE ( OriginBaseIsDeclaredNotSearched )

The board-setup block is reached by arithmetic on two declared counts, not by sweeping section 1 for a field-range signature.

The origin lives at that base +60/+64 and shifts every absolute coordinate in the file, so this pins the most load-bearing offset in the container.

Recomputing the base here from the raw bytes keeps the test independent of the reader: a change that reintroduces a search would still have to land on the declared offset.

Definition at line 2820 of file test_pads_binary_import.cpp.

References BOOST_CHECK_EQUAL(), BOOST_REQUIRE(), BOOST_TEST_CONTEXT(), PADS_IO::PADS_SDB::Coords(), expected, PADS_IO::SDB_COORDS::Found(), KI_TEST::GetPcbnewTestDataDir(), PADS_IO::SDB_COORDS::HeaderBase(), PADS_IO::PADS_SDB::Load(), path, and PADS_IO::ReadFileToBuffer().

◆ BOOST_AUTO_TEST_CASE() [29/64]

BOOST_AUTO_TEST_CASE ( PadCountExact_Ems4_Rev2 )

◆ BOOST_AUTO_TEST_CASE() [30/64]

BOOST_AUTO_TEST_CASE ( PadCountExact_LCORE_4 )

◆ BOOST_AUTO_TEST_CASE() [31/64]

BOOST_AUTO_TEST_CASE ( PadCountExact_MC4_PLUS_CSHAPE )

◆ BOOST_AUTO_TEST_CASE() [32/64]

◆ BOOST_AUTO_TEST_CASE() [33/64]

BOOST_AUTO_TEST_CASE ( PadStackShapeEnum_OblongDecoded )

Section-4 pad-shape enum decode.

The shape code is an enum {0:OF, 1:RF, 2:R, 3:S}; the earlier map left code 0 unmapped so every oblong (OF) padstack was imported as round. TMS1mmX19 and MC4_PLUS_CSHAPE both carry code-0 oblong padstacks, so the decoded shape set must contain "OF". Asserted at the parser level because the importer currently assigns a single default padstack per decal, which would mask the per-padstack shape.

Definition at line 2062 of file test_pads_binary_import.cpp.

References BOOST_TEST_CONTEXT(), PADS_IO::BINARY_PARSER::GetPadStackShapesForTest(), KI_TEST::GetPcbnewTestDataDir(), and PADS_IO::BINARY_PARSER::Parse().

◆ BOOST_AUTO_TEST_CASE() [34/64]

BOOST_AUTO_TEST_CASE ( PerPinPadStackGeometry_MC4_PLUS_CSHAPE )

◆ BOOST_AUTO_TEST_CASE() [35/64]

◆ BOOST_AUTO_TEST_CASE() [36/64]

◆ BOOST_AUTO_TEST_CASE() [37/64]

BOOST_AUTO_TEST_CASE ( RouteObjectsRejectZeroCountWithSerializedBytes )

◆ BOOST_AUTO_TEST_CASE() [38/64]

◆ BOOST_AUTO_TEST_CASE() [39/64]

BOOST_AUTO_TEST_CASE ( SdbCorpusVersionsAreRecognized )

◆ BOOST_AUTO_TEST_CASE() [40/64]

BOOST_AUTO_TEST_CASE ( SdbFooterStoresContainerItemBackPointer )

Definition at line 2763 of file test_pads_binary_import.cpp.

References PADS_IO::ValidateSdbFooter().

◆ BOOST_AUTO_TEST_CASE() [41/64]

◆ BOOST_AUTO_TEST_CASE() [42/64]

◆ BOOST_AUTO_TEST_CASE() [43/64]

BOOST_AUTO_TEST_CASE ( SdbRejectsContainerBackPointerInsideFooter )

◆ BOOST_AUTO_TEST_CASE() [44/64]

BOOST_AUTO_TEST_CASE ( SdbRejectsUnclaimedBodyByte )

◆ BOOST_AUTO_TEST_CASE() [45/64]

◆ BOOST_AUTO_TEST_CASE() [46/64]

◆ BOOST_AUTO_TEST_CASE() [47/64]

◆ BOOST_AUTO_TEST_CASE() [48/64]

BOOST_AUTO_TEST_CASE ( StructuralRoutesAndVias_LCORE_2 )

◆ BOOST_AUTO_TEST_CASE() [49/64]

BOOST_AUTO_TEST_CASE ( StructuralRoutesAndVias_LCORE_4 )

◆ BOOST_AUTO_TEST_CASE() [50/64]

BOOST_AUTO_TEST_CASE ( StructuralZoneVertices )

Geometric regression guard for the structural copper/keepout vertex link.

Copper and keepout zone polygons are sliced out of the sec12 vertex pool by each owner's structural vertexStart cursor read from the directly framed circular owner array, not by bounding-box matching. A wrong section-12 origin or a one-record owner-lag error leaves the zone COUNT intact while shifting every structural vertex, so the ZoneCountExact tests cannot catch it.

This test therefore probes the parser directly: it asserts the structural owner loop for named owners equals the design-coordinate vertices the validated shape-vertex-link harness produced (100% geometric ASC match across the v0x2025/26/27 corpus). It covers one owner per new-format version: MC4_PLUS_CSHAPE (v0x2027, a copper fill and an arc-ordinal keepout), Ems4_Rev2 (v0x2025, two copper fills) and LCORE_4 (v0x2026, a copper fill). No BR board (v0x2027) ships in the in-tree corpus; MC4 is the v0x2027 representative.

Definition at line 1908 of file test_pads_binary_import.cpp.

References BOOST_AUTO_TEST_CASE(), BOOST_CHECK_EQUAL(), BOOST_TEST_CONTEXT(), and KI_TEST::GetPcbnewTestDataDir().

◆ BOOST_AUTO_TEST_CASE() [51/64]

BOOST_AUTO_TEST_CASE ( ThermalReliefRowsReachBinaryPads )

RT/ST rows say the pad connects to a plane through relief spokes and RA/SA rows are anti-pad clearances.

The ASCII reader drops both from the copper geometry; the binary reader must reach the same conclusion on the same design.

Definition at line 3224 of file test_pads_binary_import.cpp.

References BOOST_REQUIRE(), KI_TEST::GetPcbnewTestDataDir(), LoadAscPath(), LoadBinaryPath(), pad, and THERMAL.

◆ BOOST_AUTO_TEST_CASE() [52/64]

BOOST_AUTO_TEST_CASE ( ThroughHolePadsAreNotTented )

A PADS through-hole pad opens the soldermask on both outer layers.

Importing it with a copper-only layer set tents every hole, so the fabrication output is wrong until the user repairs each footprint by hand. An unplated hole is mechanical: it carries no inner copper and no net.

Definition at line 3174 of file test_pads_binary_import.cpp.

References B_Mask, BOOST_TEST_CONTEXT(), F_Mask, LSET::InternalCuMask(), LoadAsc(), LoadBinary(), NPTH, pad, PADS_BINARY_BOARDS, and PTH.

◆ BOOST_AUTO_TEST_CASE() [53/64]

BOOST_AUTO_TEST_CASE ( UnroutedBoardHasNoTracksOrVias_MC4_PLUS_CSHAPE )

◆ BOOST_AUTO_TEST_CASE() [54/64]

BOOST_AUTO_TEST_CASE ( UnroutedBoardHasNoTracksOrVias_TMS1mmX19 )

◆ BOOST_AUTO_TEST_CASE() [55/64]

BOOST_AUTO_TEST_CASE ( V2021_PadImport_Dexter_MotorCtrl )

◆ BOOST_AUTO_TEST_CASE() [56/64]

BOOST_AUTO_TEST_CASE ( V2021_PadImport_MAIS_FC )

v0x2021 pad import (Dexter_MotorCtrl, MAIS_FC).

The v0x2021 dialect carries no parttype-definition layer, so the placement -> decal link is the direct decal index in the NEXT 96-byte placement record's +56, resolved against the JMPVIA_AAAAA-anchored 100-byte decal-name table (terminal count at record +72). The PCB_IO_PADS ASCII reader loads zero footprints for these revisions, so we score the binary import's own decoded pads against the .asc PARTDECAL/PART GOLD that the pure-binary RE harness verified (MAIS 43 exact; Dexter resolves the bulk of the placed set, with the small constant set of section-22-omitted connectors/LEDs getting footprints with no fabricated pads).

Definition at line 1585 of file test_pads_binary_import.cpp.

References BOOST_CHECK_EQUAL(), BOOST_TEST_MESSAGE(), expected, LoadBinary(), and PADS_BINARY_BOARDS.

◆ BOOST_AUTO_TEST_CASE() [57/64]

BOOST_AUTO_TEST_CASE ( V2021_PartPlacement_MAIS_FC )

Verify the v0x2021 placement Y coordinate, orientation and side.

The v0x2021 dialect frames its 96-byte placement records shifted +20 from the new dialect, putting Y immediately after X (xOff+4), the orientation at xOff+8 and the side flag at nameOff+28. Y was previously emitted as 0 (collapsing every part onto a single line) and the orientation was read from the lagged neighbour record. Ground truth is the MAIS_FC.asc PART section (the binary SetOrientation path does not negate the stored angle, so the placed orientation equals the ASC ORI value): J7 9000000 270 M J1 10800000 0 N J2 23663130 180 N J3 8785902 0 N J4 21216083 90 N

Definition at line 1695 of file test_pads_binary_import.cpp.

References std::abs(), EDA_ANGLE::AsDegrees(), FOOTPRINT::GetOrientation(), FOOTPRINT::IsFlipped(), LoadBinary(), EDA_ANGLE::Normalize(), and PADS_BINARY_BOARDS.

◆ BOOST_AUTO_TEST_CASE() [58/64]

BOOST_AUTO_TEST_CASE ( VersionedLayerTablesUseSerializedNamesAndCounts )

◆ BOOST_AUTO_TEST_CASE() [59/64]

BOOST_AUTO_TEST_CASE ( ViaCountAtLeast_Ems4_Rev2 )

◆ BOOST_AUTO_TEST_CASE() [60/64]

BOOST_AUTO_TEST_CASE ( ViaSpanSurvivesOnlyWhenTypeSetFirst )

◆ BOOST_AUTO_TEST_CASE() [61/64]

BOOST_AUTO_TEST_CASE ( ZoneCountExact_Ems4_Rev2 )

◆ BOOST_AUTO_TEST_CASE() [62/64]

BOOST_AUTO_TEST_CASE ( ZoneCountExact_LCORE_2 )

◆ BOOST_AUTO_TEST_CASE() [63/64]

BOOST_AUTO_TEST_CASE ( ZoneCountExact_LCORE_4 )

◆ BOOST_AUTO_TEST_CASE() [64/64]

BOOST_AUTO_TEST_CASE ( ZoneCountExact_MC4_PLUS_CSHAPE )

◆ CachedLoad()

static std::shared_ptr< BOARD > CachedLoad ( const wxString & aFilename,
bool aBinary )
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 111 of file test_pads_binary_import.cpp.

References PCB_IO::LoadBoard().

Referenced by LoadAsc(), LoadAscPath(), LoadBinary(), and LoadBinaryPath().

◆ CanonicalGeometryRows()

static std::vector< std::string > CanonicalGeometryRows ( const BOARD * aBoard)
static

◆ CheckArcOutlineMatchesAsc()

◆ 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 608 of file test_pads_binary_import.cpp.

◆ CountEdgeCutsArcs()

static int CountEdgeCutsArcs ( const BOARD * aBoard)
static

Definition at line 1081 of file test_pads_binary_import.cpp.

References ARC, BOARD::Drawings(), and Edge_Cuts.

Referenced by CheckArcOutlineMatchesAsc().

◆ CountEdgeCutsShapes()

static int CountEdgeCutsShapes ( const BOARD * aBoard)
static

◆ CountFreeTexts()

static size_t CountFreeTexts ( const BOARD * aBoard)
static

Definition at line 1347 of file test_pads_binary_import.cpp.

References BOARD::Drawings().

◆ CountTraces()

static size_t CountTraces ( const std::shared_ptr< BOARD > & aBoard)
static

◆ CountVias()

static size_t CountVias ( const std::shared_ptr< BOARD > & aBoard)
static

◆ DistinctPadGeometries()

static size_t DistinctPadGeometries ( BOARD * aBoard)
static

Definition at line 949 of file test_pads_binary_import.cpp.

References F_Cu, BOARD::Footprints(), pad, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by BOOST_AUTO_TEST_CASE().

◆ EdgeCutsBBox()

static BOX2I EdgeCutsBBox ( const BOARD * aBoard)
static

◆ ExactLayeredTrackMatches()

static std::pair< size_t, size_t > ExactLayeredTrackMatches ( const wxString & aBinaryPath,
const wxString & aAsciiPath,
const std::string & aLabel )
static

◆ ExactNettedTrackMatches()

static std::pair< size_t, size_t > ExactNettedTrackMatches ( const wxString & aBinaryPath,
const wxString & aAsciiPath,
const std::string & aLabel )
static

◆ ExactViaMatches()

static std::pair< size_t, size_t > ExactViaMatches ( const wxString & aBinaryPath,
const wxString & aAsciiPath,
const std::string & aLabel )
static

◆ FindFootprintByReference()

static FOOTPRINT * FindFootprintByReference ( const BOARD * aBoard,
const wxString & aReference )
static

Definition at line 490 of file test_pads_binary_import.cpp.

References BOARD::Footprints().

Referenced by BOOST_AUTO_TEST_CASE().

◆ FlattenPath()

static std::string FlattenPath ( const std::filesystem::path & aRoot,
const std::filesystem::path & aFile )
static

Definition at line 2913 of file test_pads_binary_import.cpp.

◆ GetAscPath()

static wxString GetAscPath ( const PADS_BINARY_BOARD_INFO & aBoard)
static

◆ GetBinaryPath()

◆ HasFreeText()

static bool HasFreeText ( const BOARD * aBoard,
const wxString & aText )
static

Definition at line 1361 of file test_pads_binary_import.cpp.

References BOARD::Drawings(), and text.

Referenced by BOOST_AUTO_TEST_CASE().

◆ JoinNetSet()

static wxString JoinNetSet ( const std::set< wxString > & aNames)
static

Definition at line 516 of file test_pads_binary_import.cpp.

References name.

◆ LoadAsc()

◆ LoadAscPath()

static std::shared_ptr< BOARD > LoadAscPath ( const wxString & aFilename,
const std::string & aLabel )
static

◆ LoadBinary()

◆ LoadBinaryPath()

static std::shared_ptr< BOARD > LoadBinaryPath ( const wxString & aFilename,
const std::string & aLabel )
static

◆ 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 641 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 80 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(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and CheckArcOutlineMatchesAsc().