21#include <boost/test/unit_test.hpp>
33 BOOST_CHECK(
id.Parse(
"Package_SO:DGG56" ) == -1 );
36 BOOST_CHECK(
id.IsValid() );
37 BOOST_CHECK( !
id.IsLegacy() );
38 BOOST_CHECK( !
id.
empty() );
45 BOOST_CHECK(
id.Parse(
"DGG56" ) == -1 );
46 BOOST_CHECK(
id.GetLibNickname().
empty() );
48 BOOST_CHECK( !
id.IsValid() );
49 BOOST_CHECK(
id.IsLegacy() );
50 BOOST_CHECK( !
id.
empty() );
56 LIB_ID a( wxT(
"Package_SO" ), wxT(
"DGG56" ) );
57 LIB_ID b( wxT(
"Package_SO" ), wxT(
"DGG56" ) );
58 LIB_ID c( wxT(
"OtherLib" ), wxT(
"DGG56" ) );
60 BOOST_CHECK( a == b );
61 BOOST_CHECK( a != c );
68 legacy.
Parse(
"DGG56" );
70 LIB_ID qualified( wxT(
"Package_SO" ), wxT(
"DGG56" ) );
73 BOOST_CHECK( legacy != qualified );
83 LIB_ID qualified( wxT(
"Package_SO" ), wxT(
"DGG56" ) );
87 legacy.
Parse(
"DGG56" );
93 BOOST_CHECK( reparsed == qualified );
97 BOOST_CHECK( reparsedLegacy.
IsLegacy() );
105 BOOST_CHECK(
empty.empty() );
106 BOOST_CHECK( !
empty.IsValid() );
107 BOOST_CHECK( !
empty.IsLegacy() );
123 BOOST_CHECK( libIdBad == wxS(
"<>\"\\:\t\n\r" ) );
127 BOOST_CHECK( libIdBad.Find( wxUniChar(
':' ) ) != wxNOT_FOUND );
128 BOOST_CHECK( libIdBad.Find( wxUniChar(
'"' ) ) != wxNOT_FOUND );
130 for( wxUniChar ch : libIdBad )
132 std::string
name =
"abc";
133 name +=
static_cast<char>( ch.GetValue() );
136 "LIB_ID accepted a shared-forbidden char 0x"
137 << std::hex << ch.GetValue() );
152 for( wxUniChar ch : libId )
153 BOOST_CHECK( fname.Find( ch ) != wxNOT_FOUND );
155 for( wxUniChar ch : { wxUniChar(
'%' ), wxUniChar(
'$' ), wxUniChar(
'/' ) } )
157 BOOST_CHECK( libId.Find( ch ) == wxNOT_FOUND );
158 BOOST_CHECK( fname.Find( ch ) != wxNOT_FOUND );
160 std::string
name =
"abc";
161 name +=
static_cast<char>( ch.GetValue() );
A logical library item identifier and consists of various portions much like a URI.
int Parse(const UTF8 &aId, bool aFix=false)
Parse LIB_ID with the information from aId.
static int HasIllegalChars(const UTF8 &aLibItemName)
Examine aLibItemName for invalid LIB_ID item name characters.
const UTF8 & GetLibItemName() const
An 8 bit string that is assuredly encoded in UTF8, and supplies special conversion support to and fro...
static bool empty(const wxTextEntryBase *aCtrl)
const wxString & GetLibFilenameForbiddenChars()
Characters illegal in a footprint library filename.
const wxString & GetLibIdForbiddenChars()
Characters illegal in a LIB_ID item name.
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_CASE(ParseFullyQualified)
BOOST_CHECK_MESSAGE(totalMismatches==0, std::to_string(totalMismatches)+" board(s) with strategy disagreements")
BOOST_CHECK_EQUAL(result, "25.4")