47 const wxString& aDescr )
57 void SetType(
const wxString& aType )
override
93 void Parse( LIB_TABLE_LEXER* aLexer )
override
132 "The second library",
147 "The first fallback library",
153 "The second fallback library",
184 auto row = std::make_unique<TEST_LIB_TABLE_ROW>(
215 BOOST_CHECK_EQUAL( table.
GetCount(), 0 );
216 BOOST_CHECK_EQUAL(
true, table.
IsEmpty() );
230 BOOST_CHECK_EQUAL( table.
GetCount(), 0 );
233 BOOST_CHECK_EQUAL(
false, table.
IsEmpty(
true ) );
242 m_mainTableNoFb.Clear();
245 BOOST_CHECK_EQUAL( m_mainTableNoFb.GetCount(), 0 );
246 BOOST_CHECK_EQUAL(
true, m_mainTableNoFb.IsEmpty() );
258 BOOST_CHECK_EQUAL(
true, m_mainTableNoFb == m_mainTableWithFb );
259 BOOST_CHECK_EQUAL(
false, m_mainTableNoFb != m_mainTableWithFb );
262 m_mainTableWithFb.At( 1 ).SetNickName(
"NewNickname" );
263 BOOST_CHECK_EQUAL(
false, m_mainTableNoFb == m_mainTableWithFb );
264 BOOST_CHECK_EQUAL(
true, m_mainTableNoFb != m_mainTableWithFb );
268 BOOST_CHECK_EQUAL(
false, m_mainTableNoFb == empty_table );
269 BOOST_CHECK_EQUAL(
true, m_mainTableNoFb != empty_table );
279 BOOST_CHECK_EQUAL( m_mainTableNoFb.GetCount(), 3 );
281 const auto& row0 = m_mainTableNoFb.At( 0 );
282 BOOST_CHECK_EQUAL( row0.GetNickName(),
"Lib1" );
284 const auto& row1 = m_mainTableNoFb.At( 1 );
285 BOOST_CHECK_EQUAL( row1.GetNickName(),
"Lib2" );
288 const auto& row2 = m_mainTableNoFb.At( 2 );
289 BOOST_CHECK_EQUAL( row2.GetNickName(),
"Lib3" );
302 BOOST_CHECK_EQUAL(
true, m_mainTableNoFb.HasLibrary(
"Lib1" ) );
305 BOOST_CHECK_EQUAL(
true, m_mainTableNoFb.HasLibrary(
"Lib3" ) );
306 BOOST_CHECK_EQUAL(
false, m_mainTableNoFb.HasLibrary(
"Lib3",
true ) );
308 BOOST_CHECK_EQUAL(
false, m_mainTableNoFb.HasLibrary(
"NotPresent" ) );
317 BOOST_CHECK_EQUAL(
"The first library", m_mainTableNoFb.GetDescription(
"Lib1" ) );
320 BOOST_CHECK_EQUAL(
"The third library", m_mainTableNoFb.GetDescription(
"Lib3" ) );
329 BOOST_CHECK_EQUAL(
"://lib/1", m_mainTableNoFb.GetFullURI(
"Lib1" ) );
331 const LIB_TABLE_ROW* row = m_mainTableNoFb.FindRowByURI(
"://lib/1" );
334 BOOST_CHECK_NE(
nullptr, row );
341 row = m_mainTableNoFb.FindRowByURI(
"this_uri_is_not_found" );
343 BOOST_CHECK_EQUAL(
nullptr, row );
352 auto logical_libs = m_mainTableNoFb.GetLogicalLibs();
355 const std::vector<wxString> exp_libs = {
360 BOOST_CHECK_EQUAL_COLLECTIONS(
361 logical_libs.begin(), logical_libs.end(), exp_libs.begin(), exp_libs.end() );
364BOOST_AUTO_TEST_SUITE_END()
Hold a record identifying a library accessed by the appropriate plug in object in the LIB_TABLE.
const wxString & GetNickName() const
Manage LIB_TABLE_ROW records (rows), and can be searched based on library nickname.
bool InsertRow(LIB_TABLE_ROW *aRow, bool doReplace=false)
Adds aRow if it does not already exist or if doReplace is true.
bool IsEmpty(bool aIncludeFallback=true)
Return true if the table is empty.
unsigned GetCount() const
Get the number of rows contained in the table.
A concrete implementation of LIB_TABLE_ROW that implements the minimum interface.
TEST_LIB_TABLE_ROW(const wxString &aNick, const wxString &aURI, const wxString &aOptions, const wxString &aDescr)
LIB_TABLE_ROW * do_clone() const override
void SetType(const wxString &aType) override
Change the type of library represented by this row that must be implemented in the derived object to ...
const wxString GetType() const override
Return the type of library represented by this row.
A concrete implementation of LIB_TABLE that implements the minimum interface for testing.
void Parse(LIB_TABLE_LEXER *aLexer) override
Parse the #LIB_TABLE_LEXER s-expression library table format into the appropriate LIB_TABLE_ROW objec...
void Format(OUTPUTFORMATTER *aOutput, int aIndentLevel) const override
Generate the table in s-expression format to aOutput with an indentation level of aIndentLevel.
TEST_LIB_TABLE(LIB_TABLE *aFallback=nullptr)
Simple structure to contain data to set up a single TEST_LIB_TABLE_ROW.
std::string m_description
Reusable test fixture with some basic pre-filled tables.
std::unique_ptr< TEST_LIB_TABLE_ROW > makeRowFromDef(const LIB_ROW_DEFINITION &aDef)
Helper to construct a new TEST_LIB_TABLE_ROW from a definition struct.
TEST_LIB_TABLE m_fallbackTable
The table that m_mainTableWithFb falls back to.
TEST_LIB_TABLE m_mainTableWithFb
Identical to m_mainTableNoFb, but with a fallback.
TEST_LIB_TABLE m_mainTableNoFb
Table with some enabled and disabled libs, no fallback provided.
static const std::vector< LIB_ROW_DEFINITION > fallback_lib_defs
BOOST_AUTO_TEST_CASE(Empty)
Declare the test suite.
static const std::vector< LIB_ROW_DEFINITION > main_lib_defs
Set-up data for the re-used library row definitions.
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.