KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_pns_diff_pair_tuning_width.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
21
22#include <board.h>
23#include <pcb_track.h>
26
28#include <router/pns_item.h>
30#include <router/pns_line.h>
31#include <router/pns_router.h>
32#include <router/pns_topology.h>
33
34#include <memory>
35
36
42
43
44static void checkLineUsesOnlyTrackWidth( const PNS::LINE& aLine )
45{
46 BOOST_REQUIRE_GT( aLine.LinkCount(), 0 );
47
48 const int lineWidth = aLine.Width();
49
50 for( const PNS::LINKED_ITEM* link : aLine.Links() )
51 {
52 BOOST_CHECK_EQUAL( link->Width(), lineWidth );
53 }
54}
55
56
57BOOST_FIXTURE_TEST_CASE( DiffPairTuningStopsAtTrackWidthChanges, DIFF_PAIR_TUNING_WIDTH_FIXTURE )
58{
59 KI_TEST::LoadBoard( m_settingsManager, "issue23550/issue23550", m_board );
60 BOOST_REQUIRE( m_board );
61
63 *m_board, PCB_TRACE_T, KIID( "5ca809fb-b7f4-4a3c-b239-272a2b12320f" ) ) );
64
65 PNS::ROUTER router;
67 iface.SetBoard( m_board.get() );
68 router.SetInterface( &iface );
69 router.ClearWorld();
70 router.SyncWorld();
71
72 PNS::ITEM* startItem = router.GetWorld()->FindItemByParent( &startTrack );
73 BOOST_REQUIRE( startItem );
74
75 PNS::DIFF_PAIR pair;
76 PNS::TOPOLOGY topology( router.GetWorld() );
77
78 BOOST_REQUIRE( topology.AssembleDiffPair( startItem, pair ) );
79
80 BOOST_CHECK_EQUAL( pair.PLine().Width(), pcbIUScale.mmToIU( 0.085 ) );
81 BOOST_CHECK_EQUAL( pair.NLine().Width(), pcbIUScale.mmToIU( 0.085 ) );
82
85}
constexpr EDA_IU_SCALE pcbIUScale
Definition base_units.h:121
Definition kiid.h:44
Basic class for a differential pair.
Base class for PNS router board items.
Definition pns_item.h:98
Represents a track on a PCB, connecting two non-trivial joints (that is, vias, pads,...
Definition pns_line.h:62
int Width() const
Return true if the line is geometrically identical as line aOther.
Definition pns_line.h:162
ITEM * FindItemByParent(const BOARD_ITEM *aParent)
void ClearWorld()
void SetInterface(ROUTER_IFACE *aIface)
void SyncWorld()
NODE * GetWorld() const
Definition pns_router.h:186
const DIFF_PAIR AssembleDiffPair(SEGMENT *aStart)
void SetBoard(BOARD *aBoard)
void LoadBoard(SETTINGS_MANAGER &aSettingsManager, const wxString &aRelPath, std::unique_ptr< BOARD > &aBoard)
BOARD_ITEM & RequireBoardItemWithTypeAndId(const BOARD &aBoard, KICAD_T aItemType, const KIID &aID)
Get an item from the given board with a certain type and UUID.
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
BOOST_FIXTURE_TEST_CASE(DiffPairTuningStopsAtTrackWidthChanges, DIFF_PAIR_TUNING_WIDTH_FIXTURE)
static void checkLineUsesOnlyTrackWidth(const PNS::LINE &aLine)
BOOST_CHECK_EQUAL(result, "25.4")
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)
Definition typeinfo.h:89