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

Unit tests for the PCB variant system including FOOTPRINT_VARIANT, BOARD variant registry, and variant-aware filtering. More...

Go to the source code of this file.

Functions

 BOOST_AUTO_TEST_CASE (FootprintVariantBasics)
 Test FOOTPRINT_VARIANT class basic operations.
 
 BOOST_AUTO_TEST_CASE (BoardVariantRegistry)
 Test BOARD variant registry operations.
 
 BOOST_AUTO_TEST_CASE (FootprintDNPForVariant)
 Test footprint DNP for variant.
 
 BOOST_AUTO_TEST_CASE (FootprintBOMExclusionForVariant)
 Test footprint BOM exclusion for variant.
 
 BOOST_AUTO_TEST_CASE (FootprintPosFileExclusionForVariant)
 Test footprint position file exclusion for variant.
 
 BOOST_AUTO_TEST_CASE (VariantCaseInsensitivity)
 Test variant case insensitivity for all operations.
 
 BOOST_AUTO_TEST_CASE (EmptyVariantReturnsBase)
 Test that empty variant name returns base attributes.
 
 BOOST_AUTO_TEST_CASE (UnknownVariantReturnsBase)
 Test that unknown variant name returns base attributes.
 
 BOOST_AUTO_TEST_CASE (FootprintVariantCopyAssignment)
 
 BOOST_AUTO_TEST_CASE (FootprintFieldShownTextForVariant)
 
 BOOST_AUTO_TEST_CASE (BoardVariantTextVars)
 
 BOOST_AUTO_TEST_CASE (NetlistComponentVariantsParsing)
 
 BOOST_AUTO_TEST_CASE (MultipleVariantsIndependent)
 Test adding multiple variants and verifying they're independent.
 
 BOOST_AUTO_TEST_CASE (VariantFieldUnicodeAndSpecialChars)
 Test variant field values with unicode and special characters.
 
 BOOST_AUTO_TEST_CASE (VariantDeletionClearsRegistry)
 Test variant deletion clears board variant registry.
 
 BOOST_AUTO_TEST_CASE (RenameVariantPreservesData)
 Test renaming variant to existing name fails or merges appropriately.
 
 BOOST_AUTO_TEST_CASE (GetVariantNamesForUIFormat)
 Test GetVariantNamesForUI returns sorted list with default first.
 
 BOOST_AUTO_TEST_CASE (VariantMultipleFlagsCombinations)
 Test multiple flags can be set independently for each variant.
 
 BOOST_AUTO_TEST_CASE (ComponentVariantToFootprintTransfer)
 Test that COMPONENT_VARIANT data from netlist transfers correctly to FOOTPRINT_VARIANT.
 
 BOOST_AUTO_TEST_CASE (ComponentVariantPartialOverride)
 Test that variant m_has* flags are properly respected during transfer.
 
 BOOST_AUTO_TEST_CASE (NetlistVariantAttributeParsing)
 Test that all variant attributes are properly parsed from netlist including exclude_from_pos_files.
 
 BOOST_AUTO_TEST_CASE (VariantAttributeTransferWithReset)
 Test the complete variant attribute transfer flow simulating board_netlist_updater behavior.
 
 BOOST_AUTO_TEST_CASE (VariantTestR2FootprintAttributeVerification)
 Test that recreates the user's observed bug:
 
 BOOST_AUTO_TEST_CASE (VariantTestProjectLoad)
 Test loading and verifying variant data from the variant_test project files.
 

Detailed Description

Unit tests for the PCB variant system including FOOTPRINT_VARIANT, BOARD variant registry, and variant-aware filtering.

Definition in file test_variant.cpp.

Function Documentation

◆ BOOST_AUTO_TEST_CASE() [1/24]

◆ BOOST_AUTO_TEST_CASE() [2/24]

BOOST_AUTO_TEST_CASE ( BoardVariantTextVars )

◆ BOOST_AUTO_TEST_CASE() [3/24]

◆ BOOST_AUTO_TEST_CASE() [4/24]

◆ BOOST_AUTO_TEST_CASE() [5/24]

BOOST_AUTO_TEST_CASE ( EmptyVariantReturnsBase )

Test that empty variant name returns base attributes.

Definition at line 246 of file test_variant.cpp.

References BOARD::AddVariant(), FP_DNP, FOOTPRINT::GetDNPForVariant(), FOOTPRINT::SetAttributes(), FOOTPRINT_VARIANT::SetDNP(), and FOOTPRINT::SetVariant().

◆ BOOST_AUTO_TEST_CASE() [6/24]

BOOST_AUTO_TEST_CASE ( FootprintBOMExclusionForVariant )

◆ BOOST_AUTO_TEST_CASE() [7/24]

BOOST_AUTO_TEST_CASE ( FootprintDNPForVariant )

◆ BOOST_AUTO_TEST_CASE() [8/24]

◆ BOOST_AUTO_TEST_CASE() [9/24]

BOOST_AUTO_TEST_CASE ( FootprintPosFileExclusionForVariant )

◆ BOOST_AUTO_TEST_CASE() [10/24]

◆ BOOST_AUTO_TEST_CASE() [11/24]

◆ BOOST_AUTO_TEST_CASE() [12/24]

BOOST_AUTO_TEST_CASE ( GetVariantNamesForUIFormat )

Test GetVariantNamesForUI returns sorted list with default first.

Definition at line 562 of file test_variant.cpp.

References BOARD::AddVariant(), and BOARD::GetVariantNamesForUI().

◆ BOOST_AUTO_TEST_CASE() [13/24]

◆ BOOST_AUTO_TEST_CASE() [14/24]

◆ BOOST_AUTO_TEST_CASE() [15/24]

BOOST_AUTO_TEST_CASE ( NetlistVariantAttributeParsing )

Test that all variant attributes are properly parsed from netlist including exclude_from_pos_files.

This verifies that the netlist parser correctly sets the m_has* flags for all attribute types.

Definition at line 825 of file test_variant.cpp.

References COMPONENT_VARIANT::m_dnp, COMPONENT_VARIANT::m_excludedFromBOM, COMPONENT_VARIANT::m_excludedFromPosFiles, COMPONENT_VARIANT::m_hasDnp, COMPONENT_VARIANT::m_hasExcludedFromBOM, and COMPONENT_VARIANT::m_hasExcludedFromPosFiles.

◆ BOOST_AUTO_TEST_CASE() [16/24]

BOOST_AUTO_TEST_CASE ( RenameVariantPreservesData )

◆ BOOST_AUTO_TEST_CASE() [17/24]

BOOST_AUTO_TEST_CASE ( UnknownVariantReturnsBase )

Test that unknown variant name returns base attributes.

Definition at line 273 of file test_variant.cpp.

References BOARD::AddVariant(), FP_DNP, FOOTPRINT::GetDNPForVariant(), FOOTPRINT::SetAttributes(), FOOTPRINT_VARIANT::SetDNP(), and FOOTPRINT::SetVariant().

◆ BOOST_AUTO_TEST_CASE() [18/24]

◆ BOOST_AUTO_TEST_CASE() [19/24]

BOOST_AUTO_TEST_CASE ( VariantCaseInsensitivity )

Test variant case insensitivity for all operations.

Definition at line 219 of file test_variant.cpp.

References BOARD::AddVariant(), FOOTPRINT::GetDNPForVariant(), BOARD::HasVariant(), FOOTPRINT_VARIANT::SetDNP(), and FOOTPRINT::SetVariant().

◆ BOOST_AUTO_TEST_CASE() [20/24]

BOOST_AUTO_TEST_CASE ( VariantDeletionClearsRegistry )

◆ BOOST_AUTO_TEST_CASE() [21/24]

◆ BOOST_AUTO_TEST_CASE() [22/24]

◆ BOOST_AUTO_TEST_CASE() [23/24]

◆ BOOST_AUTO_TEST_CASE() [24/24]

BOOST_AUTO_TEST_CASE ( VariantTestR2FootprintAttributeVerification )

Test that recreates the user's observed bug:

  • R2 in schematic has Variant A with ONLY a Footprint field override (no attribute overrides)
  • On the board, there are TWO R2 footprints:
    1. C_1210 footprint (variant footprint) - should have NO explicit attribute overrides
    2. C_3640 footprint (base footprint) - SHOULD have DNP/ExcludedFromBOM/ExcludedFromPosFiles because this footprint is NOT used when building Variant A

The reported bug: "R2:Variant A has no attributes set in schematic but has 3 attributes on board" This test verifies which footprint has which attributes and whether that's correct behavior.

Definition at line 941 of file test_variant.cpp.

References BOOST_REQUIRE(), BOOST_TEST_MESSAGE(), FOOTPRINT_VARIANT::GetDNP(), FOOTPRINT_VARIANT::GetExcludedFromBOM(), FOOTPRINT_VARIANT::GetExcludedFromPosFiles(), KI_TEST::GetPcbnewTestDataDir(), FOOTPRINT::GetVariant(), FOOTPRINT::IsDNP(), FOOTPRINT::IsExcludedFromBOM(), FOOTPRINT::IsExcludedFromPosFiles(), and PCB_IO_KICAD_SEXPR::LoadBoard().