KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_library_tables.cpp File Reference
#include <filesystem>
#include <fstream>
#include <mock_pgm_base.h>
#include <richio.h>
#include <io/kicad/kicad_io_utils.h>
#include <qa_utils/wx_utils/unit_test_utils.h>
#include <settings/settings_manager.h>
#include <pegtl/contrib/analyze.hpp>
#include <libraries/library_manager.h>
#include <libraries/library_table.h>
#include <libraries/library_table_parser.h>
#include <libraries/library_table_grammar.h>

Go to the source code of this file.

Functions

 BOOST_AUTO_TEST_CASE (Grammar)
 
 BOOST_AUTO_TEST_CASE (EmptyString)
 
 BOOST_AUTO_TEST_CASE (ParseFromFile)
 
 BOOST_AUTO_TEST_CASE (ParseAndConstruct)
 
 BOOST_AUTO_TEST_CASE (Manager)
 
 BOOST_AUTO_TEST_CASE (NestedTablesDisabledHidden)
 
 BOOST_AUTO_TEST_CASE (InsertRowPreservesExistingRowPointers)
 Regression test: inserting rows into a loaded LIBRARY_TABLE must not invalidate pointers or references to previously-captured rows.
 
 BOOST_AUTO_TEST_CASE (IsPcmManagedRow_URITemplateMatching)
 Regression test for the PCM auto-remove identification predicate.
 

Function Documentation

◆ BOOST_AUTO_TEST_CASE() [1/8]

BOOST_AUTO_TEST_CASE ( EmptyString )

◆ BOOST_AUTO_TEST_CASE() [2/8]

BOOST_AUTO_TEST_CASE ( Grammar )

Definition at line 40 of file test_library_tables.cpp.

References BOOST_AUTO_TEST_CASE(), and BOOST_REQUIRE().

◆ BOOST_AUTO_TEST_CASE() [3/8]

BOOST_AUTO_TEST_CASE ( InsertRowPreservesExistingRowPointers )

Regression test: inserting rows into a loaded LIBRARY_TABLE must not invalidate pointers or references to previously-captured rows.

The remote symbol import path (EnsureRemoteLibraryEntry) calls InsertRow() at runtime while LIB_DATA instances and LIBRARY_MANAGER::m_rowCache hold raw pointers into the rows container. A std::vector-backed container would reallocate on growth and leave those pointers dangling, which produced an intermittent std::bad_alloc crash deep in KIwxExpandEnvVars when the next symbol placement tried to read the stale URI.

Definition at line 228 of file test_library_tables.cpp.

References PROJECT, LIBRARY_TABLE_ROW::SetNickname(), LIBRARY_TABLE_ROW::SetType(), LIBRARY_TABLE_ROW::SetURI(), SYMBOL, table, and LIBRARY_TABLE_ROW::URI().

◆ BOOST_AUTO_TEST_CASE() [4/8]

BOOST_AUTO_TEST_CASE ( IsPcmManagedRow_URITemplateMatching )

Regression test for the PCM auto-remove identification predicate.

Rows inserted by the PCM traverser reference ${KICADn_3RD_PARTY} directly, so matching on the URI template uniquely identifies them and avoids cleaning up user-added libraries whose expanded absolute paths happen to be descendants of the 3RD_PARTY directory via a different env var (e.g. ${KICAD_USER_LIB} pointing to ${KICAD10_3RD_PARTY}/V10).

Prior to this fix, cleanupRemovedPCMLibraries did a raw prefix check on the expanded path, mis-identifying overlapping user libraries as PCM-managed and silently deleting their rows any time the file was temporarily absent. The user-visible symptom was "Could not create the library file" when adding a new library through the symbol editor.

Definition at line 284 of file test_library_tables.cpp.

References actual, BOOST_CHECK_MESSAGE(), LIBRARY_MANAGER::IsPcmManagedRow(), and LIBRARY_TABLE_ROW::SetURI().

◆ BOOST_AUTO_TEST_CASE() [5/8]

BOOST_AUTO_TEST_CASE ( Manager )

◆ BOOST_AUTO_TEST_CASE() [6/8]

BOOST_AUTO_TEST_CASE ( NestedTablesDisabledHidden )

◆ BOOST_AUTO_TEST_CASE() [7/8]

◆ BOOST_AUTO_TEST_CASE() [8/8]

BOOST_AUTO_TEST_CASE ( ParseFromFile )