KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_lib_part.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
24
26
27// Code under test
28#include <sch_shape.h>
29#include <sch_pin.h>
30#include <lib_symbol.h>
31#include <functional>
33#include <font/font.h>
34#include <locale_io.h>
35#include <sch_file_versions.h>
36#include <sch_io/sch_io.h>
37#include <sch_io/sch_io_mgr.h>
39#include <richio.h>
40#include <locale_io.h>
41#include <units_provider.h>
42
43#include <wx/file.h>
44#include <wx/filename.h>
45
47
48extern void CheckDuplicatePins( LIB_SYMBOL* aSymbol, std::vector<wxString>& aMessages,
49 UNITS_PROVIDER* aUnitsProvider );
50
52{
53public:
55 m_part_no_data( "part_name", nullptr )
56 {
57 }
58
61};
62
63
68{
69public:
71 {
72 m_dir = wxFileName::CreateTempFileName( wxS( "kicad_lib_part_" ) );
73 wxRemoveFile( m_dir );
74 wxFileName::Mkdir( m_dir );
75
76 m_path = wxFileName( m_dir, wxS( "test_lib.kicad_sym" ) ).GetFullPath();
77 }
78
80 {
81 if( wxFileName::DirExists( m_dir ) )
82 wxFileName::Rmdir( m_dir, wxPATH_RMDIR_RECURSIVE );
83 }
84
85 const wxString& GetPath() const { return m_path; }
86
87private:
88 wxString m_dir;
89 wxString m_path;
90};
91
92
97{
98 int count = 0;
99
100 for( SCH_ITEM& item : aSymbol.GetDrawItems() )
101 {
102 if( item.GetBodyStyle() > BODY_STYLE::BASE )
103 count++;
104 }
105
106 return count;
107}
108
109
113static std::unique_ptr<LIB_SYMBOL> loadDeMorganSymbol()
114{
115 wxFileName libPath( KI_TEST::GetEeschemaTestDataDir() );
116 libPath.AppendDir( "libs" );
117 libPath.SetFullName( "4xxx.kicad_sym" );
118
119 IO_RELEASER<SCH_IO> pi( SCH_IO_MGR::FindPlugin( SCH_IO_MGR::SCH_KICAD ) );
120
121 // The plugin cache owns the returned symbol, so hand back a copy
122 LIB_SYMBOL* cached = pi->LoadSymbol( libPath.GetFullPath(), wxS( "4001" ) );
123
124 return cached ? std::make_unique<LIB_SYMBOL>( *cached ) : nullptr;
125}
126
127
131static void saveToLib( const wxString& aLibPath, const LIB_SYMBOL& aSymbol )
132{
133 IO_RELEASER<SCH_IO> pi( SCH_IO_MGR::FindPlugin( SCH_IO_MGR::SCH_KICAD ) );
134
135 pi->CreateLibrary( aLibPath );
136 pi->SaveSymbol( aLibPath, std::make_unique<LIB_SYMBOL>( aSymbol ) );
137 pi->SaveLibrary( aLibPath );
138}
139
140
144static wxArrayString filterList( const std::vector<wxString>& aFilters )
145{
146 wxArrayString filters;
147
148 for( const wxString& filter : aFilters )
149 filters.Add( filter );
150
151 return filters;
152}
153
154
158static wxString formatted( LIB_SYMBOL& aSymbol )
159{
162 return wxString( out.GetString() );
163}
164
165
169BOOST_FIXTURE_TEST_SUITE( LibPart, TEST_LIB_SYMBOL_FIXTURE )
170
171
172
175BOOST_AUTO_TEST_CASE( DefaultProperties )
176{
177 BOOST_CHECK_EQUAL( m_part_no_data.GetName(), "part_name" );
178
179 // Didn't set a library, so this is empty
180 BOOST_CHECK_EQUAL( m_part_no_data.GetLibraryName(), "" );
181 BOOST_CHECK_EQUAL( m_part_no_data.GetLib(), nullptr );
182
183 // only get the root
184 BOOST_CHECK_EQUAL( m_part_no_data.IsRoot(), true );
185 BOOST_CHECK_EQUAL( m_part_no_data.IsDerived(), false );
186 BOOST_CHECK_EQUAL( m_part_no_data.SharedPtr().use_count(), 2 );
187
188 // no sub units
189 BOOST_CHECK_EQUAL( m_part_no_data.GetUnitCount(), 1 );
190 BOOST_CHECK_EQUAL( m_part_no_data.IsMultiUnit(), false );
191
192 // single body style
193 BOOST_CHECK_EQUAL( m_part_no_data.HasDeMorganBodyStyles(), false );
194}
195
196
200BOOST_AUTO_TEST_CASE( DefaultDrawings )
201{
202 // default drawings exist
203 BOOST_CHECK_EQUAL( m_part_no_data.GetDrawItems().size(), 5 );
204 BOOST_CHECK_EQUAL( m_part_no_data.GetGraphicalPins( 0, 0 ).size(), 0 );
205}
206
207
211BOOST_AUTO_TEST_CASE( DefaultFields )
212{
213 std::vector<SCH_FIELD> fields;
214 m_part_no_data.CopyFields( fields );
215
216 // Should get the 4 default fields
218
219 // but no more (we didn't set them)
220 BOOST_CHECK_EQUAL( fields.size(), 5 );
221
222 // also check the default field accessors
224 ( m_part_no_data.GetReferenceField() )( "Reference" )( (int) FIELD_T::REFERENCE ) );
226 ( m_part_no_data.GetValueField() )( "Value" )( (int) FIELD_T::VALUE ) );
228 ( m_part_no_data.GetFootprintField() )( "Footprint" )( (int) FIELD_T::FOOTPRINT ) );
230 ( m_part_no_data.GetDatasheetField() )( "Datasheet" )( (int) FIELD_T::DATASHEET ) );
232 ( m_part_no_data.GetDescriptionField() )( "Description" )( (int) FIELD_T::DESCRIPTION ) );
233}
234
235
240{
241 std::vector<SCH_FIELD> fields;
242 m_part_no_data.CopyFields( fields );
243
244 // Ctor takes non-const ref (?!)
245 const std::string newFieldName = "new_field";
246 wxString nonConstNewFieldName = newFieldName;
247 fields.push_back( SCH_FIELD( nullptr, FIELD_T::USER, nonConstNewFieldName ) );
248
249 // fairly roundabout way to add a field, but it is what it is
250 m_part_no_data.SetFields( fields );
251
252 // Should get the 4 default fields
254
255 // and our new one
256 BOOST_REQUIRE_EQUAL( fields.size(), 6 );
257
258 // Check by-name lookup
259
260 SCH_FIELD* gotNewField = m_part_no_data.GetField( newFieldName );
261
262 BOOST_REQUIRE_NE( gotNewField, nullptr );
263 BOOST_CHECK_PREDICATE( KI_TEST::FieldNameIdMatches, ( *gotNewField )( newFieldName )( 0 ) );
264}
265
266
270BOOST_AUTO_TEST_CASE( AddedDrawItems )
271{
272 const size_t defaultCount = m_part_no_data.GetDrawItems().size();
273
274 SCH_PIN* pin = new SCH_PIN( &m_part_no_data );
275 pin->SetNumber( "1" );
276 m_part_no_data.AddDrawItem( pin );
277
278 BOOST_CHECK_EQUAL( m_part_no_data.GetDrawItems().size(), defaultCount + 1 );
279 BOOST_CHECK( pin->GetParentSymbol() == &m_part_no_data );
280 BOOST_CHECK_EQUAL( m_part_no_data.GetPinCount(), 1 );
281
282 m_part_no_data.RemoveDrawItem( pin );
283
284 BOOST_CHECK_EQUAL( m_part_no_data.GetDrawItems().size(), defaultCount );
285 BOOST_CHECK_EQUAL( m_part_no_data.GetPinCount(), 0 );
286
287 // Mandatory fields are never removable, so the accessors can't be left dangling
288 m_part_no_data.RemoveDrawItem( &m_part_no_data.GetReferenceField() );
289
290 BOOST_CHECK_EQUAL( m_part_no_data.GetDrawItems().size(), defaultCount );
291}
292
293
298BOOST_AUTO_TEST_CASE( StackedPinNumberLookup )
299{
300 SCH_PIN* pin = new SCH_PIN( &m_part_no_data );
301 pin->SetNumber( "[A1,A12,B1,B12]" );
302 m_part_no_data.AddDrawItem( pin );
303
304 BOOST_CHECK( m_part_no_data.HasPinNumber( "[A1,A12,B1,B12]" ) );
305
306 BOOST_CHECK( m_part_no_data.HasPinNumber( "A1" ) );
307 BOOST_CHECK( m_part_no_data.HasPinNumber( "A12" ) );
308 BOOST_CHECK( m_part_no_data.HasPinNumber( "B1" ) );
309 BOOST_CHECK( m_part_no_data.HasPinNumber( "B12" ) );
310
311 BOOST_CHECK( !m_part_no_data.HasPinNumber( "A2" ) );
312 BOOST_CHECK( !m_part_no_data.HasPinNumber( "[A1" ) );
313}
314
315
320BOOST_AUTO_TEST_CASE( RangeStackedPinNumberLookup )
321{
322 SCH_PIN* pin = new SCH_PIN( &m_part_no_data );
323 pin->SetNumber( "[1-4]" );
324 m_part_no_data.AddDrawItem( pin );
325
326 BOOST_CHECK( m_part_no_data.HasPinNumber( "[1-4]" ) );
327
328 BOOST_CHECK( m_part_no_data.HasPinNumber( "1" ) );
329 BOOST_CHECK( m_part_no_data.HasPinNumber( "3" ) );
330
331 BOOST_CHECK( !m_part_no_data.HasPinNumber( "5" ) );
332}
333
334
336{
339 std::string m_expSubRef;
340};
341
342
346BOOST_AUTO_TEST_CASE( SubReference )
347{
348 const std::vector<TEST_LIB_SYMBOL_SUBREF_CASE> cases = {
349 {
350 1,
351 false,
352 "A",
353 },
354 {
355 2,
356 false,
357 "B",
358 },
359 {
360 26,
361 false,
362 "Z",
363 },
364 {
365 27,
366 false,
367 "AA",
368 },
369 {
370 28,
371 false,
372 "AB",
373 },
374 {
375 53,
376 false,
377 "BA",
378 },
379 {
380 79,
381 false,
382 "CA",
383 },
384 {
385 105,
386 false,
387 "DA",
388 },
389 {
390 131,
391 false,
392 "EA",
393 },
394 {
395 157,
396 false,
397 "FA",
398 },
399 {
400 183,
401 false,
402 "GA",
403 },
404 {
405 209,
406 false,
407 "HA",
408 },
409 {
410 235,
411 false,
412 "IA",
413 },
414 {
415 261,
416 false,
417 "JA",
418 },
419 {
420 287,
421 false,
422 "KA",
423 },
424 {
425 313,
426 false,
427 "LA",
428 },
429 {
430 339,
431 false,
432 "MA",
433 },
434 {
435 365,
436 false,
437 "NA",
438 },
439 {
440 391,
441 false,
442 "OA",
443 },
444 {
445 417,
446 false,
447 "PA",
448 },
449 {
450 443,
451 false,
452 "QA",
453 },
454 {
455 469,
456 false,
457 "RA",
458 },
459 {
460 495,
461 false,
462 "SA",
463 },
464 {
465 521,
466 false,
467 "TA",
468 },
469 {
470 547,
471 false,
472 "UA",
473 },
474 {
475 573,
476 false,
477 "VA",
478 },
479 {
480 599,
481 false,
482 "WA",
483 },
484 {
485 625,
486 false,
487 "XA",
488 },
489 {
490 651,
491 false,
492 "YA",
493 },
494 {
495 677,
496 false,
497 "ZA",
498 },
499 {
500 702,
501 false,
502 "ZZ",
503 },
504 {
505 703,
506 false,
507 "AAA",
508 },
509 {
510 728,
511 false,
512 "AAZ",
513 },
514 };
515
516 for( const auto& c : cases )
517 {
519 "Subref: " << c.m_index << ", " << c.m_addSep << " -> '" << c.m_expSubRef << "'" )
520 {
521 const auto subref = LIB_SYMBOL::LetterSubReference( c.m_index, 'A' );
522 BOOST_CHECK_EQUAL( subref, c.m_expSubRef );
523 }
524 }
525}
526
527
528BOOST_AUTO_TEST_CASE( NativeBezierComparisonHandlesUnequalCaches )
529{
530 LOCALE_IO locale;
531 auto symbol = loadDeMorganSymbol();
532 BOOST_REQUIRE( symbol );
533 SCH_SHAPE* shape = nullptr;
534
535 for( SCH_ITEM& item : symbol->GetDrawItems()[SCH_SHAPE_T] )
536 {
537 shape = static_cast<SCH_SHAPE*>( &item );
538 break;
539 }
540
541 BOOST_REQUIRE( shape );
542 shape->SetShape( SHAPE_T::BEZIER );
543 shape->SetStart( VECTOR2I( 0, 0 ) );
544 shape->SetEnd( VECTOR2I( 100000, 0 ) );
545 shape->SetBezierC1( VECTOR2I( 0, 100000 ) );
546 shape->SetBezierC2( VECTOR2I( 100000, 100000 ) );
547 BOOST_REQUIRE( shape->GetBezierPoints().empty() );
548 SCH_SHAPE rebuilt( *shape );
550 BOOST_REQUIRE( !rebuilt.GetBezierPoints().empty() );
551 const auto& empty = static_cast<const EDA_SHAPE&>( *shape );
552 const auto& populated = static_cast<const EDA_SHAPE&>( rebuilt );
553 BOOST_REQUIRE_NE( empty.Compare( &populated ), 0 );
554 BOOST_CHECK_LT( empty.Compare( &populated ), 0 );
555 BOOST_CHECK_GT( populated.Compare( &empty ), 0 );
556}
557
558
559BOOST_AUTO_TEST_CASE( NativeCapturedDuplicatePinsMatchChecker )
560{
561 LOCALE_IO locale;
562 const auto original = loadDeMorganSymbol();
563 BOOST_REQUIRE( original );
565 std::vector<wxString> messages;
566 CheckDuplicatePins( original.get(), messages, &units );
567 BOOST_REQUIRE( messages.empty() );
568
569 for( int change = 0; change < 7; ++change )
570 {
571 BOOST_TEST_CONTEXT( "native duplicate pin change=" << change )
572 {
573 auto changed = std::make_unique<LIB_SYMBOL>( *original );
574 const auto pins = changed->GetGraphicalPins( 0, 0 );
575 BOOST_REQUIRE( !pins.empty() );
576 auto* extra = static_cast<SCH_PIN*>( pins.front()->Clone() );
577 changed->AddDrawItem( extra );
578
579 switch( change )
580 {
581 case 0: break;
582 case 1: extra->SetBodyStyle( 99 ); break;
583 case 2: extra->SetBodyStyle( 0 ); break;
584 case 3: extra->SetUnit( 0 ); break;
585 case 4: extra->SetNumber( wxS( "[" ) + pins.front()->GetNumber() + wxS( ",98765]" ) ); break;
586 case 5: extra->SetNumber( wxS( "[98765,98765]" ) ); break;
587 case 6: extra->SetNumber( wxS( "[malformed" ) ); break;
588 }
589
590 messages.clear();
591 CheckDuplicatePins( changed.get(), messages, &units );
592 const bool expected = change == 0 || change == 2 || change == 3 || change == 4;
593 BOOST_REQUIRE_EQUAL( !messages.empty(), expected );
594 const auto captured = SCH_CONNECTIVITY::ExtractLibrarySymbolFact( *changed );
595 BOOST_CHECK_EQUAL( captured.HasDuplicatePins(), expected );
596 }
597 }
598}
599
600
601BOOST_AUTO_TEST_CASE( NativeLibrarySnapshotsMatchLiveComparison )
602{
603 LOCALE_IO locale;
604 auto original = loadDeMorganSymbol();
605 BOOST_REQUIRE( original );
606 const auto captured = SCH_CONNECTIVITY::ExtractLibrarySymbolFact( *original );
607 using FLAGS = SCH_ITEM::COMPARE_FLAGS;
608 const int baseFlags = ~( FLAGS::UUID | FLAGS::UNIT | FLAGS::IDENTITY );
609 const std::vector<int> masks{ 0, FLAGS::PIN_VISIBILITIES, FLAGS::PIN_ALT_DEFS, FLAGS::FIELD_TEXT,
610 FLAGS::FIELD_POSITIONS, FLAGS::FIELD_SIZE_AND_STYLE, FLAGS::FIELD_VISIBILITY,
611 FLAGS::MISSING_FIELDS, FLAGS::EXTRA_FIELDS };
612
613 for( int change = 0; change < 13; ++change )
614 {
615 BOOST_TEST_CONTEXT( "native snapshot change=" << change )
616 {
617 LIB_SYMBOL changed( *original );
618 const auto pins = changed.GetGraphicalPins( 0, 0 );
619 BOOST_REQUIRE( !pins.empty() );
620 SCH_PIN* pin = pins.front();
621 SCH_FIELD* field = changed.GetField( FIELD_T::VALUE );
622 BOOST_REQUIRE( field );
623
624 switch( change )
625 {
626 case 0: break;
627 case 1: pin->SetName( pin->GetName() + "_Changed" ); break;
628 case 2: pin->SetVisible( !pin->IsVisible() ); break;
629 case 3:
630 pin->GetAlternates().emplace( wxS( "CapturedAlt" ),
631 SCH_PIN::ALT{ wxS( "CapturedAlt" ), GRAPHIC_PINSHAPE::CLOCK,
633 break;
634 case 4:
635 {
636 auto* extra = static_cast<SCH_PIN*>( pin->Clone() );
637 extra->SetNumber( wxS( "CapturedExtra" ) );
638 changed.AddDrawItem( extra );
639 break;
640 }
641 case 5: changed.AddField( new SCH_FIELD( &changed, FIELD_T::USER, wxS( "CapturedField" ) ) ); break;
642 case 6: field->SetText( field->GetText() + "_Changed" ); break;
643 case 7: field->SetPosition( field->GetPosition() + VECTOR2I( 1000, 2000 ) ); break;
644 case 8: field->SetFont( field->GetFont() ? nullptr : KIFONT::FONT::GetFont( wxString() ) ); break;
645 case 9: changed.SetKeyWords( changed.GetKeyWords() + "_Changed" ); break;
646 case 10:
648 static_cast<SCH_SHAPE&>( changed.GetDrawItems()[SCH_SHAPE_T].front() ).Move( VECTOR2I( 1000, 2000 ) );
649 break;
650 case 11: changed.GetField( FIELD_T::REFERENCE )->SetText( wxS( "ChangedReference" ) ); break;
651 case 12: field->SetVisible( !field->IsVisible() ); break;
652 }
653
654 const auto values = SCH_CONNECTIVITY::ExtractLibrarySymbolFact( changed );
655
656 for( int mask : masks )
657 {
658 const int flags = baseFlags & ~mask;
659 BOOST_CHECK_EQUAL( captured.Matches( values, flags ), original->Compare( changed, flags ) == 0 );
660 BOOST_CHECK_EQUAL( values.Matches( captured, flags ), changed.Compare( *original, flags ) == 0 );
661 }
662 }
663 }
664
665 LIB_SYMBOL baseline( *original );
666 LIB_SYMBOL derived( *original );
667 derived.SetParent( original.get() );
668 const auto inherited = SCH_CONNECTIVITY::ExtractLibrarySymbolFact( derived );
669 BOOST_REQUIRE( inherited.inheritedPins );
670 BOOST_REQUIRE( captured.Matches( inherited, baseFlags ) );
671 SCH_PIN* parentPin = original->GetGraphicalPins( 0, 0 ).front();
672 parentPin->SetLength( parentPin->GetLength() + 1 );
673 const auto editedParent = SCH_CONNECTIVITY::ExtractLibrarySymbolFact( derived );
674 BOOST_CHECK( !captured.Matches( editedParent, baseFlags ) );
675 BOOST_CHECK_NE( baseline.Compare( derived, baseFlags ), 0 );
676}
677
678
679BOOST_AUTO_TEST_CASE( NativeSymbolAttributesMatchCompareFlags )
680{
681 LOCALE_IO locale;
682 auto original = loadDeMorganSymbol();
683 BOOST_REQUIRE( original );
684 const auto captured = original->ComparisonAttributes();
685 using FLAGS = SCH_ITEM::COMPARE_FLAGS;
686 const int flags = ~( FLAGS::UUID | FLAGS::UNIT | FLAGS::IDENTITY );
687 const std::vector<std::pair<int, std::function<void( LIB_SYMBOL& )>>> changes{
688 { 0, []( auto& symbol ) { symbol.SetLocalPower(); } },
689 { 0, []( auto& symbol ) { symbol.SetUnitCount( symbol.GetUnitCount() + 1, false ); } },
690 { 0, []( auto& symbol ) { symbol.SetKeyWords( symbol.GetKeyWords() + " CapturedKeyword" ); } },
691 { 0, []( auto& symbol ) { symbol.SetPinNameOffset( symbol.GetPinNameOffset() + 1 ); } },
692 { 0, []( auto& symbol ) { symbol.LockUnits( !symbol.UnitsLocked() ); } },
693 { 0, []( auto& symbol ) { symbol.GetUnitDisplayNames()[1] = wxS( "CapturedUnit" ); } },
694 { 0, []( auto& symbol ) { symbol.SetBodyStyleNames( { wxS( "CapturedBody" ) } ); } },
695 { 0, []( auto& symbol )
696 {
697 auto filters = symbol.GetFPFilters();
698 filters.Add( wxS( "CapturedFilter*" ) );
699 symbol.SetFPFilters( filters );
700 } },
701 { FLAGS::PIN_VISIBILITIES, []( auto& symbol ) { symbol.SetShowPinNames( !symbol.GetShowPinNames() ); } },
702 { FLAGS::PIN_VISIBILITIES, []( auto& symbol ) { symbol.SetShowPinNumbers( !symbol.GetShowPinNumbers() ); } },
703 { FLAGS::EXCLUDE_FROM_SIM,
704 []( auto& symbol ) { symbol.SetExcludedFromSim( !symbol.GetExcludedFromSim() ); } },
705 { FLAGS::EXCLUDE_FROM_BOM,
706 []( auto& symbol ) { symbol.SetExcludedFromBOM( !symbol.GetExcludedFromBOM() ); } },
707 { FLAGS::EXCLUDE_FROM_BOARD,
708 []( auto& symbol ) { symbol.SetExcludedFromBoard( !symbol.GetExcludedFromBoard() ); } },
709 { FLAGS::EXCLUDE_FROM_POS_FILES,
710 []( auto& symbol ) { symbol.SetExcludedFromPosFiles( !symbol.GetExcludedFromPosFiles() ); } },
711 { FLAGS::DNP, []( auto& symbol ) { symbol.SetDNP( !symbol.GetDNP() ); } }
712 };
713
714 for( size_t i = 0; i < changes.size(); ++i )
715 {
716 BOOST_TEST_CONTEXT( "native attribute change=" << i )
717 {
718 LIB_SYMBOL changed( *original );
719 BOOST_REQUIRE( captured.Matches( changed.ComparisonAttributes(), flags ) );
720 BOOST_REQUIRE_EQUAL( original->Compare( changed, flags ), 0 );
721 const auto& [optionalFlag, mutate] = changes[i];
722 mutate( changed );
723 const auto values = changed.ComparisonAttributes();
724 BOOST_CHECK( captured != values );
725 BOOST_CHECK( !captured.Matches( values, flags ) );
726 BOOST_CHECK_NE( original->Compare( changed, flags ), 0 );
727
728 if( optionalFlag )
729 {
730 BOOST_CHECK( captured.Matches( values, flags & ~optionalFlag ) );
731 BOOST_CHECK_EQUAL( original->Compare( changed, flags & ~optionalFlag ), 0 );
732 }
733 }
734 }
735
736 original->SetDuplicatePinNumbersAreJumpers( !captured.duplicatePinNumbersAreJumpers );
737 const auto jumpers = original->ComparisonAttributes();
738 BOOST_CHECK( captured != jumpers );
739 BOOST_CHECK( captured.Matches( jumpers, flags ) );
740
741 const auto pins = original->GetGraphicalPins( 0, 0 );
742 BOOST_REQUIRE( !pins.empty() );
743 PIN_MAP map( wxS( "CapturedAttributes" ) );
744 map.SetEntry( pins.front()->GetNumber(), wxS( "CapturedPad" ) );
745 original->PinMaps().AddOrReplace( map );
746 const auto mapped = original->ComparisonAttributes();
747 BOOST_CHECK( !captured.Matches( mapped, flags ) );
748 original->PinMaps().FindByName( map.GetName() )->SetEntry( pins.front()->GetNumber(), wxS( "LaterPad" ) );
749 BOOST_CHECK( !mapped.Matches( original->ComparisonAttributes(), flags ) );
750 BOOST_CHECK_EQUAL( mapped.pinMaps.FindByName( map.GetName() )->GetPadNumber( pins.front()->GetNumber() ),
751 wxString( "CapturedPad" ) );
752
753 LIB_ID footprint;
754 footprint.SetLibNickname( wxS( "CapturedLibrary" ) );
755 footprint.SetLibItemName( wxS( "CapturedFootprint" ) );
756 original->SetAssociatedFootprints( { { footprint, map.GetName() } } );
757 const auto associated = original->ComparisonAttributes();
758 original->SetAssociatedFootprints( {} );
759 BOOST_CHECK( !associated.Matches( original->ComparisonAttributes(), flags ) );
760}
761
762
767{
768 // Identical root part to m_part_no_data sans time stamp.
769 LIB_SYMBOL testPart( "part_name" );
770
771 // Self comparison test.
772 BOOST_CHECK_EQUAL( m_part_no_data.Compare( m_part_no_data ), 0 );
773
774 // Test for identical LIB_SYMBOL.
775 BOOST_CHECK_EQUAL( m_part_no_data.Compare( testPart, ~SCH_ITEM::COMPARE_FLAGS::UUID ), 0 );
776
777 // Test name.
778 testPart.SetName( "tart_name" );
779 BOOST_CHECK( m_part_no_data.Compare( testPart ) < 0 );
780 testPart.SetName( "cart_name" );
781 BOOST_CHECK( m_part_no_data.Compare( testPart ) > 0 );
782 testPart.SetName( "part_name" );
783
784 // LIB_ID comparison tests.
785 LIB_ID id = testPart.GetLibId();
786 id.SetLibItemName( "tart_name" );
787 testPart.SetLibId( id );
788 BOOST_CHECK( m_part_no_data.Compare( testPart ) < 0 );
789 id.SetLibItemName( "cart_name" );
790 testPart.SetLibId( id );
791 BOOST_CHECK( m_part_no_data.Compare( testPart ) > 0 );
792 id.SetLibItemName( "part_name" );
793 testPart.SetLibId( id );
794
795 // Unit count comparison tests.
796 testPart.SetUnitCount( 2, true );
797 BOOST_CHECK( m_part_no_data.Compare( testPart ) < 0 );
798 testPart.SetUnitCount( 1, true );
799 m_part_no_data.SetUnitCount( 2, true );
800 BOOST_CHECK( m_part_no_data.Compare( testPart ) > 0 );
801 m_part_no_data.SetUnitCount( 1, true );
802
803 // Options flag comparison tests.
804 testPart.SetGlobalPower();
805 BOOST_CHECK( m_part_no_data.Compare( testPart ) < 0 );
806 testPart.SetNormal();
807 m_part_no_data.SetGlobalPower();
808 BOOST_CHECK( m_part_no_data.Compare( testPart ) > 0 );
809 m_part_no_data.SetNormal();
810
811 // Draw item list size comparison tests.
813 m_part_no_data.AddDrawItem( new SCH_SHAPE( SHAPE_T::RECTANGLE, LAYER_DEVICE ) );
814 BOOST_CHECK_EQUAL( m_part_no_data.Compare( testPart, ~SCH_ITEM::COMPARE_FLAGS::UUID ), 0 );
815 m_part_no_data.RemoveDrawItem( &m_part_no_data.GetDrawItems()[SCH_SHAPE_T].front() );
816 BOOST_CHECK( m_part_no_data.Compare( testPart, ~SCH_ITEM::COMPARE_FLAGS::UUID ) < 0 );
817 testPart.RemoveDrawItem( &testPart.GetDrawItems()[SCH_SHAPE_T].front() );
818 m_part_no_data.AddDrawItem( new SCH_SHAPE( SHAPE_T::RECTANGLE, LAYER_DEVICE ) );
819 BOOST_CHECK( m_part_no_data.Compare( testPart, ~SCH_ITEM::COMPARE_FLAGS::UUID ) > 0 );
820 m_part_no_data.RemoveDrawItem( &m_part_no_data.GetDrawItems()[SCH_SHAPE_T].front() );
821
822 // Draw item list contents comparison tests.
824 m_part_no_data.AddDrawItem( new SCH_SHAPE( SHAPE_T::ARC, LAYER_DEVICE ) );
825 BOOST_CHECK( m_part_no_data.Compare( testPart, ~SCH_ITEM::COMPARE_FLAGS::UUID ) > 0 );
826 m_part_no_data.RemoveDrawItem( &m_part_no_data.GetDrawItems()[SCH_SHAPE_T].front() );
827 testPart.RemoveDrawItem( &testPart.GetDrawItems()[SCH_SHAPE_T].front() );
828 m_part_no_data.AddDrawItem( new SCH_PIN( &m_part_no_data ) );
829 BOOST_CHECK( m_part_no_data.Compare( testPart, ~SCH_ITEM::COMPARE_FLAGS::UUID ) > 0 );
830 m_part_no_data.RemoveDrawItem( &m_part_no_data.GetDrawItems()[SCH_PIN_T].front() );
831
832 // Footprint filter array comparison tests.
833 wxArrayString footPrintFilters;
834 BOOST_CHECK( m_part_no_data.GetFPFilters() == footPrintFilters );
835 footPrintFilters.Add( "b" );
836 testPart.SetFPFilters( footPrintFilters );
837 BOOST_CHECK( m_part_no_data.Compare( testPart, ~SCH_ITEM::COMPARE_FLAGS::UUID ) < 0 );
838 m_part_no_data.SetFPFilters( footPrintFilters );
839 footPrintFilters.Clear();
840 testPart.SetFPFilters( footPrintFilters );
841 BOOST_CHECK( m_part_no_data.Compare( testPart, ~SCH_ITEM::COMPARE_FLAGS::UUID ) > 0 );
842 footPrintFilters.Clear();
843 m_part_no_data.SetFPFilters( footPrintFilters );
844 testPart.SetFPFilters( footPrintFilters );
845
846 // Description string tests.
847 m_part_no_data.SetDescription( "b" );
848 testPart.SetDescription( "b" );
849 BOOST_CHECK_EQUAL( m_part_no_data.Compare( testPart, ~SCH_ITEM::COMPARE_FLAGS::UUID ), 0 );
850 m_part_no_data.SetDescription( "a" );
851 BOOST_CHECK( m_part_no_data.Compare( testPart, ~SCH_ITEM::COMPARE_FLAGS::UUID ) < 0 );
852 m_part_no_data.SetDescription( "c" );
853 BOOST_CHECK( m_part_no_data.Compare( testPart, ~SCH_ITEM::COMPARE_FLAGS::UUID ) > 0 );
854 m_part_no_data.SetDescription( wxEmptyString );
855 testPart.SetDescription( wxEmptyString );
856
857 // Key word string tests.
858 m_part_no_data.SetKeyWords( "b" );
859 testPart.SetKeyWords( "b" );
860 BOOST_CHECK_EQUAL( m_part_no_data.Compare( testPart, ~SCH_ITEM::COMPARE_FLAGS::UUID ), 0 );
861 m_part_no_data.SetKeyWords( "a" );
862 BOOST_CHECK( m_part_no_data.Compare( testPart, ~SCH_ITEM::COMPARE_FLAGS::UUID ) < 0 );
863 m_part_no_data.SetKeyWords( "c" );
864 BOOST_CHECK( m_part_no_data.Compare( testPart, ~SCH_ITEM::COMPARE_FLAGS::UUID ) > 0 );
865 m_part_no_data.SetKeyWords( wxEmptyString );
866 testPart.SetKeyWords( wxEmptyString );
867
868 // Pin name offset comparison tests.
869 testPart.SetPinNameOffset( testPart.GetPinNameOffset() + 1 );
870 BOOST_CHECK( m_part_no_data.Compare( testPart, ~SCH_ITEM::COMPARE_FLAGS::UUID ) < 0 );
871 testPart.SetPinNameOffset( testPart.GetPinNameOffset() - 2 );
872 BOOST_CHECK( m_part_no_data.Compare( testPart, ~SCH_ITEM::COMPARE_FLAGS::UUID ) > 0 );
873 testPart.SetPinNameOffset( testPart.GetPinNameOffset() + 1 );
874
875 // Units locked flag comparison tests.
876 testPart.LockUnits( true );
877 BOOST_CHECK( m_part_no_data.Compare( testPart, ~SCH_ITEM::COMPARE_FLAGS::UUID ) < 0 );
878 testPart.LockUnits( false );
879 m_part_no_data.LockUnits( true );
880 BOOST_CHECK( m_part_no_data.Compare( testPart, ~SCH_ITEM::COMPARE_FLAGS::UUID ) > 0 );
881 m_part_no_data.LockUnits( false );
882
883 // Include in BOM support tests.
884 testPart.SetExcludedFromBOM( true );
885 BOOST_CHECK( m_part_no_data.Compare( testPart, ~SCH_ITEM::COMPARE_FLAGS::UUID ) > 0 );
886 testPart.SetExcludedFromBOM( false );
887 m_part_no_data.SetExcludedFromBOM( true );
888 BOOST_CHECK( m_part_no_data.Compare( testPart, ~SCH_ITEM::COMPARE_FLAGS::UUID ) < 0 );
889 m_part_no_data.SetExcludedFromBOM( false );
890
891 // Include on board support tests.
892 testPart.SetExcludedFromBoard( true );
893 BOOST_CHECK( m_part_no_data.Compare( testPart, ~SCH_ITEM::COMPARE_FLAGS::UUID ) > 0 );
894 testPart.SetExcludedFromBoard( false );
895 m_part_no_data.SetExcludedFromBoard( true );
896 BOOST_CHECK( m_part_no_data.Compare( testPart, ~SCH_ITEM::COMPARE_FLAGS::UUID ) < 0 );
897 m_part_no_data.SetExcludedFromBoard( false );
898
899 // Include in position files support tests.
900 testPart.SetExcludedFromPosFiles( true );
901 BOOST_CHECK( m_part_no_data.Compare( testPart, ~SCH_ITEM::COMPARE_FLAGS::UUID ) > 0 );
902 testPart.SetExcludedFromPosFiles( false );
903 m_part_no_data.SetExcludedFromPosFiles( true );
904 BOOST_CHECK( m_part_no_data.Compare( testPart, ~SCH_ITEM::COMPARE_FLAGS::UUID ) < 0 );
905 m_part_no_data.SetExcludedFromPosFiles( false );
906
907 // Show pin names flag comparison tests.
908 m_part_no_data.SetShowPinNames( false );
909 BOOST_CHECK( m_part_no_data.Compare( testPart, ~SCH_ITEM::COMPARE_FLAGS::UUID ) < 0 );
910 m_part_no_data.SetShowPinNames( true );
911 testPart.SetShowPinNames( false );
912 BOOST_CHECK( m_part_no_data.Compare( testPart, ~SCH_ITEM::COMPARE_FLAGS::UUID ) > 0 );
913 testPart.SetShowPinNames( true );
914
915 // Show pin numbers flag comparison tests.
916 m_part_no_data.SetShowPinNumbers( false );
917 BOOST_CHECK( m_part_no_data.Compare( testPart, ~SCH_ITEM::COMPARE_FLAGS::UUID ) < 0 );
918 m_part_no_data.SetShowPinNumbers( true );
919 testPart.SetShowPinNumbers( false );
920 BOOST_CHECK( m_part_no_data.Compare( testPart, ~SCH_ITEM::COMPARE_FLAGS::UUID ) > 0 );
921 testPart.SetShowPinNumbers( true );
922
923 // Time stamp comparison tests.
924
925 // Check to see if we broke the copy ctor.
926 LIB_SYMBOL copy( testPart );
927 BOOST_CHECK( testPart.Compare( copy ) == 0 );
928}
929
930
934BOOST_AUTO_TEST_CASE( GetUnitItems )
935{
936 // There are no unit draw items in the empty LIB_SYMBOL object.
937 BOOST_CHECK( m_part_no_data.GetUnitDrawItems( 1, 1 ).size() == 0 );
938
939 // A single unique unit with 1 pin common to all units and all body styles.
940 SCH_PIN* pin1 = new SCH_PIN( &m_part_no_data );
941 m_part_no_data.AddDrawItem( pin1 );
942 BOOST_CHECK( m_part_no_data.GetUnitDrawItems( ALL_UNITS, ALL_BODY_STYLES ).size() == 1 );
943
944 // A single unique unit with 1 pin in unit 1 and common to all body styles.
945 pin1->SetUnit( 1 );
946 BOOST_CHECK( m_part_no_data.GetUnitDrawItems( 1, ALL_BODY_STYLES ).size() == 1 );
947
948 // A single unique unit with 1 pin in unit 1 and body style 1.
949 pin1->SetBodyStyle( 1 );
950 BOOST_CHECK( m_part_no_data.GetUnitDrawItems( 1, 1 ).size() == 1 );
951
952 // Two unique units with pin 1 assigned to unit 1 and body style 1 and pin 2 assigned to
953 // unit 2 and body style 1.
954 SCH_PIN* pin2 = new SCH_PIN( &m_part_no_data );
955 m_part_no_data.SetUnitCount( 2, true );
956 pin2->SetUnit( 2 );
957 pin2->SetBodyStyle( 2 );
958 pin2->SetNumber( "4" );
959 m_part_no_data.AddDrawItem( pin2 );
960 BOOST_CHECK( m_part_no_data.GetUnitDrawItems( 2, 2 ).size() == 1 );
961
962 // Make pin 1 body style common to all body styles.
963 pin1->SetBodyStyle( ALL_BODY_STYLES );
964 BOOST_CHECK( m_part_no_data.GetUnitDrawItems( 1, 1 ).size() == 1 );
965 BOOST_CHECK( m_part_no_data.GetUnitDrawItems( 2, 1 ).size() == 1 );
966
967 m_part_no_data.RemoveDrawItem( pin2 );
968 m_part_no_data.RemoveDrawItem( pin1 );
969 m_part_no_data.RemoveDrawItem( &*m_part_no_data.GetDrawItems().begin() );
970}
971
972
976BOOST_AUTO_TEST_CASE( GetUnitDrawItems )
977{
978 // An empty symbol still reports its unit and body style so the saver writes them out
979 std::vector<struct LIB_SYMBOL_UNIT> units = m_part_no_data.GetUnitDrawItems();
980
981 BOOST_REQUIRE_EQUAL( units.size(), 1u );
982 BOOST_CHECK_EQUAL( units[0].m_unit, 1 );
983 BOOST_CHECK_EQUAL( units[0].m_bodyStyle, 1 );
984 BOOST_CHECK( units[0].m_items.empty() );
985
986 // A pin common to all units and all body styles matches no numbered unit and gets a
987 // record of its own rather than being dropped
988 SCH_PIN* pin1 = new SCH_PIN( &m_part_no_data );
989 pin1->SetNumber( "1" );
990 m_part_no_data.AddDrawItem( pin1 );
991
992 units = m_part_no_data.GetUnitDrawItems();
993
994 BOOST_REQUIRE_EQUAL( units.size(), 2u );
995 BOOST_CHECK_EQUAL( units[0].m_unit, 0 );
996 BOOST_CHECK_EQUAL( units[0].m_bodyStyle, 0 );
997 BOOST_REQUIRE_EQUAL( units[0].m_items.size(), 1u );
998 BOOST_CHECK_EQUAL( units[0].m_items[0], pin1 );
999 BOOST_CHECK_EQUAL( units[1].m_unit, 1 );
1000 BOOST_CHECK_EQUAL( units[1].m_bodyStyle, 1 );
1001 BOOST_CHECK( units[1].m_items.empty() );
1002
1003 // Units without draw items of their own are still reported
1004 m_part_no_data.SetUnitCount( 3, true );
1005
1006 units = m_part_no_data.GetUnitDrawItems();
1007
1008 BOOST_REQUIRE_EQUAL( units.size(), 4u );
1009 BOOST_CHECK_EQUAL( units[0].m_unit, 0 );
1010 BOOST_CHECK_EQUAL( units[1].m_unit, 1 );
1011 BOOST_CHECK_EQUAL( units[2].m_unit, 2 );
1012 BOOST_CHECK_EQUAL( units[3].m_unit, 3 );
1013 BOOST_CHECK( units[1].m_items.empty() );
1014 BOOST_CHECK( units[2].m_items.empty() );
1015 BOOST_CHECK( units[3].m_items.empty() );
1016
1017 // Both body styles of every unit are reported once De Morgan is enabled
1018 m_part_no_data.SetHasDeMorganBodyStyles( true );
1019
1020 units = m_part_no_data.GetUnitDrawItems();
1021
1022 BOOST_REQUIRE_EQUAL( units.size(), 7u );
1023 BOOST_CHECK_EQUAL( units[1].m_bodyStyle, 1 );
1024 BOOST_CHECK_EQUAL( units[2].m_bodyStyle, 2 );
1025}
1026
1027
1032{
1033 std::unique_ptr<LIB_SYMBOL> parent = std::make_unique<LIB_SYMBOL>( "parent" );
1034 BOOST_CHECK( parent->IsRoot() );
1035 BOOST_CHECK_EQUAL( parent->GetInheritanceDepth(), 0 );
1036
1037 std::unique_ptr<LIB_SYMBOL> ref = std::make_unique<LIB_SYMBOL>( *parent );
1038
1039 std::unique_ptr<LIB_SYMBOL> child = std::make_unique<LIB_SYMBOL>( "child", parent.get() );
1040 BOOST_CHECK( child->IsDerived() );
1041 BOOST_CHECK_EQUAL( child->GetInheritanceDepth(), 1 );
1042
1043 std::unique_ptr<LIB_SYMBOL> grandChild = std::make_unique<LIB_SYMBOL>( "grandchild", child.get() );
1044 BOOST_CHECK( grandChild->IsDerived() );
1045 BOOST_CHECK_EQUAL( grandChild->GetInheritanceDepth(), 2 );
1046
1047 BOOST_CHECK( parent->GetRootSymbol().get() == parent.get() );
1048 BOOST_CHECK( child->GetRootSymbol().get() == parent.get() );
1049 BOOST_CHECK( grandChild->GetRootSymbol().get() == parent.get() );
1050
1051 std::shared_ptr<LIB_SYMBOL> parentRef = child->GetParent().lock();
1052 BOOST_CHECK( parentRef );
1053 BOOST_CHECK( parentRef == parent->SharedPtr() );
1054 BOOST_CHECK_EQUAL( parent->SharedPtr().use_count(), 3 );
1055
1056 std::shared_ptr<LIB_SYMBOL> childRef = grandChild->GetParent().lock();
1057 BOOST_CHECK( childRef );
1058 BOOST_CHECK( childRef == child->SharedPtr() );
1059 BOOST_CHECK_EQUAL( child->SharedPtr().use_count(), 3 );
1060
1061 BOOST_CHECK_EQUAL( child->GetUnitCount(), 1 );
1062 parent->SetUnitCount( 4, true );
1063 BOOST_CHECK_EQUAL( child->GetUnitCount(), 4 );
1064 parent->SetUnitCount( 1, true );
1065
1066 parent->GetField( FIELD_T::DATASHEET )->SetText( "https://kicad/resistors.pdf" );
1067 ref->GetField( FIELD_T::DATASHEET )->SetText( "https://kicad/resistors.pdf" );
1068
1069 BOOST_CHECK( *parent == *ref );
1070
1071 ref->SetName( "child" );
1072 SCH_FIELD* field = new SCH_FIELD( nullptr, FIELD_T::USER, "Manufacturer" );
1073 field->SetText( "KiCad" );
1074 child->AddField( field );
1075 field->SetParent( child.get() );
1076
1077 field = new SCH_FIELD( nullptr, FIELD_T::USER, "Manufacturer" );
1078 field->SetText( "KiCad" );
1079 ref->AddField( field );
1080 field->SetParent( ref.get() );
1081
1082 BOOST_CHECK( *ref == *child->Flatten() );
1083
1084 ref->SetName( "grandchild" );
1085 field = new SCH_FIELD( nullptr, FIELD_T::USER, "MPN" );
1086 field->SetText( "123456" );
1087 grandChild->AddField( field );
1088 field->SetParent( grandChild.get() );
1089
1090 field = new SCH_FIELD( nullptr, FIELD_T::USER, "MPN" );
1091 field->SetText( "123456" );
1092 ref->AddField( field );
1093 field->SetParent( ref.get() );
1094
1095 BOOST_CHECK( *ref == *grandChild->Flatten() );
1096
1097 BOOST_CHECK_EQUAL( grandChild->Flatten()->GetField( FIELD_T::DATASHEET )->GetText(),
1098 "https://kicad/resistors.pdf" );
1099
1100 child->SetParent();
1101 BOOST_CHECK_EQUAL( child->GetUnitCount(), 1 );
1102
1103 parentRef.reset();
1104 BOOST_CHECK_EQUAL( parent->SharedPtr().use_count(), 2 );
1105}
1106
1107
1111BOOST_AUTO_TEST_CASE( CopyConstructor )
1112{
1113 std::shared_ptr<LIB_SYMBOL> copy = std::make_shared<LIB_SYMBOL>( m_part_no_data );
1114 BOOST_CHECK( m_part_no_data == *copy.get() );
1115}
1116
1117
1122{
1123 std::unique_ptr<LIB_SYMBOL> symbol = std::make_unique<LIB_SYMBOL>( "power" );
1124 SCH_PIN* pin = new SCH_PIN( symbol.get() );
1125 pin->SetNumber( "1" );
1127 pin->SetVisible( false );
1128 symbol->AddDrawItem( pin );
1129
1130 BOOST_CHECK( !symbol->IsPower() );
1131 BOOST_CHECK( symbol->IsNormal() );
1132
1133 symbol->SetGlobalPower();
1134 BOOST_CHECK( symbol->IsPower() );
1135 BOOST_CHECK( !symbol->IsNormal() );
1136
1137 // symbol->SetNormal();
1138 // symbol->GetReferenceField().SetText( wxS( "#PWR" ) );
1139 // BOOST_CHECK( symbol->IsPower() );
1140
1141 // Legacy power symbols are limited to a single pin.
1142 // pin = new LIB_PIN( symbol.get() );
1143 // pin->SetNumber( "2" );
1144 // pin->SetType( ELECTRICAL_PINTYPE::PT_POWER_IN );
1145 // pin->SetVisible( false );
1146 // symbol->AddDrawItem( pin );
1147 // BOOST_CHECK( !symbol->IsPower() );
1148}
1149
1150
1160BOOST_AUTO_TEST_CASE( SetUnitCountRejectsInvalidValues )
1161{
1162 auto checkMandatoryFields = []( LIB_SYMBOL& aSymbol )
1163 {
1164 BOOST_CHECK_EQUAL( aSymbol.GetUnitCount(), 1 );
1165 BOOST_CHECK_NE( aSymbol.GetField( FIELD_T::REFERENCE ), nullptr );
1166 BOOST_CHECK_NE( aSymbol.GetField( FIELD_T::VALUE ), nullptr );
1167 BOOST_CHECK_NE( aSymbol.GetField( FIELD_T::FOOTPRINT ), nullptr );
1168 BOOST_CHECK_NE( aSymbol.GetField( FIELD_T::DATASHEET ), nullptr );
1169 BOOST_CHECK_NE( aSymbol.GetField( FIELD_T::DESCRIPTION ), nullptr );
1170
1171 // Reading the reference field text must not crash. This was the original SIGSEGV
1172 // path through CONNECTION_SUBGRAPH::GetDriverPriority() reported in issue 23788.
1173 BOOST_CHECK_NO_THROW( (void) aSymbol.GetReferenceField().GetText() );
1174 };
1175
1176 // Sanity check the freshly constructed symbol.
1177 LIB_SYMBOL baseline( wxS( "test_part" ) );
1178 checkMandatoryFields( baseline );
1179
1180 // When wxDEBUG_LEVEL > 0 the wxCHECK fires (caught by CHECK_WX_ASSERT) and the function
1181 // does not modify the symbol. With wxDEBUG_LEVEL == 0 the wxCHECK is silent and the
1182 // function returns early without modification. Cover both call paths so the test
1183 // exercises the actual SetUnitCount entry on every build configuration.
1184 LIB_SYMBOL zeroCount( wxS( "test_part" ) );
1185 CHECK_WX_ASSERT( zeroCount.SetUnitCount( 0, true ) );
1186#if wxDEBUG_LEVEL == 0
1187 zeroCount.SetUnitCount( 0, true );
1188#endif
1189 checkMandatoryFields( zeroCount );
1190
1191 LIB_SYMBOL negativeCount( wxS( "test_part" ) );
1192 CHECK_WX_ASSERT( negativeCount.SetUnitCount( -1, true ) );
1193#if wxDEBUG_LEVEL == 0
1194 negativeCount.SetUnitCount( -1, true );
1195#endif
1196 checkMandatoryFields( negativeCount );
1197}
1198
1199
1209BOOST_AUTO_TEST_CASE( DeleteDeMorganBodyStyleDrawItems )
1210{
1211 for( bool clearFlagFirst : { false, true } )
1212 {
1213 std::unique_ptr<LIB_SYMBOL> symbol = loadDeMorganSymbol();
1214 BOOST_REQUIRE( symbol );
1215 BOOST_REQUIRE( symbol->HasDeMorganBodyStyles() );
1217
1218 if( clearFlagFirst )
1219 {
1220 symbol->SetHasDeMorganBodyStyles( false );
1221 symbol->SetBodyStyleCount( 1, false, false );
1222 }
1223 else
1224 {
1225 symbol->SetBodyStyleCount( 1, false, false );
1226 symbol->SetHasDeMorganBodyStyles( false );
1227 }
1228
1229 symbol->SetBodyStyleNames( {} );
1230
1231 BOOST_CHECK_EQUAL( symbol->GetBodyStyleCount(), 1 );
1233 }
1234}
1235
1236
1241BOOST_AUTO_TEST_CASE( OrphanedBodyStyleItemsAreNotLoaded )
1242{
1243 std::unique_ptr<LIB_SYMBOL> symbol = loadDeMorganSymbol();
1244 BOOST_REQUIRE( symbol );
1245
1246 // Reproduce what a broken save left on disk: no De Morgan declaration, alternate drawings
1247 symbol->SetHasDeMorganBodyStyles( false );
1249
1250 SCOPED_TEMP_LIB tempLib;
1251 saveToLib( tempLib.GetPath(), *symbol );
1252
1253 IO_RELEASER<SCH_IO> pi( SCH_IO_MGR::FindPlugin( SCH_IO_MGR::SCH_KICAD ) );
1254 LIB_SYMBOL* reloaded = pi->LoadSymbol( tempLib.GetPath(), wxS( "4001" ) );
1255
1256 BOOST_REQUIRE( reloaded );
1257 BOOST_CHECK_EQUAL( reloaded->GetBodyStyleCount(), 1 );
1259
1260 // The standard body style must survive the pruning
1261 BOOST_CHECK( !reloaded->GetUnitDrawItems( 1, BODY_STYLE::BASE ).empty() );
1262 BOOST_CHECK_EQUAL( reloaded->GetUnitCount(), symbol->GetUnitCount() );
1263}
1264
1265
1266BOOST_AUTO_TEST_CASE( NativeComparisonDetectsPinTypeChanges )
1267{
1268 LOCALE_IO locale;
1269 const auto original = loadDeMorganSymbol();
1270 BOOST_REQUIRE( original );
1271 LIB_SYMBOL changed( *original );
1274 BOOST_REQUIRE_EQUAL( original->Compare( changed, flags ), 0 );
1275 BOOST_REQUIRE_EQUAL( changed.Compare( *original, flags ), 0 );
1276 SCH_PIN* pin = changed.GetGraphicalPins( 0, 0 ).front();
1277 BOOST_REQUIRE( pin );
1278 const auto previous = pin->GetType();
1281 BOOST_REQUIRE( pin->GetType() != previous );
1282 BOOST_CHECK_NE( original->Compare( changed, flags ), 0 );
1283 BOOST_CHECK_NE( changed.Compare( *original, flags ), 0 );
1284}
1285
1286
1287BOOST_AUTO_TEST_CASE( NativeComparisonDetectsAddedPins )
1288{
1289 LOCALE_IO locale;
1290 const auto original = loadDeMorganSymbol();
1291 BOOST_REQUIRE( original );
1292 LIB_SYMBOL changed( *original );
1295 BOOST_REQUIRE_EQUAL( original->Compare( changed, flags ), 0 );
1296 BOOST_REQUIRE_EQUAL( changed.Compare( *original, flags ), 0 );
1297 const auto pins = original->GetGraphicalPins( 0, 0 );
1298 BOOST_REQUIRE( !pins.empty() );
1299 auto* extra = static_cast<SCH_PIN*>( pins.front()->Clone() );
1300 extra->SetNumber( "NativeExtra" );
1301 changed.AddDrawItem( extra );
1302 BOOST_REQUIRE_EQUAL( changed.GetGraphicalPins( 0, 0 ).size(), pins.size() + 1 );
1303 BOOST_CHECK_NE( original->Compare( changed, flags ), 0 );
1304 BOOST_CHECK_NE( changed.Compare( *original, flags ), 0 );
1305}
1306
1307
1308BOOST_AUTO_TEST_CASE( NativeComparisonHonorsMissingAndExtraFieldFlags )
1309{
1310 LOCALE_IO locale;
1311 const auto original = loadDeMorganSymbol();
1312 BOOST_REQUIRE( original );
1313 LIB_SYMBOL changed( *original );
1316 BOOST_REQUIRE_EQUAL( original->Compare( changed, flags ), 0 );
1317 BOOST_REQUIRE_EQUAL( changed.Compare( *original, flags ), 0 );
1318 const wxString name( "Native comparison field" );
1319 BOOST_REQUIRE( !original->GetField( name ) );
1320 changed.AddField( new SCH_FIELD( &changed, FIELD_T::USER, name ) );
1321 BOOST_REQUIRE( changed.GetField( name ) );
1322 BOOST_CHECK_EQUAL( original->Compare( changed, flags & ~SCH_ITEM::COMPARE_FLAGS::MISSING_FIELDS ), 0 );
1323 BOOST_CHECK_EQUAL( changed.Compare( *original, flags & ~SCH_ITEM::COMPARE_FLAGS::EXTRA_FIELDS ), 0 );
1324 BOOST_CHECK_NE( original->Compare( changed, flags ), 0 );
1325 BOOST_CHECK_NE( changed.Compare( *original, flags ), 0 );
1326}
1327
1328
1329BOOST_AUTO_TEST_CASE( NativeComparisonHonorsPinVisibilityFlag )
1330{
1331 LOCALE_IO locale;
1332 const auto original = loadDeMorganSymbol();
1333 BOOST_REQUIRE( original );
1334 LIB_SYMBOL changed( *original );
1337 BOOST_REQUIRE_EQUAL( original->Compare( changed, flags ), 0 );
1338 BOOST_REQUIRE_EQUAL( changed.Compare( *original, flags ), 0 );
1339 const auto pins = changed.GetGraphicalPins( 0, 0 );
1340 BOOST_REQUIRE( !pins.empty() );
1341 SCH_PIN* pin = pins.front();
1342 pin->SetVisible( !pin->IsVisible() );
1343 BOOST_CHECK_EQUAL( original->Compare( changed, flags & ~SCH_ITEM::COMPARE_FLAGS::PIN_VISIBILITIES ), 0 );
1344 BOOST_CHECK_EQUAL( changed.Compare( *original, flags & ~SCH_ITEM::COMPARE_FLAGS::PIN_VISIBILITIES ), 0 );
1345 BOOST_CHECK_NE( original->Compare( changed, flags ), 0 );
1346 BOOST_CHECK_NE( changed.Compare( *original, flags ), 0 );
1347}
1348
1349
1350BOOST_AUTO_TEST_CASE( NativeComparisonHonorsAlternateDefinitionFlag )
1351{
1352 LOCALE_IO locale;
1353 const auto original = loadDeMorganSymbol();
1354 BOOST_REQUIRE( original );
1355 LIB_SYMBOL changed( *original );
1358 BOOST_REQUIRE_EQUAL( original->Compare( changed, flags ), 0 );
1359 BOOST_REQUIRE_EQUAL( changed.Compare( *original, flags ), 0 );
1360 const auto pins = changed.GetGraphicalPins( 0, 0 );
1361 BOOST_REQUIRE( !pins.empty() );
1362 SCH_PIN* pin = pins.front();
1363 const wxString name( "Native alternate" );
1364 BOOST_REQUIRE( !pin->GetAlternates().contains( name ) );
1365 pin->GetAlternates().emplace( name, SCH_PIN::ALT{ name, GRAPHIC_PINSHAPE::LINE,
1367 BOOST_CHECK_EQUAL( original->Compare( changed, flags & ~SCH_ITEM::COMPARE_FLAGS::PIN_ALT_DEFS ), 0 );
1368 BOOST_CHECK_EQUAL( changed.Compare( *original, flags & ~SCH_ITEM::COMPARE_FLAGS::PIN_ALT_DEFS ), 0 );
1369 BOOST_CHECK_NE( original->Compare( changed, flags ), 0 );
1370 BOOST_CHECK_NE( changed.Compare( *original, flags ), 0 );
1371}
1372
1373
1379BOOST_AUTO_TEST_CASE( InheritedFootprintFiltersAreNotWritten )
1380{
1381 LIB_SYMBOL parent( wxS( "MAX291" ) );
1382 LIB_SYMBOL derived( wxS( "MAX293" ) );
1383
1384 parent.SetFPFilters( filterList( { wxS( "DIP*" ), wxS( "SOIC*" ) } ) );
1385 derived.SetParent( &parent );
1386
1387 BOOST_REQUIRE( derived.IsDerived() );
1388 BOOST_CHECK( derived.GetRawFPFilters().IsEmpty() );
1389
1390 // The resolving accessor must keep reporting what the symbol uses
1391 BOOST_CHECK( derived.GetFPFilters() == parent.GetFPFilters() );
1392
1393 BOOST_CHECK( formatted( parent ).Contains( wxS( "ki_fp_filters" ) ) );
1394 BOOST_CHECK( !formatted( derived ).Contains( wxS( "ki_fp_filters" ) ) );
1395
1396 // A schematic caches a flattened copy, which is a root and so must carry the filters
1397 std::unique_ptr<LIB_SYMBOL> flattened = derived.Flatten();
1398 BOOST_REQUIRE( flattened );
1399 BOOST_CHECK( flattened->IsRoot() );
1400 BOOST_CHECK( flattened->GetRawFPFilters() == parent.GetFPFilters() );
1401 BOOST_CHECK( formatted( *flattened ).Contains( wxS( "ki_fp_filters" ) ) );
1402}
1403
1404
1408BOOST_AUTO_TEST_CASE( OwnFootprintFiltersAreWritten )
1409{
1410 LIB_SYMBOL parent( wxS( "MAX291" ) );
1411 LIB_SYMBOL derived( wxS( "MAX293" ) );
1412
1413 parent.SetFPFilters( filterList( { wxS( "DIP*" ) } ) );
1414 derived.SetParent( &parent );
1415 derived.SetFPFilters( filterList( { wxS( "QFN*" ) } ) );
1416
1417 BOOST_CHECK( derived.GetFPFilters() == filterList( { wxS( "QFN*" ) } ) );
1418
1419 wxString text = formatted( derived );
1420 BOOST_CHECK( text.Contains( wxS( "ki_fp_filters" ) ) );
1421 BOOST_CHECK( text.Contains( wxS( "QFN*" ) ) );
1422 BOOST_CHECK( !text.Contains( wxS( "DIP*" ) ) );
1423}
1424
1425
1432BOOST_AUTO_TEST_CASE( ClearingOwnFootprintFiltersReturnsToInheriting )
1433{
1434 LIB_SYMBOL parent( wxS( "MAX291" ) );
1435 LIB_SYMBOL derived( wxS( "MAX293" ) );
1436
1437 parent.SetFPFilters( filterList( { wxS( "DIP*" ), wxS( "SOIC*" ) } ) );
1438 derived.SetParent( &parent );
1439
1440 // Dropping one of two inherited filters is a real override and must be kept
1441 derived.SetFPFilters( filterList( { wxS( "SOIC*" ) } ) );
1442 BOOST_CHECK( derived.GetFPFilters() == filterList( { wxS( "SOIC*" ) } ) );
1443
1444 wxString kept = formatted( derived );
1445 BOOST_CHECK( kept.Contains( wxS( "SOIC*" ) ) );
1446 BOOST_CHECK( !kept.Contains( wxS( "DIP*" ) ) );
1447
1448 // Dropping the last one leaves nothing of its own, so the parent's list applies again
1449 derived.SetFPFilters( wxArrayString() );
1450 BOOST_CHECK( derived.GetRawFPFilters().IsEmpty() );
1451 BOOST_CHECK( derived.GetFPFilters() == parent.GetFPFilters() );
1452
1453 // What must not happen is the parent's list being stamped onto the child as an override
1454 BOOST_CHECK( !formatted( derived ).Contains( wxS( "ki_fp_filters" ) ) );
1455}
1456
1457
1462BOOST_AUTO_TEST_CASE( FootprintFiltersSurviveSaveAndReload )
1463{
1464 SCOPED_TEMP_LIB tempLib;
1465
1466 {
1467 LIB_SYMBOL parent( wxS( "MAX291" ) );
1468 parent.GetValueField().SetText( wxS( "MAX291" ) );
1469 parent.SetFPFilters( filterList( { wxS( "DIP*" ), wxS( "SOIC*" ) } ) );
1470
1471 LIB_SYMBOL derived( wxS( "MAX293" ) );
1472 derived.GetValueField().SetText( wxS( "MAX293" ) );
1473 derived.SetParent( &parent );
1474
1475 // saveToLib() writes a single symbol, and the parent has to land first
1476 IO_RELEASER<SCH_IO> pi( SCH_IO_MGR::FindPlugin( SCH_IO_MGR::SCH_KICAD ) );
1477 pi->CreateLibrary( tempLib.GetPath() );
1478 pi->SaveSymbol( tempLib.GetPath(), std::make_unique<LIB_SYMBOL>( parent ) );
1479 pi->SaveSymbol( tempLib.GetPath(), std::make_unique<LIB_SYMBOL>( derived ) );
1480 pi->SaveLibrary( tempLib.GetPath() );
1481 }
1482
1483 IO_RELEASER<SCH_IO> pi( SCH_IO_MGR::FindPlugin( SCH_IO_MGR::SCH_KICAD ) );
1484 LIB_SYMBOL* parent = pi->LoadSymbol( tempLib.GetPath(), wxS( "MAX291" ) );
1485 LIB_SYMBOL* derived = pi->LoadSymbol( tempLib.GetPath(), wxS( "MAX293" ) );
1486
1487 BOOST_REQUIRE( parent && derived );
1488 BOOST_REQUIRE( derived->IsDerived() );
1489
1490 BOOST_CHECK( derived->GetRawFPFilters().IsEmpty() );
1491 BOOST_CHECK( derived->GetFPFilters() == filterList( { wxS( "DIP*" ), wxS( "SOIC*" ) } ) );
1492
1493 // Retracking the parent is the point: a new parent filter reaches the child
1494 parent->SetFPFilters( filterList( { wxS( "QFN*" ) } ) );
1495 BOOST_CHECK( derived->GetFPFilters() == filterList( { wxS( "QFN*" ) } ) );
1496}
1497
1498
const char * name
constexpr EDA_IU_SCALE schIUScale
Definition base_units.h:130
virtual void SetParent(EDA_ITEM *aParent)
Definition eda_item.cpp:153
virtual void SetEnd(const VECTOR2I &aEnd)
Definition eda_shape.h:338
virtual void SetBezierC2(const VECTOR2I &aPt)
Definition eda_shape.h:376
virtual void SetBezierC1(const VECTOR2I &aPt)
Definition eda_shape.h:373
void RebuildBezierToSegmentsPointsList(int aMaxError)
Rebuild the m_bezierPoints vertex list that approximate the Bezier curve by a list of segments.
virtual void SetShape(SHAPE_T aShape)
Definition eda_shape.h:177
const std::vector< VECTOR2I > & GetBezierPoints() const
Definition eda_shape.h:506
virtual void SetStart(const VECTOR2I &aStart)
Definition eda_shape.h:288
virtual bool IsVisible() const
Definition eda_text.h:226
KIFONT::FONT * GetFont() const
Definition eda_text.h:286
virtual void SetVisible(bool aVisible)
Definition eda_text.cpp:348
void SetFont(KIFONT::FONT *aFont)
Definition eda_text.cpp:472
static FONT * GetFont(const wxString &aFontName=wxEmptyString, bool aBold=false, bool aItalic=false, const std::vector< wxString > *aEmbeddedFiles=nullptr, bool aForDrawingSheet=false)
Definition font.cpp:144
A logical library item identifier and consists of various portions much like a URI.
Definition lib_id.h:45
int SetLibItemName(const UTF8 &aLibItemName)
Override the library item name portion of the LIB_ID to aLibItemName.
Definition lib_id.cpp:124
int SetLibNickname(const UTF8 &aLibNickname)
Override the logical library name portion of the LIB_ID to aLibNickname.
Definition lib_id.cpp:113
Define a library symbol object.
Definition lib_symbol.h:114
const LIB_ID & GetLibId() const override
Definition lib_symbol.h:190
wxString GetKeyWords() const override
Definition lib_symbol.h:220
void SetGlobalPower()
std::vector< struct LIB_SYMBOL_UNIT > GetUnitDrawItems()
Return a list of SCH_ITEM objects separated by unit and convert number.
bool IsDerived() const
Definition lib_symbol.h:241
SCH_FIELD * GetField(const wxString &aFieldName)
Find a field within this symbol matching aFieldName; return nullptr if not found.
static wxString LetterSubReference(int aUnit, wxChar aInitialLetter)
void LockUnits(bool aLockUnits)
Set interchangeable the property for symbol units.
Definition lib_symbol.h:376
LIB_ITEMS_CONTAINER & GetDrawItems()
Return a reference to the draw item list.
Definition lib_symbol.h:845
void SetParent(LIB_SYMBOL *aParent=nullptr)
void SetUnitCount(int aCount, bool aDuplicateDrawItems)
Set the units per symbol count.
void SetDescription(const wxString &aDescription)
Set the Description field text value.
void SetKeyWords(const wxString &aKeyWords)
SCH_FIELD & GetValueField()
Definition lib_symbol.h:449
wxArrayString GetFPFilters() const
Definition lib_symbol.h:254
void RemoveDrawItem(SCH_ITEM *aItem)
Remove draw aItem from list.
void SetFPFilters(const wxArrayString &aFilters)
Definition lib_symbol.h:250
int GetBodyStyleCount() const override
The body styles are a property of the drawings, which a derived symbol inherits from its root symbol ...
LIB_SYMBOL_ATTRIBUTES ComparisonAttributes() const
int GetUnitCount() const override
const wxArrayString & GetRawFPFilters() const
Definition lib_symbol.h:252
std::unique_ptr< LIB_SYMBOL > Flatten() const
Return a flattened symbol inheritance to the caller.
void SetLibId(const LIB_ID &aLibId)
void AddField(SCH_FIELD *aField)
Add a field.
std::vector< SCH_PIN * > GetGraphicalPins(int aUnit=0, int aBodyStyle=0) const override
Graphical pins: Return schematic pin objects as drawn (unexpanded), filtered by unit/body.
int Compare(const LIB_SYMBOL &aRhs, int aCompareFlags=~COMPARE_FLAGS::UNIT, REPORTER *aReporter=nullptr) const
Comparison test that can be used for operators.
void AddDrawItem(SCH_ITEM *aItem, bool aSort=true)
Add a new draw aItem to the draw object list and sort according to aSort.
virtual void SetName(const wxString &aName)
void SetNormal()
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition locale_io.h:37
bool empty(int aType=UNDEFINED_TYPE) const
A named pin map.
Definition pin_map.h:65
const wxString & GetName() const
Definition pin_map.h:70
void SetEntry(const wxString &aPinNumber, const wxString &aPadNumber)
Set the pad number for a symbol pin.
Definition pin_map.cpp:59
VECTOR2I GetPosition() const override
virtual const wxString & GetText() const override
Return the string associated with the text object.
Definition sch_field.h:139
void SetPosition(const VECTOR2I &aPosition) override
void SetText(const wxString &aText) override
static void FormatLibSymbol(LIB_SYMBOL *aPart, OUTPUTFORMATTER &aFormatter)
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition sch_item.h:170
virtual void SetBodyStyle(int aBodyStyle)
Definition sch_item.h:252
COMPARE_FLAGS
The list of flags used by various compare functions.
Definition sch_item.h:749
@ MISSING_FIELDS
Definition sch_item.h:753
@ EXTRA_FIELDS
Definition sch_item.h:754
@ PIN_ALT_DEFS
Definition sch_item.h:760
@ PIN_VISIBILITIES
Definition sch_item.h:759
virtual void SetUnit(int aUnit)
Definition sch_item.h:242
int GetLength() const
Definition sch_pin.cpp:424
void SetNumber(const wxString &aNumber)
Definition sch_pin.cpp:845
void SetLength(int aLength)
Definition sch_pin.h:119
PIN_ALTERNATE ALT
Definition sch_pin.h:63
void Move(const VECTOR2I &aOffset) override
Move the item by aMoveVector to a new position.
A temporary symbol library that is removed when it goes out of scope.
const wxString & GetPath() const
Implement an OUTPUTFORMATTER to a memory buffer.
Definition richio.h:430
const std::string & GetString()
Definition richio.h:453
void SetExcludedFromBoard(bool aExclude, const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) override
Set or clear exclude from board netlist flag.
Definition symbol.h:210
virtual void SetShowPinNumbers(bool aShow)
Set or clear the pin number visibility flag.
Definition symbol.h:174
int GetPinNameOffset() const
Definition symbol.h:163
virtual void SetShowPinNames(bool aShow)
Set or clear the pin name visibility flag.
Definition symbol.h:168
void SetPinNameOffset(int aOffset)
Set the offset in mils of the pin name text from the pin symbol.
Definition symbol.h:162
void SetExcludedFromPosFiles(bool aExclude, const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) override
Set or clear exclude from position files flag.
Definition symbol.h:225
virtual void SetExcludedFromBOM(bool aExcludeFromBOM, const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) override
Set or clear the exclude from schematic bill of materials flag.
Definition symbol.h:195
LIB_SYMBOL m_part_no_data
Part with no extra data set.
static bool empty(const wxTextEntryBase *aCtrl)
@ RECTANGLE
Use RECTANGLE instead of RECT to avoid collision in a Windows header.
Definition eda_shape.h:58
std::unique_ptr< T > IO_RELEASER
Helper to hold and release an IO_BASE object when exceptions are thrown.
Definition io_mgr.h:33
@ LAYER_DEVICE
Definition layer_ids.h:497
Test utils (e.g.
std::string GetEeschemaTestDataDir()
Get the configured location of Eeschema test data.
bool AreDefaultFieldsCorrect(const std::vector< SCH_FIELD > &aFields)
Predicate to check that the mandatory fields look sensible.
bool FieldNameIdMatches(const SCH_FIELD &aField, const std::string &aExpectedName, int aExpectedId)
Predicate to check a field name is as expected.
LIBRARY_SYMBOL_FACT ExtractLibrarySymbolFact(const LIB_SYMBOL &aSymbol)
@ PT_INPUT
usual pin input: must be connected
Definition pin_type.h:33
@ PT_OUTPUT
usual output
Definition pin_type.h:34
@ PT_POWER_IN
power input (GND, VCC for ICs). Must be connected to a power output.
Definition pin_type.h:42
static const std::vector< std::string > filters
Definition plugin.cpp:64
@ BASE
Definition sch_item.h:64
#define ALL_UNITS
Definition symbol.h:150
#define ALL_BODY_STYLES
Definition symbol.h:151
@ USER
The field ID hasn't been set yet; field is invalid.
@ DESCRIPTION
Field Description of part, i.e. "1/4W 1% Metal Film Resistor".
@ FOOTPRINT
Field Name Module PCB, i.e. "16DIP300".
@ DATASHEET
name of datasheet
@ REFERENCE
Field Reference of part, i.e. "IC21".
@ VALUE
Field Value of part, i.e. "3.3K".
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_CHECK(res.column_datatype(0)==SQL_NUMERIC||res.column_datatype(0)==SQL_DECIMAL)
BOOST_REQUIRE_EQUAL(rows.size(), 1)
BOOST_CHECK_EQUAL(std::any_cast< std::string >(rows[0].at("val")), "12345678901234567.89")
BOOST_REQUIRE(res.columns()==1)
BOOST_AUTO_TEST_SUITE_END()
KIBIS_PIN * pin1
KIBIS_PIN * pin
void CheckDuplicatePins(LIB_SYMBOL *aSymbol, std::vector< wxString > &aMessages, UNITS_PROVIDER *aUnitsProvider)
static wxArrayString filterList(const std::vector< wxString > &aFilters)
Build a footprint filter list.
static void saveToLib(const wxString &aLibPath, const LIB_SYMBOL &aSymbol)
Write a symbol to its own library file.
static int alternateBodyStyleItemCount(LIB_SYMBOL &aSymbol)
Return the number of draw items belonging to a body style beyond the standard one.
static std::unique_ptr< LIB_SYMBOL > loadDeMorganSymbol()
Load 4001, a four unit NOR gate carrying a De Morgan alternate body style.
static wxString formatted(LIB_SYMBOL &aSymbol)
Serialize one symbol the way the library writer would.
BOOST_AUTO_TEST_CASE(DefaultProperties)
Declare the test suite.
VECTOR3I expected(15, 30, 45)
BOOST_CHECK_PREDICATE(ArePolylineEndPointsNearCircle,(chain)(c.m_geom.m_center_point)(radius)(accuracy+epsilon))
BOOST_TEST_CONTEXT("Test Clearance")
@ SCH_SHAPE_T
Definition typeinfo.h:145
@ SCH_PIN_T
Definition typeinfo.h:149
#define CHECK_WX_ASSERT(STATEMENT)
A test macro to check a wxASSERT is thrown.
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:708