KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_diptrace_sch_import.cpp File Reference

Test suite for import of DipTrace schematic (.dch) files. More...

Go to the source code of this file.

Functions

 BOOST_AUTO_TEST_CASE (CanReadSchematic)
 Test that CanReadSchematicFile correctly identifies DipTrace .dch files by their magic header bytes.
 
 BOOST_AUTO_TEST_CASE (V37Utf16SchematicLoadsWithContent)
 power_supply.dch is a v37 schematic that stores UTF-16-BE strings, which the legacy version threshold would mis-read as ASCII.
 
 BOOST_AUTO_TEST_CASE (InvalidComponentCountFailsDeterministically)
 
 BOOST_AUTO_TEST_CASE (ComponentRecordsAreParsedSequentially)
 
 BOOST_AUTO_TEST_CASE (NoSymbolLibraryFileIsGenerated)
 The importer must rely solely on the symbol definitions embedded in the schematic.
 
 BOOST_AUTO_TEST_CASE (ImportedRootIsTheSchematicTopLevelSheet)
 The imported content root must become the schematic's real top-level sheet.
 
 BOOST_AUTO_TEST_CASE (ViewerExampleComponentRecordsAreParsedSequentiallyOptional)
 
 BOOST_AUTO_TEST_CASE (ComponentCountMismatchFailsDeterministically)
 
 BOOST_AUTO_TEST_CASE (InvalidComponentPinCountFailsDeterministically)
 
 BOOST_AUTO_TEST_CASE (InvalidComponentExtraTailLengthFailsDeterministically)
 
 BOOST_AUTO_TEST_CASE (InvalidComponentPinRecordFailsDeterministically)
 
 BOOST_AUTO_TEST_CASE (InvalidLaterComponentPinRecordFailsDeterministically)
 
 BOOST_AUTO_TEST_CASE (InvalidComponentShapePointCountFailsDeterministically)
 
 BOOST_AUTO_TEST_CASE (ZeroComponentShapePointCountFailsDeterministically)
 
 BOOST_AUTO_TEST_CASE (InvalidBusEntryTerminatorFailsDeterministically)
 
 BOOST_AUTO_TEST_CASE (InvalidBusSectionCountFailsDeterministically)
 
 BOOST_AUTO_TEST_CASE (InvalidWireNetPinCountFailsDeterministically)
 
 BOOST_AUTO_TEST_CASE (InvalidWireNetNameLengthFailsDeterministically)
 
 BOOST_AUTO_TEST_CASE (InvalidWirePointCountFailsDeterministically)
 
 BOOST_AUTO_TEST_CASE (ImportChainIsClean)
 Importing a well-formed DipTrace schematic must run the full import chain without emitting any warnings or errors.
 
 BOOST_AUTO_TEST_CASE (CanReadLegacyHeaderOptional)
 
 BOOST_AUTO_TEST_CASE (ViewerExamplesLoadOptional)
 
 BOOST_AUTO_TEST_CASE (ExternalCorpusLoadOptional)
 
 BOOST_AUTO_TEST_CASE (ViewerExamplesDchXmlParityOptional)
 
 BOOST_AUTO_TEST_CASE (ViewerExamplesPinCountsOptional)
 
 BOOST_AUTO_TEST_CASE (ViewerExamplesFootprintFieldOptional)
 
 BOOST_AUTO_TEST_CASE (ImportedNetConnectivityIsConsistent)
 Items electrically joined in DipTrace (by a shared net label or a direct wire) must land on the same KiCad net after import.
 
 BOOST_AUTO_TEST_CASE (AllSymbolsWithinPageBounds)
 The corrected coordinate scaling must place every imported symbol within a sane area around the origin.
 
 BOOST_AUTO_TEST_CASE (SymbolGraphicWidthMatchesPinWidth)
 A symbol's graphic line width must read at the same scale as its pins so the body and pins look like one drawing.
 
 BOOST_AUTO_TEST_CASE (ShapeKindDiscriminatorProducesRectanglesAndLines)
 The shape type comes from the stored kind pair in each shape record, not from geometry.
 
 BOOST_AUTO_TEST_CASE (PinsCarryNonDefaultOrientations)
 Pins must carry the orientation recovered from their geometry rather than all defaulting to one side.
 
 BOOST_AUTO_TEST_CASE (PageSizeIsAppliedWhenStored)
 A DipTrace file that stores its page geometry must drive the KiCad page size.
 
 BOOST_AUTO_TEST_CASE (MultiLineValueComponentIsNotSkipped)
 re-arm_pub.dch (the Panucatt Re-ARM board, CERN OHL v1.2) contains component U3 whose value field is the multi-line text "\nIRLML2244TRPb".
 

Detailed Description

Test suite for import of DipTrace schematic (.dch) files.

Definition in file test_diptrace_sch_import.cpp.

Function Documentation

◆ BOOST_AUTO_TEST_CASE() [1/33]

BOOST_AUTO_TEST_CASE ( AllSymbolsWithinPageBounds )

The corrected coordinate scaling must place every imported symbol within a sane area around the origin.

DipTrace .dch files store no explicit page size, so the KiCad default sheet size is used as the reference. The previous 100x-too-large scaling pushed symbols far past these bounds, so this test fails on the scaling regression and passes once positions divide by 3.

Definition at line 947 of file test_diptrace_sch_import.cpp.

References std::abs(), BOOST_CHECK_MESSAGE(), BOOST_REQUIRE(), BOX2< Vec >::GetBottom(), SCH_SYMBOL::GetBoundingBox(), BOX2< Vec >::GetLeft(), BOX2< Vec >::GetRight(), BOX2< Vec >::GetTop(), SCH_SCREEN::Items(), EE_RTREE::OfType(), path, and SCH_SYMBOL_T.

◆ BOOST_AUTO_TEST_CASE() [2/33]

BOOST_AUTO_TEST_CASE ( CanReadLegacyHeaderOptional )

Definition at line 612 of file test_diptrace_sch_import.cpp.

References BOOST_TEST_MESSAGE().

◆ BOOST_AUTO_TEST_CASE() [3/33]

BOOST_AUTO_TEST_CASE ( CanReadSchematic )

Test that CanReadSchematicFile correctly identifies DipTrace .dch files by their magic header bytes.

Definition at line 35 of file test_diptrace_sch_import.cpp.

References BOOST_AUTO_TEST_CASE().

◆ BOOST_AUTO_TEST_CASE() [4/33]

BOOST_AUTO_TEST_CASE ( ComponentCountMismatchFailsDeterministically )

Definition at line 261 of file test_diptrace_sch_import.cpp.

References BOOST_REQUIRE().

◆ BOOST_AUTO_TEST_CASE() [5/33]

◆ BOOST_AUTO_TEST_CASE() [6/33]

BOOST_AUTO_TEST_CASE ( ExternalCorpusLoadOptional )

◆ BOOST_AUTO_TEST_CASE() [7/33]

BOOST_AUTO_TEST_CASE ( ImportChainIsClean )

Importing a well-formed DipTrace schematic must run the full import chain without emitting any warnings or errors.

Component records are split by their header signature and parsed within fixed bounds, so a recognised file should never fall back, mis-parse a record, or fail to save its generated library. This guards against regressions in the component boundary detector.

z80_board.dch (v38) and power_supply.dch (v37) exercise the schematic UTF-16 string path; pppp.dch (v31) exercises the legacy ASCII string path.

Definition at line 589 of file test_diptrace_sch_import.cpp.

References BOOST_CHECK_MESSAGE(), BOOST_REQUIRE(), path, RPT_SEVERITY_ERROR, and RPT_SEVERITY_WARNING.

◆ BOOST_AUTO_TEST_CASE() [8/33]

BOOST_AUTO_TEST_CASE ( ImportedNetConnectivityIsConsistent )

Items electrically joined in DipTrace (by a shared net label or a direct wire) must land on the same KiCad net after import.

Recalculate the connection graph headlessly and assert that every subgraph is internally consistent and that at least one net actually ties two or more symbol pins together, proving the importer rebuilt real connectivity rather than isolated pins.

Definition at line 896 of file test_diptrace_sch_import.cpp.

References BOOST_CHECK_EQUAL(), BOOST_CHECK_MESSAGE(), BOOST_REQUIRE(), SCH_CONNECTION::NetCode(), path, pin, and SCH_PIN_T.

◆ BOOST_AUTO_TEST_CASE() [9/33]

BOOST_AUTO_TEST_CASE ( ImportedRootIsTheSchematicTopLevelSheet )

The imported content root must become the schematic's real top-level sheet.

A nil-UUID root is treated as the virtual root and dropped by SetTopLevelSheets(), orphaning the import so the schematic editor shows nothing even though parsing succeeded.

Definition at line 182 of file test_diptrace_sch_import.cpp.

References BOOST_CHECK_EQUAL(), BOOST_REQUIRE(), SCH_SHEET::GetScreen(), EDA_ITEM::m_Uuid, niluuid, and path.

◆ BOOST_AUTO_TEST_CASE() [10/33]

BOOST_AUTO_TEST_CASE ( InvalidBusEntryTerminatorFailsDeterministically )

Definition at line 447 of file test_diptrace_sch_import.cpp.

References BOOST_REQUIRE().

◆ BOOST_AUTO_TEST_CASE() [11/33]

BOOST_AUTO_TEST_CASE ( InvalidBusSectionCountFailsDeterministically )

Definition at line 474 of file test_diptrace_sch_import.cpp.

References BOOST_REQUIRE().

◆ BOOST_AUTO_TEST_CASE() [12/33]

BOOST_AUTO_TEST_CASE ( InvalidComponentCountFailsDeterministically )

Definition at line 62 of file test_diptrace_sch_import.cpp.

References BOOST_REQUIRE().

◆ BOOST_AUTO_TEST_CASE() [13/33]

BOOST_AUTO_TEST_CASE ( InvalidComponentExtraTailLengthFailsDeterministically )

Definition at line 313 of file test_diptrace_sch_import.cpp.

References BOOST_REQUIRE().

◆ BOOST_AUTO_TEST_CASE() [14/33]

BOOST_AUTO_TEST_CASE ( InvalidComponentPinCountFailsDeterministically )

Definition at line 287 of file test_diptrace_sch_import.cpp.

References BOOST_REQUIRE().

◆ BOOST_AUTO_TEST_CASE() [15/33]

BOOST_AUTO_TEST_CASE ( InvalidComponentPinRecordFailsDeterministically )

Definition at line 340 of file test_diptrace_sch_import.cpp.

References BOOST_REQUIRE().

◆ BOOST_AUTO_TEST_CASE() [16/33]

BOOST_AUTO_TEST_CASE ( InvalidComponentShapePointCountFailsDeterministically )

Definition at line 394 of file test_diptrace_sch_import.cpp.

References BOOST_REQUIRE().

◆ BOOST_AUTO_TEST_CASE() [17/33]

BOOST_AUTO_TEST_CASE ( InvalidLaterComponentPinRecordFailsDeterministically )

Definition at line 367 of file test_diptrace_sch_import.cpp.

References BOOST_REQUIRE().

◆ BOOST_AUTO_TEST_CASE() [18/33]

BOOST_AUTO_TEST_CASE ( InvalidWireNetNameLengthFailsDeterministically )

Definition at line 526 of file test_diptrace_sch_import.cpp.

References BOOST_REQUIRE().

◆ BOOST_AUTO_TEST_CASE() [19/33]

BOOST_AUTO_TEST_CASE ( InvalidWireNetPinCountFailsDeterministically )

Definition at line 500 of file test_diptrace_sch_import.cpp.

References BOOST_REQUIRE().

◆ BOOST_AUTO_TEST_CASE() [20/33]

BOOST_AUTO_TEST_CASE ( InvalidWirePointCountFailsDeterministically )

Definition at line 553 of file test_diptrace_sch_import.cpp.

References BOOST_REQUIRE().

◆ BOOST_AUTO_TEST_CASE() [21/33]

BOOST_AUTO_TEST_CASE ( MultiLineValueComponentIsNotSkipped )

re-arm_pub.dch (the Panucatt Re-ARM board, CERN OHL v1.2) contains component U3 whose value field is the multi-line text "\nIRLML2244TRPb".

The component-header detector rejected any header string carrying a control byte, so U3's leading newline made the structural scan miss its record. The count-guided check then aborted the whole import with "found 145 components, but the file header declares 146". Multi-line text values are legal, so every component (including U3) must be found and the schematic must load with its full symbol set.

Definition at line 1199 of file test_diptrace_sch_import.cpp.

References BOOST_CHECK_EQUAL(), BOOST_REQUIRE(), path, RPT_SEVERITY_ERROR, and SCH_SYMBOL_T.

◆ BOOST_AUTO_TEST_CASE() [22/33]

BOOST_AUTO_TEST_CASE ( NoSymbolLibraryFileIsGenerated )

The importer must rely solely on the symbol definitions embedded in the schematic.

It must not write a standalone .kicad_sym library beside the imported file.

Definition at line 117 of file test_diptrace_sch_import.cpp.

References BOOST_CHECK_MESSAGE(), BOOST_REQUIRE(), SCH_SHEET::GetScreen(), SCH_SCREEN::Items(), path, SCH_SHEET_T, and SCH_SYMBOL_T.

◆ BOOST_AUTO_TEST_CASE() [23/33]

BOOST_AUTO_TEST_CASE ( PageSizeIsAppliedWhenStored )

A DipTrace file that stores its page geometry must drive the KiCad page size.

power_supply.dch carries an A4 (297 x 210 mm) page record, so the imported root screen must read back that size rather than the default. Files without a page record keep the KiCad default, which is covered by the other import tests that load z80_board.dch unchanged.

Definition at line 1173 of file test_diptrace_sch_import.cpp.

References BOOST_REQUIRE(), PAGE_INFO::GetHeightMM(), SCH_SCREEN::GetPageSettings(), SCH_SHEET::GetScreen(), PAGE_INFO::GetWidthMM(), and path.

◆ BOOST_AUTO_TEST_CASE() [24/33]

BOOST_AUTO_TEST_CASE ( PinsCarryNonDefaultOrientations )

Pins must carry the orientation recovered from their geometry rather than all defaulting to one side.

A symbol whose pins ring its body has pins facing several directions, so the imported pin set must use more than a single orientation.

Definition at line 1123 of file test_diptrace_sch_import.cpp.

References BOOST_CHECK_MESSAGE(), BOOST_REQUIRE(), SCH_SYMBOL::GetLibSymbolRef(), SCH_SCREEN::Items(), EE_RTREE::OfType(), path, SCH_PIN_T, and SCH_SYMBOL_T.

◆ BOOST_AUTO_TEST_CASE() [25/33]

BOOST_AUTO_TEST_CASE ( ShapeKindDiscriminatorProducesRectanglesAndLines )

The shape type comes from the stored kind pair in each shape record, not from geometry.

A shape tagged (700, 6) is a rectangle whose two points are opposite corners; everything else stays a polyline, so a two point diagonal line keeps its true line type. Both kinds occur in z80_board, which exercises the discriminator.

Definition at line 1058 of file test_diptrace_sch_import.cpp.

References BOOST_REQUIRE(), BOOST_TEST_MESSAGE(), SHAPE_LINE_CHAIN::CPoints(), SCH_SYMBOL::GetLibSymbolRef(), EDA_SHAPE::GetPolyShape(), EDA_SHAPE::GetShape(), SCH_SCREEN::Items(), EE_RTREE::OfType(), SHAPE_POLY_SET::Outline(), SHAPE_POLY_SET::OutlineCount(), path, POLY, RECTANGLE, SCH_SHAPE_T, and SCH_SYMBOL_T.

◆ BOOST_AUTO_TEST_CASE() [26/33]

BOOST_AUTO_TEST_CASE ( SymbolGraphicWidthMatchesPinWidth )

A symbol's graphic line width must read at the same scale as its pins so the body and pins look like one drawing.

KiCad renders a pin (and a shape with stored width 0) at the default symbol line width, and DipTrace stores real per-shape widths that can be a few times thicker. The previous 100x scaling instead produced page-scale strokes two orders of magnitude past the pins; this test rejects that while still accepting genuine heavy DipTrace strokes.

Definition at line 1001 of file test_diptrace_sch_import.cpp.

References BOOST_CHECK_MESSAGE(), BOOST_REQUIRE(), DEFAULT_LINE_WIDTH_MILS, SCH_SYMBOL::GetLibSymbolRef(), EDA_SHAPE::GetWidth(), SCH_SCREEN::Items(), EE_RTREE::OfType(), path, SCH_SHAPE_T, SCH_SYMBOL_T, and schIUScale.

◆ BOOST_AUTO_TEST_CASE() [27/33]

BOOST_AUTO_TEST_CASE ( V37Utf16SchematicLoadsWithContent )

power_supply.dch is a v37 schematic that stores UTF-16-BE strings, which the legacy version threshold would mis-read as ASCII.

The encoding auto-detection must let it load with real content rather than throwing "Unreasonable v37 string length" at the header.

Definition at line 48 of file test_diptrace_sch_import.cpp.

References BOOST_REQUIRE(), path, SCH_LINE_T, and SCH_SYMBOL_T.

◆ BOOST_AUTO_TEST_CASE() [28/33]

◆ BOOST_AUTO_TEST_CASE() [29/33]

BOOST_AUTO_TEST_CASE ( ViewerExamplesDchXmlParityOptional )

◆ BOOST_AUTO_TEST_CASE() [30/33]

BOOST_AUTO_TEST_CASE ( ViewerExamplesFootprintFieldOptional )

◆ BOOST_AUTO_TEST_CASE() [31/33]

BOOST_AUTO_TEST_CASE ( ViewerExamplesLoadOptional )

◆ BOOST_AUTO_TEST_CASE() [32/33]

BOOST_AUTO_TEST_CASE ( ViewerExamplesPinCountsOptional )

◆ BOOST_AUTO_TEST_CASE() [33/33]

BOOST_AUTO_TEST_CASE ( ZeroComponentShapePointCountFailsDeterministically )

Definition at line 421 of file test_diptrace_sch_import.cpp.

References BOOST_REQUIRE().