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 <locale_io.h>
32#include <sch_file_versions.h>
33#include <sch_io/sch_io.h>
34#include <sch_io/sch_io_mgr.h>
35#include <locale_io.h>
36
37#include <wx/file.h>
38#include <wx/filename.h>
39
41
43{
44public:
46 m_part_no_data( "part_name", nullptr )
47 {
48 }
49
52};
53
54
59{
60public:
62 {
63 m_dir = wxFileName::CreateTempFileName( wxS( "kicad_lib_part_" ) );
64 wxRemoveFile( m_dir );
65 wxFileName::Mkdir( m_dir );
66
67 m_path = wxFileName( m_dir, wxS( "test_lib.kicad_sym" ) ).GetFullPath();
68 }
69
71 {
72 if( wxFileName::DirExists( m_dir ) )
73 wxFileName::Rmdir( m_dir, wxPATH_RMDIR_RECURSIVE );
74 }
75
76 const wxString& GetPath() const { return m_path; }
77
78private:
79 wxString m_dir;
80 wxString m_path;
81};
82
83
88{
89 int count = 0;
90
91 for( SCH_ITEM& item : aSymbol.GetDrawItems() )
92 {
93 if( item.GetBodyStyle() > BODY_STYLE::BASE )
94 count++;
95 }
96
97 return count;
98}
99
100
104static std::unique_ptr<LIB_SYMBOL> loadDeMorganSymbol()
105{
106 wxFileName libPath( KI_TEST::GetEeschemaTestDataDir() );
107 libPath.AppendDir( "libs" );
108 libPath.SetFullName( "4xxx.kicad_sym" );
109
110 IO_RELEASER<SCH_IO> pi( SCH_IO_MGR::FindPlugin( SCH_IO_MGR::SCH_KICAD ) );
111
112 // The plugin cache owns the returned symbol, so hand back a copy
113 LIB_SYMBOL* cached = pi->LoadSymbol( libPath.GetFullPath(), wxS( "4001" ) );
114
115 return cached ? std::make_unique<LIB_SYMBOL>( *cached ) : nullptr;
116}
117
118
122static void saveToLib( const wxString& aLibPath, const LIB_SYMBOL& aSymbol )
123{
124 IO_RELEASER<SCH_IO> pi( SCH_IO_MGR::FindPlugin( SCH_IO_MGR::SCH_KICAD ) );
125
126 pi->CreateLibrary( aLibPath );
127 pi->SaveSymbol( aLibPath, std::make_unique<LIB_SYMBOL>( aSymbol ) );
128 pi->SaveLibrary( aLibPath );
129}
130
131
135BOOST_FIXTURE_TEST_SUITE( LibPart, TEST_LIB_SYMBOL_FIXTURE )
136
137
138
141BOOST_AUTO_TEST_CASE( DefaultProperties )
142{
143 BOOST_CHECK_EQUAL( m_part_no_data.GetName(), "part_name" );
144
145 // Didn't set a library, so this is empty
146 BOOST_CHECK_EQUAL( m_part_no_data.GetLibraryName(), "" );
147 BOOST_CHECK_EQUAL( m_part_no_data.GetLib(), nullptr );
148
149 // only get the root
150 BOOST_CHECK_EQUAL( m_part_no_data.IsRoot(), true );
151 BOOST_CHECK_EQUAL( m_part_no_data.IsDerived(), false );
152 BOOST_CHECK_EQUAL( m_part_no_data.SharedPtr().use_count(), 2 );
153
154 // no sub units
155 BOOST_CHECK_EQUAL( m_part_no_data.GetUnitCount(), 1 );
156 BOOST_CHECK_EQUAL( m_part_no_data.IsMultiUnit(), false );
157
158 // single body style
159 BOOST_CHECK_EQUAL( m_part_no_data.HasDeMorganBodyStyles(), false );
160}
161
162
166BOOST_AUTO_TEST_CASE( DefaultDrawings )
167{
168 // default drawings exist
169 BOOST_CHECK_EQUAL( m_part_no_data.GetDrawItems().size(), 5 );
170 BOOST_CHECK_EQUAL( m_part_no_data.GetGraphicalPins( 0, 0 ).size(), 0 );
171}
172
173
177BOOST_AUTO_TEST_CASE( DefaultFields )
178{
179 std::vector<SCH_FIELD> fields;
180 m_part_no_data.CopyFields( fields );
181
182 // Should get the 4 default fields
184
185 // but no more (we didn't set them)
186 BOOST_CHECK_EQUAL( fields.size(), 5 );
187
188 // also check the default field accessors
190 ( m_part_no_data.GetReferenceField() )( "Reference" )( (int) FIELD_T::REFERENCE ) );
192 ( m_part_no_data.GetValueField() )( "Value" )( (int) FIELD_T::VALUE ) );
194 ( m_part_no_data.GetFootprintField() )( "Footprint" )( (int) FIELD_T::FOOTPRINT ) );
196 ( m_part_no_data.GetDatasheetField() )( "Datasheet" )( (int) FIELD_T::DATASHEET ) );
198 ( m_part_no_data.GetDescriptionField() )( "Description" )( (int) FIELD_T::DESCRIPTION ) );
199}
200
201
206{
207 std::vector<SCH_FIELD> fields;
208 m_part_no_data.CopyFields( fields );
209
210 // Ctor takes non-const ref (?!)
211 const std::string newFieldName = "new_field";
212 wxString nonConstNewFieldName = newFieldName;
213 fields.push_back( SCH_FIELD( nullptr, FIELD_T::USER, nonConstNewFieldName ) );
214
215 // fairly roundabout way to add a field, but it is what it is
216 m_part_no_data.SetFields( fields );
217
218 // Should get the 4 default fields
220
221 // and our new one
222 BOOST_REQUIRE_EQUAL( fields.size(), 6 );
223
224 // Check by-name lookup
225
226 SCH_FIELD* gotNewField = m_part_no_data.GetField( newFieldName );
227
228 BOOST_REQUIRE_NE( gotNewField, nullptr );
229 BOOST_CHECK_PREDICATE( KI_TEST::FieldNameIdMatches, ( *gotNewField )( newFieldName )( 0 ) );
230}
231
232
236BOOST_AUTO_TEST_CASE( AddedDrawItems )
237{
238 const size_t defaultCount = m_part_no_data.GetDrawItems().size();
239
240 SCH_PIN* pin = new SCH_PIN( &m_part_no_data );
241 pin->SetNumber( "1" );
242 m_part_no_data.AddDrawItem( pin );
243
244 BOOST_CHECK_EQUAL( m_part_no_data.GetDrawItems().size(), defaultCount + 1 );
245 BOOST_CHECK( pin->GetParentSymbol() == &m_part_no_data );
246 BOOST_CHECK_EQUAL( m_part_no_data.GetPinCount(), 1 );
247
248 m_part_no_data.RemoveDrawItem( pin );
249
250 BOOST_CHECK_EQUAL( m_part_no_data.GetDrawItems().size(), defaultCount );
251 BOOST_CHECK_EQUAL( m_part_no_data.GetPinCount(), 0 );
252
253 // Mandatory fields are never removable, so the accessors can't be left dangling
254 m_part_no_data.RemoveDrawItem( &m_part_no_data.GetReferenceField() );
255
256 BOOST_CHECK_EQUAL( m_part_no_data.GetDrawItems().size(), defaultCount );
257}
258
259
264BOOST_AUTO_TEST_CASE( StackedPinNumberLookup )
265{
266 SCH_PIN* pin = new SCH_PIN( &m_part_no_data );
267 pin->SetNumber( "[A1,A12,B1,B12]" );
268 m_part_no_data.AddDrawItem( pin );
269
270 BOOST_CHECK( m_part_no_data.HasPinNumber( "[A1,A12,B1,B12]" ) );
271
272 BOOST_CHECK( m_part_no_data.HasPinNumber( "A1" ) );
273 BOOST_CHECK( m_part_no_data.HasPinNumber( "A12" ) );
274 BOOST_CHECK( m_part_no_data.HasPinNumber( "B1" ) );
275 BOOST_CHECK( m_part_no_data.HasPinNumber( "B12" ) );
276
277 BOOST_CHECK( !m_part_no_data.HasPinNumber( "A2" ) );
278 BOOST_CHECK( !m_part_no_data.HasPinNumber( "[A1" ) );
279}
280
281
286BOOST_AUTO_TEST_CASE( RangeStackedPinNumberLookup )
287{
288 SCH_PIN* pin = new SCH_PIN( &m_part_no_data );
289 pin->SetNumber( "[1-4]" );
290 m_part_no_data.AddDrawItem( pin );
291
292 BOOST_CHECK( m_part_no_data.HasPinNumber( "[1-4]" ) );
293
294 BOOST_CHECK( m_part_no_data.HasPinNumber( "1" ) );
295 BOOST_CHECK( m_part_no_data.HasPinNumber( "3" ) );
296
297 BOOST_CHECK( !m_part_no_data.HasPinNumber( "5" ) );
298}
299
300
302{
305 std::string m_expSubRef;
306};
307
308
312BOOST_AUTO_TEST_CASE( SubReference )
313{
314 const std::vector<TEST_LIB_SYMBOL_SUBREF_CASE> cases = {
315 {
316 1,
317 false,
318 "A",
319 },
320 {
321 2,
322 false,
323 "B",
324 },
325 {
326 26,
327 false,
328 "Z",
329 },
330 {
331 27,
332 false,
333 "AA",
334 },
335 {
336 28,
337 false,
338 "AB",
339 },
340 {
341 53,
342 false,
343 "BA",
344 },
345 {
346 79,
347 false,
348 "CA",
349 },
350 {
351 105,
352 false,
353 "DA",
354 },
355 {
356 131,
357 false,
358 "EA",
359 },
360 {
361 157,
362 false,
363 "FA",
364 },
365 {
366 183,
367 false,
368 "GA",
369 },
370 {
371 209,
372 false,
373 "HA",
374 },
375 {
376 235,
377 false,
378 "IA",
379 },
380 {
381 261,
382 false,
383 "JA",
384 },
385 {
386 287,
387 false,
388 "KA",
389 },
390 {
391 313,
392 false,
393 "LA",
394 },
395 {
396 339,
397 false,
398 "MA",
399 },
400 {
401 365,
402 false,
403 "NA",
404 },
405 {
406 391,
407 false,
408 "OA",
409 },
410 {
411 417,
412 false,
413 "PA",
414 },
415 {
416 443,
417 false,
418 "QA",
419 },
420 {
421 469,
422 false,
423 "RA",
424 },
425 {
426 495,
427 false,
428 "SA",
429 },
430 {
431 521,
432 false,
433 "TA",
434 },
435 {
436 547,
437 false,
438 "UA",
439 },
440 {
441 573,
442 false,
443 "VA",
444 },
445 {
446 599,
447 false,
448 "WA",
449 },
450 {
451 625,
452 false,
453 "XA",
454 },
455 {
456 651,
457 false,
458 "YA",
459 },
460 {
461 677,
462 false,
463 "ZA",
464 },
465 {
466 702,
467 false,
468 "ZZ",
469 },
470 {
471 703,
472 false,
473 "AAA",
474 },
475 {
476 728,
477 false,
478 "AAZ",
479 },
480 };
481
482 for( const auto& c : cases )
483 {
485 "Subref: " << c.m_index << ", " << c.m_addSep << " -> '" << c.m_expSubRef << "'" )
486 {
487 const auto subref = LIB_SYMBOL::LetterSubReference( c.m_index, 'A' );
488 BOOST_CHECK_EQUAL( subref, c.m_expSubRef );
489 }
490 }
491}
492
493
494BOOST_AUTO_TEST_CASE( NativeBezierComparisonHandlesUnequalCaches )
495{
496 LOCALE_IO locale;
497 auto symbol = loadDeMorganSymbol();
498 BOOST_REQUIRE( symbol );
499 SCH_SHAPE* shape = nullptr;
500
501 for( SCH_ITEM& item : symbol->GetDrawItems()[SCH_SHAPE_T] )
502 {
503 shape = static_cast<SCH_SHAPE*>( &item );
504 break;
505 }
506
507 BOOST_REQUIRE( shape );
508 shape->SetShape( SHAPE_T::BEZIER );
509 shape->SetStart( VECTOR2I( 0, 0 ) );
510 shape->SetEnd( VECTOR2I( 100000, 0 ) );
511 shape->SetBezierC1( VECTOR2I( 0, 100000 ) );
512 shape->SetBezierC2( VECTOR2I( 100000, 100000 ) );
513 BOOST_REQUIRE( shape->GetBezierPoints().empty() );
514 SCH_SHAPE rebuilt( *shape );
516 BOOST_REQUIRE( !rebuilt.GetBezierPoints().empty() );
517 const auto& empty = static_cast<const EDA_SHAPE&>( *shape );
518 const auto& populated = static_cast<const EDA_SHAPE&>( rebuilt );
519 BOOST_REQUIRE_NE( empty.Compare( &populated ), 0 );
520 BOOST_CHECK_LT( empty.Compare( &populated ), 0 );
521 BOOST_CHECK_GT( populated.Compare( &empty ), 0 );
522}
523
524
529{
530 // Identical root part to m_part_no_data sans time stamp.
531 LIB_SYMBOL testPart( "part_name" );
532
533 // Self comparison test.
534 BOOST_CHECK_EQUAL( m_part_no_data.Compare( m_part_no_data ), 0 );
535
536 // Test for identical LIB_SYMBOL.
537 BOOST_CHECK_EQUAL( m_part_no_data.Compare( testPart, ~SCH_ITEM::COMPARE_FLAGS::UUID ), 0 );
538
539 // Test name.
540 testPart.SetName( "tart_name" );
541 BOOST_CHECK( m_part_no_data.Compare( testPart ) < 0 );
542 testPart.SetName( "cart_name" );
543 BOOST_CHECK( m_part_no_data.Compare( testPart ) > 0 );
544 testPart.SetName( "part_name" );
545
546 // LIB_ID comparison tests.
547 LIB_ID id = testPart.GetLibId();
548 id.SetLibItemName( "tart_name" );
549 testPart.SetLibId( id );
550 BOOST_CHECK( m_part_no_data.Compare( testPart ) < 0 );
551 id.SetLibItemName( "cart_name" );
552 testPart.SetLibId( id );
553 BOOST_CHECK( m_part_no_data.Compare( testPart ) > 0 );
554 id.SetLibItemName( "part_name" );
555 testPart.SetLibId( id );
556
557 // Unit count comparison tests.
558 testPart.SetUnitCount( 2, true );
559 BOOST_CHECK( m_part_no_data.Compare( testPart ) < 0 );
560 testPart.SetUnitCount( 1, true );
561 m_part_no_data.SetUnitCount( 2, true );
562 BOOST_CHECK( m_part_no_data.Compare( testPart ) > 0 );
563 m_part_no_data.SetUnitCount( 1, true );
564
565 // Options flag comparison tests.
566 testPart.SetGlobalPower();
567 BOOST_CHECK( m_part_no_data.Compare( testPart ) < 0 );
568 testPart.SetNormal();
569 m_part_no_data.SetGlobalPower();
570 BOOST_CHECK( m_part_no_data.Compare( testPart ) > 0 );
571 m_part_no_data.SetNormal();
572
573 // Draw item list size comparison tests.
575 m_part_no_data.AddDrawItem( new SCH_SHAPE( SHAPE_T::RECTANGLE, LAYER_DEVICE ) );
576 BOOST_CHECK_EQUAL( m_part_no_data.Compare( testPart, ~SCH_ITEM::COMPARE_FLAGS::UUID ), 0 );
577 m_part_no_data.RemoveDrawItem( &m_part_no_data.GetDrawItems()[SCH_SHAPE_T].front() );
578 BOOST_CHECK( m_part_no_data.Compare( testPart, ~SCH_ITEM::COMPARE_FLAGS::UUID ) < 0 );
579 testPart.RemoveDrawItem( &testPart.GetDrawItems()[SCH_SHAPE_T].front() );
580 m_part_no_data.AddDrawItem( new SCH_SHAPE( SHAPE_T::RECTANGLE, LAYER_DEVICE ) );
581 BOOST_CHECK( m_part_no_data.Compare( testPart, ~SCH_ITEM::COMPARE_FLAGS::UUID ) > 0 );
582 m_part_no_data.RemoveDrawItem( &m_part_no_data.GetDrawItems()[SCH_SHAPE_T].front() );
583
584 // Draw item list contents comparison tests.
586 m_part_no_data.AddDrawItem( new SCH_SHAPE( SHAPE_T::ARC, LAYER_DEVICE ) );
587 BOOST_CHECK( m_part_no_data.Compare( testPart, ~SCH_ITEM::COMPARE_FLAGS::UUID ) > 0 );
588 m_part_no_data.RemoveDrawItem( &m_part_no_data.GetDrawItems()[SCH_SHAPE_T].front() );
589 testPart.RemoveDrawItem( &testPart.GetDrawItems()[SCH_SHAPE_T].front() );
590 m_part_no_data.AddDrawItem( new SCH_PIN( &m_part_no_data ) );
591 BOOST_CHECK( m_part_no_data.Compare( testPart, ~SCH_ITEM::COMPARE_FLAGS::UUID ) > 0 );
592 m_part_no_data.RemoveDrawItem( &m_part_no_data.GetDrawItems()[SCH_PIN_T].front() );
593
594 // Footprint filter array comparison tests.
595 wxArrayString footPrintFilters;
596 BOOST_CHECK( m_part_no_data.GetFPFilters() == footPrintFilters );
597 footPrintFilters.Add( "b" );
598 testPart.SetFPFilters( footPrintFilters );
599 BOOST_CHECK( m_part_no_data.Compare( testPart, ~SCH_ITEM::COMPARE_FLAGS::UUID ) < 0 );
600 m_part_no_data.SetFPFilters( footPrintFilters );
601 footPrintFilters.Clear();
602 testPart.SetFPFilters( footPrintFilters );
603 BOOST_CHECK( m_part_no_data.Compare( testPart, ~SCH_ITEM::COMPARE_FLAGS::UUID ) > 0 );
604 footPrintFilters.Clear();
605 m_part_no_data.SetFPFilters( footPrintFilters );
606 testPart.SetFPFilters( footPrintFilters );
607
608 // Description string tests.
609 m_part_no_data.SetDescription( "b" );
610 testPart.SetDescription( "b" );
611 BOOST_CHECK_EQUAL( m_part_no_data.Compare( testPart, ~SCH_ITEM::COMPARE_FLAGS::UUID ), 0 );
612 m_part_no_data.SetDescription( "a" );
613 BOOST_CHECK( m_part_no_data.Compare( testPart, ~SCH_ITEM::COMPARE_FLAGS::UUID ) < 0 );
614 m_part_no_data.SetDescription( "c" );
615 BOOST_CHECK( m_part_no_data.Compare( testPart, ~SCH_ITEM::COMPARE_FLAGS::UUID ) > 0 );
616 m_part_no_data.SetDescription( wxEmptyString );
617 testPart.SetDescription( wxEmptyString );
618
619 // Key word string tests.
620 m_part_no_data.SetKeyWords( "b" );
621 testPart.SetKeyWords( "b" );
622 BOOST_CHECK_EQUAL( m_part_no_data.Compare( testPart, ~SCH_ITEM::COMPARE_FLAGS::UUID ), 0 );
623 m_part_no_data.SetKeyWords( "a" );
624 BOOST_CHECK( m_part_no_data.Compare( testPart, ~SCH_ITEM::COMPARE_FLAGS::UUID ) < 0 );
625 m_part_no_data.SetKeyWords( "c" );
626 BOOST_CHECK( m_part_no_data.Compare( testPart, ~SCH_ITEM::COMPARE_FLAGS::UUID ) > 0 );
627 m_part_no_data.SetKeyWords( wxEmptyString );
628 testPart.SetKeyWords( wxEmptyString );
629
630 // Pin name offset comparison tests.
631 testPart.SetPinNameOffset( testPart.GetPinNameOffset() + 1 );
632 BOOST_CHECK( m_part_no_data.Compare( testPart, ~SCH_ITEM::COMPARE_FLAGS::UUID ) < 0 );
633 testPart.SetPinNameOffset( testPart.GetPinNameOffset() - 2 );
634 BOOST_CHECK( m_part_no_data.Compare( testPart, ~SCH_ITEM::COMPARE_FLAGS::UUID ) > 0 );
635 testPart.SetPinNameOffset( testPart.GetPinNameOffset() + 1 );
636
637 // Units locked flag comparison tests.
638 testPart.LockUnits( true );
639 BOOST_CHECK( m_part_no_data.Compare( testPart, ~SCH_ITEM::COMPARE_FLAGS::UUID ) < 0 );
640 testPart.LockUnits( false );
641 m_part_no_data.LockUnits( true );
642 BOOST_CHECK( m_part_no_data.Compare( testPart, ~SCH_ITEM::COMPARE_FLAGS::UUID ) > 0 );
643 m_part_no_data.LockUnits( false );
644
645 // Include in BOM support tests.
646 testPart.SetExcludedFromBOM( true );
647 BOOST_CHECK( m_part_no_data.Compare( testPart, ~SCH_ITEM::COMPARE_FLAGS::UUID ) > 0 );
648 testPart.SetExcludedFromBOM( false );
649 m_part_no_data.SetExcludedFromBOM( true );
650 BOOST_CHECK( m_part_no_data.Compare( testPart, ~SCH_ITEM::COMPARE_FLAGS::UUID ) < 0 );
651 m_part_no_data.SetExcludedFromBOM( false );
652
653 // Include on board support tests.
654 testPart.SetExcludedFromBoard( true );
655 BOOST_CHECK( m_part_no_data.Compare( testPart, ~SCH_ITEM::COMPARE_FLAGS::UUID ) > 0 );
656 testPart.SetExcludedFromBoard( false );
657 m_part_no_data.SetExcludedFromBoard( true );
658 BOOST_CHECK( m_part_no_data.Compare( testPart, ~SCH_ITEM::COMPARE_FLAGS::UUID ) < 0 );
659 m_part_no_data.SetExcludedFromBoard( false );
660
661 // Include in position files support tests.
662 testPart.SetExcludedFromPosFiles( true );
663 BOOST_CHECK( m_part_no_data.Compare( testPart, ~SCH_ITEM::COMPARE_FLAGS::UUID ) > 0 );
664 testPart.SetExcludedFromPosFiles( false );
665 m_part_no_data.SetExcludedFromPosFiles( true );
666 BOOST_CHECK( m_part_no_data.Compare( testPart, ~SCH_ITEM::COMPARE_FLAGS::UUID ) < 0 );
667 m_part_no_data.SetExcludedFromPosFiles( false );
668
669 // Show pin names flag comparison tests.
670 m_part_no_data.SetShowPinNames( false );
671 BOOST_CHECK( m_part_no_data.Compare( testPart, ~SCH_ITEM::COMPARE_FLAGS::UUID ) < 0 );
672 m_part_no_data.SetShowPinNames( true );
673 testPart.SetShowPinNames( false );
674 BOOST_CHECK( m_part_no_data.Compare( testPart, ~SCH_ITEM::COMPARE_FLAGS::UUID ) > 0 );
675 testPart.SetShowPinNames( true );
676
677 // Show pin numbers flag comparison tests.
678 m_part_no_data.SetShowPinNumbers( false );
679 BOOST_CHECK( m_part_no_data.Compare( testPart, ~SCH_ITEM::COMPARE_FLAGS::UUID ) < 0 );
680 m_part_no_data.SetShowPinNumbers( true );
681 testPart.SetShowPinNumbers( false );
682 BOOST_CHECK( m_part_no_data.Compare( testPart, ~SCH_ITEM::COMPARE_FLAGS::UUID ) > 0 );
683 testPart.SetShowPinNumbers( true );
684
685 // Time stamp comparison tests.
686
687 // Check to see if we broke the copy ctor.
688 LIB_SYMBOL copy( testPart );
689 BOOST_CHECK( testPart.Compare( copy ) == 0 );
690}
691
692
696BOOST_AUTO_TEST_CASE( GetUnitItems )
697{
698 // There are no unit draw items in the empty LIB_SYMBOL object.
699 BOOST_CHECK( m_part_no_data.GetUnitDrawItems( 1, 1 ).size() == 0 );
700
701 // A single unique unit with 1 pin common to all units and all body styles.
702 SCH_PIN* pin1 = new SCH_PIN( &m_part_no_data );
703 m_part_no_data.AddDrawItem( pin1 );
704 BOOST_CHECK( m_part_no_data.GetUnitDrawItems( 0, 0 ).size() == 1 );
705
706 // A single unique unit with 1 pin in unit 1 and common to all body styles.
707 pin1->SetUnit( 1 );
708 BOOST_CHECK( m_part_no_data.GetUnitDrawItems( 1, 0 ).size() == 1 );
709
710 // A single unique unit with 1 pin in unit 1 and body style 1.
711 pin1->SetBodyStyle( 1 );
712 BOOST_CHECK( m_part_no_data.GetUnitDrawItems( 1, 1 ).size() == 1 );
713
714 // Two unique units with pin 1 assigned to unit 1 and body style 1 and pin 2 assigned to
715 // unit 2 and body style 1.
716 SCH_PIN* pin2 = new SCH_PIN( &m_part_no_data );
717 m_part_no_data.SetUnitCount( 2, true );
718 pin2->SetUnit( 2 );
719 pin2->SetBodyStyle( 2 );
720 pin2->SetNumber( "4" );
721 m_part_no_data.AddDrawItem( pin2 );
722 BOOST_CHECK( m_part_no_data.GetUnitDrawItems( 2, 2 ).size() == 1 );
723
724 // Make pin 1 body style common to all units.
725 pin1->SetBodyStyle( 0 );
726 BOOST_CHECK( m_part_no_data.GetUnitDrawItems( 1, 1 ).size() == 0 );
727 BOOST_CHECK( m_part_no_data.GetUnitDrawItems( 2, 1 ).size() == 1 );
728
729 m_part_no_data.RemoveDrawItem( pin2 );
730 m_part_no_data.RemoveDrawItem( pin1 );
731 m_part_no_data.RemoveDrawItem( &*m_part_no_data.GetDrawItems().begin() );
732}
733
734
738BOOST_AUTO_TEST_CASE( GetUnitDrawItems )
739{
740 // An empty symbol still reports its unit and body style so the saver writes them out
741 std::vector<struct LIB_SYMBOL_UNIT> units = m_part_no_data.GetUnitDrawItems();
742
743 BOOST_REQUIRE_EQUAL( units.size(), 1u );
744 BOOST_CHECK_EQUAL( units[0].m_unit, 1 );
745 BOOST_CHECK_EQUAL( units[0].m_bodyStyle, 1 );
746 BOOST_CHECK( units[0].m_items.empty() );
747
748 // A pin common to all units and all body styles matches no numbered unit and gets a
749 // record of its own rather than being dropped
750 SCH_PIN* pin1 = new SCH_PIN( &m_part_no_data );
751 pin1->SetNumber( "1" );
752 m_part_no_data.AddDrawItem( pin1 );
753
754 units = m_part_no_data.GetUnitDrawItems();
755
756 BOOST_REQUIRE_EQUAL( units.size(), 2u );
757 BOOST_CHECK_EQUAL( units[0].m_unit, 0 );
758 BOOST_CHECK_EQUAL( units[0].m_bodyStyle, 0 );
759 BOOST_REQUIRE_EQUAL( units[0].m_items.size(), 1u );
760 BOOST_CHECK_EQUAL( units[0].m_items[0], pin1 );
761 BOOST_CHECK_EQUAL( units[1].m_unit, 1 );
762 BOOST_CHECK_EQUAL( units[1].m_bodyStyle, 1 );
763 BOOST_CHECK( units[1].m_items.empty() );
764
765 // Units without draw items of their own are still reported
766 m_part_no_data.SetUnitCount( 3, true );
767
768 units = m_part_no_data.GetUnitDrawItems();
769
770 BOOST_REQUIRE_EQUAL( units.size(), 4u );
771 BOOST_CHECK_EQUAL( units[0].m_unit, 0 );
772 BOOST_CHECK_EQUAL( units[1].m_unit, 1 );
773 BOOST_CHECK_EQUAL( units[2].m_unit, 2 );
774 BOOST_CHECK_EQUAL( units[3].m_unit, 3 );
775 BOOST_CHECK( units[1].m_items.empty() );
776 BOOST_CHECK( units[2].m_items.empty() );
777 BOOST_CHECK( units[3].m_items.empty() );
778
779 // Both body styles of every unit are reported once De Morgan is enabled
780 m_part_no_data.SetHasDeMorganBodyStyles( true );
781
782 units = m_part_no_data.GetUnitDrawItems();
783
784 BOOST_REQUIRE_EQUAL( units.size(), 7u );
785 BOOST_CHECK_EQUAL( units[1].m_bodyStyle, 1 );
786 BOOST_CHECK_EQUAL( units[2].m_bodyStyle, 2 );
787}
788
789
794{
795 std::unique_ptr<LIB_SYMBOL> parent = std::make_unique<LIB_SYMBOL>( "parent" );
796 BOOST_CHECK( parent->IsRoot() );
797 BOOST_CHECK_EQUAL( parent->GetInheritanceDepth(), 0 );
798
799 std::unique_ptr<LIB_SYMBOL> ref = std::make_unique<LIB_SYMBOL>( *parent );
800
801 std::unique_ptr<LIB_SYMBOL> child = std::make_unique<LIB_SYMBOL>( "child", parent.get() );
802 BOOST_CHECK( child->IsDerived() );
803 BOOST_CHECK_EQUAL( child->GetInheritanceDepth(), 1 );
804
805 std::unique_ptr<LIB_SYMBOL> grandChild = std::make_unique<LIB_SYMBOL>( "grandchild", child.get() );
806 BOOST_CHECK( grandChild->IsDerived() );
807 BOOST_CHECK_EQUAL( grandChild->GetInheritanceDepth(), 2 );
808
809 BOOST_CHECK( parent->GetRootSymbol().get() == parent.get() );
810 BOOST_CHECK( child->GetRootSymbol().get() == parent.get() );
811 BOOST_CHECK( grandChild->GetRootSymbol().get() == parent.get() );
812
813 std::shared_ptr<LIB_SYMBOL> parentRef = child->GetParent().lock();
814 BOOST_CHECK( parentRef );
815 BOOST_CHECK( parentRef == parent->SharedPtr() );
816 BOOST_CHECK_EQUAL( parent->SharedPtr().use_count(), 3 );
817
818 std::shared_ptr<LIB_SYMBOL> childRef = grandChild->GetParent().lock();
819 BOOST_CHECK( childRef );
820 BOOST_CHECK( childRef == child->SharedPtr() );
821 BOOST_CHECK_EQUAL( child->SharedPtr().use_count(), 3 );
822
823 BOOST_CHECK_EQUAL( child->GetUnitCount(), 1 );
824 parent->SetUnitCount( 4, true );
825 BOOST_CHECK_EQUAL( child->GetUnitCount(), 4 );
826 parent->SetUnitCount( 1, true );
827
828 parent->GetField( FIELD_T::DATASHEET )->SetText( "https://kicad/resistors.pdf" );
829 ref->GetField( FIELD_T::DATASHEET )->SetText( "https://kicad/resistors.pdf" );
830
831 BOOST_CHECK( *parent == *ref );
832
833 ref->SetName( "child" );
834 SCH_FIELD* field = new SCH_FIELD( nullptr, FIELD_T::USER, "Manufacturer" );
835 field->SetText( "KiCad" );
836 child->AddField( field );
837 field->SetParent( child.get() );
838
839 field = new SCH_FIELD( nullptr, FIELD_T::USER, "Manufacturer" );
840 field->SetText( "KiCad" );
841 ref->AddField( field );
842 field->SetParent( ref.get() );
843
844 BOOST_CHECK( *ref == *child->Flatten() );
845
846 ref->SetName( "grandchild" );
847 field = new SCH_FIELD( nullptr, FIELD_T::USER, "MPN" );
848 field->SetText( "123456" );
849 grandChild->AddField( field );
850 field->SetParent( grandChild.get() );
851
852 field = new SCH_FIELD( nullptr, FIELD_T::USER, "MPN" );
853 field->SetText( "123456" );
854 ref->AddField( field );
855 field->SetParent( ref.get() );
856
857 BOOST_CHECK( *ref == *grandChild->Flatten() );
858
859 BOOST_CHECK_EQUAL( grandChild->Flatten()->GetField( FIELD_T::DATASHEET )->GetText(),
860 "https://kicad/resistors.pdf" );
861
862 child->SetParent();
863 BOOST_CHECK_EQUAL( child->GetUnitCount(), 1 );
864
865 parentRef.reset();
866 BOOST_CHECK_EQUAL( parent->SharedPtr().use_count(), 2 );
867}
868
869
873BOOST_AUTO_TEST_CASE( CopyConstructor )
874{
875 std::shared_ptr<LIB_SYMBOL> copy = std::make_shared<LIB_SYMBOL>( m_part_no_data );
876 BOOST_CHECK( m_part_no_data == *copy.get() );
877}
878
879
884{
885 std::unique_ptr<LIB_SYMBOL> symbol = std::make_unique<LIB_SYMBOL>( "power" );
886 SCH_PIN* pin = new SCH_PIN( symbol.get() );
887 pin->SetNumber( "1" );
889 pin->SetVisible( false );
890 symbol->AddDrawItem( pin );
891
892 BOOST_CHECK( !symbol->IsPower() );
893 BOOST_CHECK( symbol->IsNormal() );
894
895 symbol->SetGlobalPower();
896 BOOST_CHECK( symbol->IsPower() );
897 BOOST_CHECK( !symbol->IsNormal() );
898
899 // symbol->SetNormal();
900 // symbol->GetReferenceField().SetText( wxS( "#PWR" ) );
901 // BOOST_CHECK( symbol->IsPower() );
902
903 // Legacy power symbols are limited to a single pin.
904 // pin = new LIB_PIN( symbol.get() );
905 // pin->SetNumber( "2" );
906 // pin->SetType( ELECTRICAL_PINTYPE::PT_POWER_IN );
907 // pin->SetVisible( false );
908 // symbol->AddDrawItem( pin );
909 // BOOST_CHECK( !symbol->IsPower() );
910}
911
912
922BOOST_AUTO_TEST_CASE( SetUnitCountRejectsInvalidValues )
923{
924 auto checkMandatoryFields = []( LIB_SYMBOL& aSymbol )
925 {
926 BOOST_CHECK_EQUAL( aSymbol.GetUnitCount(), 1 );
927 BOOST_CHECK_NE( aSymbol.GetField( FIELD_T::REFERENCE ), nullptr );
928 BOOST_CHECK_NE( aSymbol.GetField( FIELD_T::VALUE ), nullptr );
929 BOOST_CHECK_NE( aSymbol.GetField( FIELD_T::FOOTPRINT ), nullptr );
930 BOOST_CHECK_NE( aSymbol.GetField( FIELD_T::DATASHEET ), nullptr );
931 BOOST_CHECK_NE( aSymbol.GetField( FIELD_T::DESCRIPTION ), nullptr );
932
933 // Reading the reference field text must not crash. This was the original SIGSEGV
934 // path through CONNECTION_SUBGRAPH::GetDriverPriority() reported in issue 23788.
935 BOOST_CHECK_NO_THROW( (void) aSymbol.GetReferenceField().GetText() );
936 };
937
938 // Sanity check the freshly constructed symbol.
939 LIB_SYMBOL baseline( wxS( "test_part" ) );
940 checkMandatoryFields( baseline );
941
942 // When wxDEBUG_LEVEL > 0 the wxCHECK fires (caught by CHECK_WX_ASSERT) and the function
943 // does not modify the symbol. With wxDEBUG_LEVEL == 0 the wxCHECK is silent and the
944 // function returns early without modification. Cover both call paths so the test
945 // exercises the actual SetUnitCount entry on every build configuration.
946 LIB_SYMBOL zeroCount( wxS( "test_part" ) );
947 CHECK_WX_ASSERT( zeroCount.SetUnitCount( 0, true ) );
948#if wxDEBUG_LEVEL == 0
949 zeroCount.SetUnitCount( 0, true );
950#endif
951 checkMandatoryFields( zeroCount );
952
953 LIB_SYMBOL negativeCount( wxS( "test_part" ) );
954 CHECK_WX_ASSERT( negativeCount.SetUnitCount( -1, true ) );
955#if wxDEBUG_LEVEL == 0
956 negativeCount.SetUnitCount( -1, true );
957#endif
958 checkMandatoryFields( negativeCount );
959}
960
961
971BOOST_AUTO_TEST_CASE( DeleteDeMorganBodyStyleDrawItems )
972{
973 for( bool clearFlagFirst : { false, true } )
974 {
975 std::unique_ptr<LIB_SYMBOL> symbol = loadDeMorganSymbol();
976 BOOST_REQUIRE( symbol );
977 BOOST_REQUIRE( symbol->HasDeMorganBodyStyles() );
979
980 if( clearFlagFirst )
981 {
982 symbol->SetHasDeMorganBodyStyles( false );
983 symbol->SetBodyStyleCount( 1, false, false );
984 }
985 else
986 {
987 symbol->SetBodyStyleCount( 1, false, false );
988 symbol->SetHasDeMorganBodyStyles( false );
989 }
990
991 symbol->SetBodyStyleNames( {} );
992
993 BOOST_CHECK_EQUAL( symbol->GetBodyStyleCount(), 1 );
995 }
996}
997
998
1003BOOST_AUTO_TEST_CASE( OrphanedBodyStyleItemsAreNotLoaded )
1004{
1005 std::unique_ptr<LIB_SYMBOL> symbol = loadDeMorganSymbol();
1006 BOOST_REQUIRE( symbol );
1007
1008 // Reproduce what a broken save left on disk: no De Morgan declaration, alternate drawings
1009 symbol->SetHasDeMorganBodyStyles( false );
1011
1012 SCOPED_TEMP_LIB tempLib;
1013 saveToLib( tempLib.GetPath(), *symbol );
1014
1015 IO_RELEASER<SCH_IO> pi( SCH_IO_MGR::FindPlugin( SCH_IO_MGR::SCH_KICAD ) );
1016 LIB_SYMBOL* reloaded = pi->LoadSymbol( tempLib.GetPath(), wxS( "4001" ) );
1017
1018 BOOST_REQUIRE( reloaded );
1019 BOOST_CHECK_EQUAL( reloaded->GetBodyStyleCount(), 1 );
1021
1022 // The standard body style must survive the pruning
1023 BOOST_CHECK( !reloaded->GetUnitDrawItems( 1, BODY_STYLE::BASE ).empty() );
1024 BOOST_CHECK_EQUAL( reloaded->GetUnitCount(), symbol->GetUnitCount() );
1025}
1026
1027
1028BOOST_AUTO_TEST_CASE( NativeComparisonDetectsPinTypeChanges )
1029{
1030 LOCALE_IO locale;
1031 const auto original = loadDeMorganSymbol();
1032 BOOST_REQUIRE( original );
1033 LIB_SYMBOL changed( *original );
1036 BOOST_REQUIRE_EQUAL( original->Compare( changed, flags ), 0 );
1037 BOOST_REQUIRE_EQUAL( changed.Compare( *original, flags ), 0 );
1038 SCH_PIN* pin = changed.GetGraphicalPins( 0, 0 ).front();
1039 BOOST_REQUIRE( pin );
1040 const auto previous = pin->GetType();
1043 BOOST_REQUIRE( pin->GetType() != previous );
1044 BOOST_CHECK_NE( original->Compare( changed, flags ), 0 );
1045 BOOST_CHECK_NE( changed.Compare( *original, flags ), 0 );
1046}
1047
1048
1049BOOST_AUTO_TEST_CASE( NativeComparisonDetectsAddedPins )
1050{
1051 LOCALE_IO locale;
1052 const auto original = loadDeMorganSymbol();
1053 BOOST_REQUIRE( original );
1054 LIB_SYMBOL changed( *original );
1057 BOOST_REQUIRE_EQUAL( original->Compare( changed, flags ), 0 );
1058 BOOST_REQUIRE_EQUAL( changed.Compare( *original, flags ), 0 );
1059 const auto pins = original->GetGraphicalPins( 0, 0 );
1060 BOOST_REQUIRE( !pins.empty() );
1061 auto* extra = static_cast<SCH_PIN*>( pins.front()->Clone() );
1062 extra->SetNumber( "NativeExtra" );
1063 changed.AddDrawItem( extra );
1064 BOOST_REQUIRE_EQUAL( changed.GetGraphicalPins( 0, 0 ).size(), pins.size() + 1 );
1065 BOOST_CHECK_NE( original->Compare( changed, flags ), 0 );
1066 BOOST_CHECK_NE( changed.Compare( *original, flags ), 0 );
1067}
1068
1069
1070BOOST_AUTO_TEST_CASE( NativeComparisonHonorsMissingAndExtraFieldFlags )
1071{
1072 LOCALE_IO locale;
1073 const auto original = loadDeMorganSymbol();
1074 BOOST_REQUIRE( original );
1075 LIB_SYMBOL changed( *original );
1078 BOOST_REQUIRE_EQUAL( original->Compare( changed, flags ), 0 );
1079 BOOST_REQUIRE_EQUAL( changed.Compare( *original, flags ), 0 );
1080 const wxString name( "Native comparison field" );
1081 BOOST_REQUIRE( !original->GetField( name ) );
1082 changed.AddField( new SCH_FIELD( &changed, FIELD_T::USER, name ) );
1083 BOOST_REQUIRE( changed.GetField( name ) );
1084 BOOST_CHECK_EQUAL( original->Compare( changed, flags & ~SCH_ITEM::COMPARE_FLAGS::MISSING_FIELDS ), 0 );
1085 BOOST_CHECK_EQUAL( changed.Compare( *original, flags & ~SCH_ITEM::COMPARE_FLAGS::EXTRA_FIELDS ), 0 );
1086 BOOST_CHECK_NE( original->Compare( changed, flags ), 0 );
1087 BOOST_CHECK_NE( changed.Compare( *original, flags ), 0 );
1088}
1089
1090
1091BOOST_AUTO_TEST_CASE( NativeComparisonHonorsPinVisibilityFlag )
1092{
1093 LOCALE_IO locale;
1094 const auto original = loadDeMorganSymbol();
1095 BOOST_REQUIRE( original );
1096 LIB_SYMBOL changed( *original );
1099 BOOST_REQUIRE_EQUAL( original->Compare( changed, flags ), 0 );
1100 BOOST_REQUIRE_EQUAL( changed.Compare( *original, flags ), 0 );
1101 const auto pins = changed.GetGraphicalPins( 0, 0 );
1102 BOOST_REQUIRE( !pins.empty() );
1103 SCH_PIN* pin = pins.front();
1104 pin->SetVisible( !pin->IsVisible() );
1105 BOOST_CHECK_EQUAL( original->Compare( changed, flags & ~SCH_ITEM::COMPARE_FLAGS::PIN_VISIBILITIES ), 0 );
1106 BOOST_CHECK_EQUAL( changed.Compare( *original, flags & ~SCH_ITEM::COMPARE_FLAGS::PIN_VISIBILITIES ), 0 );
1107 BOOST_CHECK_NE( original->Compare( changed, flags ), 0 );
1108 BOOST_CHECK_NE( changed.Compare( *original, flags ), 0 );
1109}
1110
1111
1112BOOST_AUTO_TEST_CASE( NativeComparisonHonorsAlternateDefinitionFlag )
1113{
1114 LOCALE_IO locale;
1115 const auto original = loadDeMorganSymbol();
1116 BOOST_REQUIRE( original );
1117 LIB_SYMBOL changed( *original );
1120 BOOST_REQUIRE_EQUAL( original->Compare( changed, flags ), 0 );
1121 BOOST_REQUIRE_EQUAL( changed.Compare( *original, flags ), 0 );
1122 const auto pins = changed.GetGraphicalPins( 0, 0 );
1123 BOOST_REQUIRE( !pins.empty() );
1124 SCH_PIN* pin = pins.front();
1125 const wxString name( "Native alternate" );
1126 BOOST_REQUIRE( !pin->GetAlternates().contains( name ) );
1127 pin->GetAlternates().emplace( name, SCH_PIN::ALT{ name, GRAPHIC_PINSHAPE::LINE,
1129 BOOST_CHECK_EQUAL( original->Compare( changed, flags & ~SCH_ITEM::COMPARE_FLAGS::PIN_ALT_DEFS ), 0 );
1130 BOOST_CHECK_EQUAL( changed.Compare( *original, flags & ~SCH_ITEM::COMPARE_FLAGS::PIN_ALT_DEFS ), 0 );
1131 BOOST_CHECK_NE( original->Compare( changed, flags ), 0 );
1132 BOOST_CHECK_NE( changed.Compare( *original, flags ), 0 );
1133}
1134
1135
const char * name
virtual void SetParent(EDA_ITEM *aParent)
Definition eda_item.cpp:153
virtual void SetEnd(const VECTOR2I &aEnd)
Definition eda_shape.h:329
virtual void SetBezierC2(const VECTOR2I &aPt)
Definition eda_shape.h:367
virtual void SetBezierC1(const VECTOR2I &aPt)
Definition eda_shape.h:364
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:174
const std::vector< VECTOR2I > & GetBezierPoints() const
Definition eda_shape.h:491
virtual void SetStart(const VECTOR2I &aStart)
Definition eda_shape.h:279
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
Define a library symbol object.
Definition lib_symbol.h:119
const LIB_ID & GetLibId() const override
Definition lib_symbol.h:188
void SetGlobalPower()
std::vector< const SCH_PIN * > GetGraphicalPins(int aUnit=0, int aBodyStyle=0) const
Graphical pins: Return schematic pin objects as drawn (unexpanded), filtered by unit/body.
std::vector< struct LIB_SYMBOL_UNIT > GetUnitDrawItems()
Return a list of SCH_ITEM objects separated by unit and convert number.
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:365
LIB_ITEMS_CONTAINER & GetDrawItems()
Return a reference to the draw item list.
Definition lib_symbol.h:832
void SetUnitCount(int aCount, bool aDuplicateDrawItems)
Set the units per symbol count.
void SetDescription(const wxString &aDescription)
Gets the Description field text value *‍/.
void SetKeyWords(const wxString &aKeyWords)
void RemoveDrawItem(SCH_ITEM *aItem)
Remove draw aItem from list.
void SetFPFilters(const wxArrayString &aFilters)
Definition lib_symbol.h:245
int GetBodyStyleCount() const override
The body styles are a property of the drawings, which a derived symbol inherits from its root symbol ...
int GetUnitCount() const override
void SetLibId(const LIB_ID &aLibId)
void AddField(SCH_FIELD *aField)
Add a field.
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
void SetText(const wxString &aText) override
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition sch_item.h:165
virtual void SetBodyStyle(int aBodyStyle)
Definition sch_item.h:246
@ MISSING_FIELDS
Definition sch_item.h:709
@ EXTRA_FIELDS
Definition sch_item.h:710
@ PIN_ALT_DEFS
Definition sch_item.h:716
@ PIN_VISIBILITIES
Definition sch_item.h:715
virtual void SetUnit(int aUnit)
Definition sch_item.h:236
void SetNumber(const wxString &aNumber)
Definition sch_pin.cpp:825
PIN_ALTERNATE ALT
Definition sch_pin.h:61
A temporary symbol library that is removed when it goes out of scope.
const wxString & GetPath() const
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:206
virtual void SetShowPinNumbers(bool aShow)
Set or clear the pin number visibility flag.
Definition symbol.h:170
int GetPinNameOffset() const
Definition symbol.h:159
virtual void SetShowPinNames(bool aShow)
Set or clear the pin name visibility flag.
Definition symbol.h:164
void SetPinNameOffset(int aOffset)
Set the offset in mils of the pin name text from the pin symbol.
Definition symbol.h:158
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:221
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:191
TEST_LIB_SYMBOL_FIXTURE()
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:57
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:488
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.
@ 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
@ BASE
Definition sch_item.h:59
@ 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_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
BOOST_AUTO_TEST_SUITE_END()
KIBIS_PIN * pin1
KIBIS_PIN * pin
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.
BOOST_AUTO_TEST_CASE(DefaultProperties)
Declare the test suite.
BOOST_CHECK_PREDICATE(ArePolylineEndPointsNearCircle,(chain)(c.m_geom.m_center_point)(radius)(accuracy+epsilon))
BOOST_TEST_CONTEXT("Test Clearance")
BOOST_CHECK_EQUAL(result, "25.4")
@ 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:683