KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_pin_map_api.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 modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or (at your
9 * option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
21
22#include <string>
23
24#include <pin_map.h>
25#include <api/schematic/schematic_types.pb.h>
26#include <api/api_sch_utils.h>
27
28
29BOOST_AUTO_TEST_SUITE( PinMapApi )
30
31
32BOOST_AUTO_TEST_CASE( LibSymbolPinMapsProtoRoundTrip )
33{
34 kiapi::schematic::types::LibSymbolPinMaps maps;
35
36 kiapi::schematic::types::AssociatedFootprint* assoc = maps.add_associated_footprints();
37 assoc->mutable_footprint()->set_library_nickname( "Package_SO" );
38 assoc->mutable_footprint()->set_entry_name( "SOIC-8" );
39 assoc->set_map_name( "STD-8" );
40
41 kiapi::schematic::types::PinMap* map = maps.add_pin_maps();
42 map->set_name( "STD-8" );
43 kiapi::schematic::types::PinMapEntry* entry = map->add_entries();
44 entry->set_pin_number( "4" );
45 entry->set_pad_number( "[4,9]" );
46
47 std::string bytes;
48 BOOST_REQUIRE( maps.SerializeToString( &bytes ) );
49
50 kiapi::schematic::types::LibSymbolPinMaps parsed;
51 BOOST_REQUIRE( parsed.ParseFromString( bytes ) );
52
53 BOOST_REQUIRE_EQUAL( parsed.pin_maps_size(), 1 );
54 BOOST_CHECK_EQUAL( parsed.pin_maps( 0 ).name(), "STD-8" );
55 BOOST_REQUIRE_EQUAL( parsed.pin_maps( 0 ).entries_size(), 1 );
56 BOOST_CHECK_EQUAL( parsed.pin_maps( 0 ).entries( 0 ).pad_number(), "[4,9]" );
57 BOOST_REQUIRE_EQUAL( parsed.associated_footprints_size(), 1 );
58 BOOST_CHECK_EQUAL( parsed.associated_footprints( 0 ).map_name(), "STD-8" );
59 BOOST_CHECK_EQUAL( parsed.associated_footprints( 0 ).footprint().entry_name(), "SOIC-8" );
60}
61
62
63BOOST_AUTO_TEST_CASE( InstanceOverrideRoundTrip )
64{
67 override.m_ActiveMapName = wxS( "DFN-8-EP" );
68 override.m_Edits.push_back( { wxS( "1" ), wxS( "8" ) } );
69 override.m_Edits.push_back( { wxS( "8" ), wxS( "1" ) } );
70
71 kiapi::schematic::types::PinMapInstanceOverride proto;
72 PackPinMapOverride( &proto, override );
73
74 std::string bytes;
75 BOOST_REQUIRE( proto.SerializeToString( &bytes ) );
76
77 kiapi::schematic::types::PinMapInstanceOverride parsedProto;
78 BOOST_REQUIRE( parsedProto.ParseFromString( bytes ) );
79
81
82 BOOST_CHECK( result == override );
83}
84
85
PIN_MAP_INSTANCE_OVERRIDE UnpackPinMapOverride(const kiapi::schematic::types::PinMapInstanceOverride &aInput)
void PackPinMapOverride(kiapi::schematic::types::PinMapInstanceOverride *aOutput, const PIN_MAP_INSTANCE_OVERRIDE &aOverride)
Pack/unpack a pin-to-pad map instance override to/from its protobuf form (issue #2282).
Per-instance override of the active pin map and a sparse delta on top.
Definition pin_map.h:199
PIN_MAP_OVERRIDE_MODE m_Mode
Definition pin_map.h:200
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_CASE(LibSymbolPinMapsProtoRoundTrip)
wxString result
Test unit parsing edge cases and error handling.
BOOST_CHECK_EQUAL(result, "25.4")