|
KiCad PCB EDA Suite
|
Unit tests for the PCB variant system including FOOTPRINT_VARIANT, BOARD variant registry, and variant-aware filtering. More...
#include <qa_utils/wx_utils/unit_test_utils.h>#include <boost/test/unit_test.hpp>#include <board.h>#include <footprint.h>#include <pcbnew/netlist_reader/kicad_netlist_parser.h>#include <pcbnew/netlist_reader/pcb_netlist.h>#include <pcb_io/kicad_sexpr/pcb_io_kicad_sexpr.h>#include <pcbnew_utils/board_file_utils.h>#include <richio.h>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. | |
Unit tests for the PCB variant system including FOOTPRINT_VARIANT, BOARD variant registry, and variant-aware filtering.
Definition in file test_variant.cpp.
| BOOST_AUTO_TEST_CASE | ( | BoardVariantRegistry | ) |
Test BOARD variant registry operations.
Definition at line 76 of file test_variant.cpp.
References BOARD::AddVariant(), BOOST_CHECK_EQUAL(), BOARD::DeleteVariant(), BOARD::GetCurrentVariant(), BOARD::GetVariantDescription(), BOARD::GetVariantNames(), BOARD::HasVariant(), BOARD::SetCurrentVariant(), and BOARD::SetVariantDescription().
| BOOST_AUTO_TEST_CASE | ( | BoardVariantTextVars | ) |
Definition at line 346 of file test_variant.cpp.
References BOARD::AddVariant(), BOOST_CHECK_EQUAL(), BOARD::ResolveTextVar(), BOARD::SetCurrentVariant(), and BOARD::SetVariantDescription().
| BOOST_AUTO_TEST_CASE | ( | ComponentVariantPartialOverride | ) |
Test that variant m_has* flags are properly respected during transfer.
When a flag is not set (m_hasDnp = false), the footprint variant value should be reset to the base footprint's value, not retained.
Definition at line 756 of file test_variant.cpp.
References BOARD::AddVariant(), COMPONENT::AddVariant(), BOOST_REQUIRE(), FOOTPRINT::GetDNPForVariant(), FOOTPRINT::GetExcludedFromBOMForVariant(), FOOTPRINT::GetExcludedFromPosFilesForVariant(), FOOTPRINT::GetVariant(), COMPONENT::GetVariants(), FOOTPRINT::IsDNP(), FOOTPRINT::IsExcludedFromBOM(), FOOTPRINT::IsExcludedFromPosFiles(), COMPONENT_VARIANT::m_dnp, COMPONENT_VARIANT::m_hasDnp, path, FOOTPRINT::SetDNP(), FOOTPRINT_VARIANT::SetDNP(), FOOTPRINT::SetExcludedFromBOM(), FOOTPRINT_VARIANT::SetExcludedFromBOM(), FOOTPRINT::SetExcludedFromPosFiles(), FOOTPRINT_VARIANT::SetExcludedFromPosFiles(), FOOTPRINT::SetReference(), and FOOTPRINT::SetVariant().
| BOOST_AUTO_TEST_CASE | ( | ComponentVariantToFootprintTransfer | ) |
Test that COMPONENT_VARIANT data from netlist transfers correctly to FOOTPRINT_VARIANT.
This simulates the variant property transfer that occurs during "Update PCB from Schematic".
Definition at line 660 of file test_variant.cpp.
References BOARD::AddVariant(), COMPONENT::AddVariant(), FOOTPRINT::AddVariant(), BOOST_CHECK_EQUAL(), BOOST_REQUIRE(), FOOTPRINT_VARIANT::GetDNP(), FOOTPRINT::GetDNPForVariant(), FOOTPRINT_VARIANT::GetExcludedFromBOM(), FOOTPRINT::GetExcludedFromBOMForVariant(), FOOTPRINT_VARIANT::GetExcludedFromPosFiles(), FOOTPRINT::GetExcludedFromPosFilesForVariant(), FOOTPRINT_VARIANT::GetFieldValue(), FOOTPRINT::GetVariant(), COMPONENT::GetVariants(), FOOTPRINT_VARIANT::HasFieldValue(), COMPONENT_VARIANT::m_dnp, COMPONENT_VARIANT::m_excludedFromBOM, COMPONENT_VARIANT::m_excludedFromPosFiles, COMPONENT_VARIANT::m_fields, COMPONENT_VARIANT::m_hasDnp, COMPONENT_VARIANT::m_hasExcludedFromBOM, COMPONENT_VARIANT::m_hasExcludedFromPosFiles, path, FOOTPRINT_VARIANT::SetDNP(), FOOTPRINT_VARIANT::SetExcludedFromBOM(), FOOTPRINT_VARIANT::SetExcludedFromPosFiles(), FOOTPRINT_VARIANT::SetFieldValue(), FOOTPRINT::SetReference(), and FOOTPRINT::SetValue().
| 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 | ( | FootprintBOMExclusionForVariant | ) |
Test footprint BOM exclusion for variant.
Definition at line 159 of file test_variant.cpp.
References BOARD::AddVariant(), FP_EXCLUDE_FROM_BOM, FOOTPRINT::GetExcludedFromBOMForVariant(), FOOTPRINT::SetAttributes(), FOOTPRINT_VARIANT::SetExcludedFromBOM(), and FOOTPRINT::SetVariant().
| BOOST_AUTO_TEST_CASE | ( | FootprintDNPForVariant | ) |
Test footprint DNP for variant.
Definition at line 117 of file test_variant.cpp.
References BOARD::AddVariant(), FP_DNP, FOOTPRINT::GetDNPForVariant(), FOOTPRINT::SetAttributes(), FOOTPRINT_VARIANT::SetDNP(), and FOOTPRINT::SetVariant().
| BOOST_AUTO_TEST_CASE | ( | FootprintFieldShownTextForVariant | ) |
Definition at line 325 of file test_variant.cpp.
References BOARD::AddVariant(), BOOST_CHECK_EQUAL(), PCB_FIELD::GetName(), PCB_FIELD::GetShownText(), BOARD::SetCurrentVariant(), FOOTPRINT_VARIANT::SetFieldValue(), FOOTPRINT::SetValue(), FOOTPRINT::SetVariant(), and FOOTPRINT::Value().
| BOOST_AUTO_TEST_CASE | ( | FootprintPosFileExclusionForVariant | ) |
Test footprint position file exclusion for variant.
Definition at line 189 of file test_variant.cpp.
References BOARD::AddVariant(), FP_EXCLUDE_FROM_POS_FILES, FOOTPRINT::GetExcludedFromPosFilesForVariant(), FOOTPRINT::SetAttributes(), FOOTPRINT_VARIANT::SetExcludedFromPosFiles(), and FOOTPRINT::SetVariant().
| BOOST_AUTO_TEST_CASE | ( | FootprintVariantBasics | ) |
Test FOOTPRINT_VARIANT class basic operations.
Definition at line 48 of file test_variant.cpp.
References BOOST_AUTO_TEST_CASE(), BOOST_CHECK_EQUAL(), FOOTPRINT_VARIANT::GetDNP(), FOOTPRINT_VARIANT::GetExcludedFromBOM(), FOOTPRINT_VARIANT::GetExcludedFromPosFiles(), FOOTPRINT_VARIANT::GetFields(), FOOTPRINT_VARIANT::GetFieldValue(), FOOTPRINT_VARIANT::GetName(), FOOTPRINT_VARIANT::HasFieldValue(), FOOTPRINT_VARIANT::SetDNP(), FOOTPRINT_VARIANT::SetExcludedFromBOM(), FOOTPRINT_VARIANT::SetExcludedFromPosFiles(), and FOOTPRINT_VARIANT::SetFieldValue().
| BOOST_AUTO_TEST_CASE | ( | FootprintVariantCopyAssignment | ) |
Definition at line 293 of file test_variant.cpp.
References BOOST_CHECK_EQUAL(), BOOST_REQUIRE(), copy, FOOTPRINT_VARIANT::GetDNP(), FOOTPRINT_VARIANT::GetExcludedFromBOM(), FOOTPRINT_VARIANT::GetFieldValue(), PCB_FIELD::GetName(), FOOTPRINT::GetVariant(), FOOTPRINT_VARIANT::SetDNP(), FOOTPRINT_VARIANT::SetExcludedFromBOM(), FOOTPRINT_VARIANT::SetFieldValue(), FOOTPRINT::SetReference(), FOOTPRINT::SetValue(), FOOTPRINT::SetVariant(), and FOOTPRINT::Value().
| 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 | ( | MultipleVariantsIndependent | ) |
Test adding multiple variants and verifying they're independent.
Definition at line 422 of file test_variant.cpp.
References BOARD::AddVariant(), BOOST_CHECK_EQUAL(), BOOST_REQUIRE(), FOOTPRINT::GetDNPForVariant(), PCB_FIELD::GetName(), FOOTPRINT::GetVariant(), BOARD::GetVariantDescription(), FOOTPRINT_VARIANT::SetDNP(), FOOTPRINT_VARIANT::SetFieldValue(), FOOTPRINT::SetReference(), FOOTPRINT::SetValue(), FOOTPRINT::SetVariant(), BOARD::SetVariantDescription(), v1, v2, and FOOTPRINT::Value().
| BOOST_AUTO_TEST_CASE | ( | NetlistComponentVariantsParsing | ) |
Definition at line 369 of file test_variant.cpp.
References BOOST_CHECK_EQUAL(), BOOST_REQUIRE(), NETLIST::GetComponent(), NETLIST::GetCount(), COMPONENT::GetVariant(), COMPONENT_VARIANT::m_dnp, COMPONENT_VARIANT::m_excludedFromBOM, COMPONENT_VARIANT::m_fields, COMPONENT_VARIANT::m_hasDnp, COMPONENT_VARIANT::m_hasExcludedFromBOM, netlist, and KICAD_NETLIST_PARSER::Parse().
| 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 | ( | RenameVariantPreservesData | ) |
Test renaming variant to existing name fails or merges appropriately.
Definition at line 536 of file test_variant.cpp.
References BOARD::AddVariant(), BOOST_CHECK_EQUAL(), BOARD::GetCurrentVariant(), BOARD::GetVariantDescription(), BOARD::HasVariant(), BOARD::RenameVariant(), BOARD::SetCurrentVariant(), and BOARD::SetVariantDescription().
| 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 | ( | VariantAttributeTransferWithReset | ) |
Test the complete variant attribute transfer flow simulating board_netlist_updater behavior.
This tests the fixed logic where attributes without explicit overrides are reset to base values.
Definition at line 876 of file test_variant.cpp.
References BOARD::AddVariant(), FOOTPRINT::AddVariant(), BOOST_REQUIRE(), FOOTPRINT::GetDNPForVariant(), FOOTPRINT::GetExcludedFromBOMForVariant(), FOOTPRINT::GetExcludedFromPosFilesForVariant(), FOOTPRINT::IsDNP(), FOOTPRINT::IsExcludedFromBOM(), FOOTPRINT::IsExcludedFromPosFiles(), COMPONENT_VARIANT::m_dnp, COMPONENT_VARIANT::m_excludedFromBOM, COMPONENT_VARIANT::m_excludedFromPosFiles, COMPONENT_VARIANT::m_hasDnp, COMPONENT_VARIANT::m_hasExcludedFromBOM, COMPONENT_VARIANT::m_hasExcludedFromPosFiles, FOOTPRINT::SetDNP(), FOOTPRINT_VARIANT::SetDNP(), FOOTPRINT::SetExcludedFromBOM(), FOOTPRINT_VARIANT::SetExcludedFromBOM(), FOOTPRINT::SetExcludedFromPosFiles(), FOOTPRINT_VARIANT::SetExcludedFromPosFiles(), FOOTPRINT::SetFPID(), and FOOTPRINT::SetReference().
| 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 | ( | VariantDeletionClearsRegistry | ) |
Test variant deletion clears board variant registry.
Definition at line 508 of file test_variant.cpp.
References BOARD::AddVariant(), BOOST_CHECK_EQUAL(), BOARD::DeleteVariant(), BOARD::GetCurrentVariant(), BOARD::GetVariantNames(), BOARD::HasVariant(), BOARD::SetCurrentVariant(), and BOARD::SetVariantDescription().
| BOOST_AUTO_TEST_CASE | ( | VariantFieldUnicodeAndSpecialChars | ) |
Test variant field values with unicode and special characters.
Definition at line 469 of file test_variant.cpp.
References BOARD::AddVariant(), BOOST_CHECK_EQUAL(), BOOST_REQUIRE(), FOOTPRINT_VARIANT::GetFieldValue(), PCB_FIELD::GetName(), FOOTPRINT::GetVariant(), BOARD::GetVariantDescription(), FOOTPRINT_VARIANT::SetFieldValue(), FOOTPRINT::SetValue(), FOOTPRINT::SetVariant(), BOARD::SetVariantDescription(), and FOOTPRINT::Value().
| BOOST_AUTO_TEST_CASE | ( | VariantMultipleFlagsCombinations | ) |
Test multiple flags can be set independently for each variant.
Definition at line 602 of file test_variant.cpp.
References BOARD::AddVariant(), FOOTPRINT::GetDNPForVariant(), FOOTPRINT::GetExcludedFromBOMForVariant(), FOOTPRINT::GetExcludedFromPosFilesForVariant(), FOOTPRINT_VARIANT::SetDNP(), FOOTPRINT_VARIANT::SetExcludedFromBOM(), FOOTPRINT_VARIANT::SetExcludedFromPosFiles(), and FOOTPRINT::SetVariant().
| BOOST_AUTO_TEST_CASE | ( | VariantTestProjectLoad | ) |
Test loading and verifying variant data from the variant_test project files.
Definition at line 1039 of file test_variant.cpp.
References BOOST_CHECK_EQUAL(), BOOST_REQUIRE(), FOOTPRINT_VARIANT::GetDNP(), FOOTPRINT_VARIANT::GetExcludedFromBOM(), FOOTPRINT_VARIANT::GetExcludedFromPosFiles(), FOOTPRINT_VARIANT::GetFieldValue(), KI_TEST::GetPcbnewTestDataDir(), FOOTPRINT_VARIANT::HasFieldValue(), and PCB_IO_KICAD_SEXPR::LoadBoard().
| BOOST_AUTO_TEST_CASE | ( | VariantTestR2FootprintAttributeVerification | ) |
Test that recreates the user's observed bug:
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().