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
20
#include <
qa_utils/wx_utils/unit_test_utils.h
>
21
22
#include <
board.h
>
23
#include <
pcb_track.h
>
24
#include <
pcbnew_utils/board_test_utils.h
>
25
#include <
settings/settings_manager.h
>
26
27
#include <
router/pns_diff_pair.h
>
28
#include <
router/pns_item.h
>
29
#include <
router/pns_kicad_iface.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
37
struct
DIFF_PAIR_TUNING_WIDTH_FIXTURE
38
{
39
SETTINGS_MANAGER
m_settingsManager
;
40
std::unique_ptr<BOARD>
m_board
;
41
};
42
43
44
static
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
57
BOOST_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
62
PCB_TRACK
& startTrack =
static_cast<
PCB_TRACK
&
>
(
KI_TEST::RequireBoardItemWithTypeAndId
(
63
*m_board,
PCB_TRACE_T
,
KIID
(
"5ca809fb-b7f4-4a3c-b239-272a2b12320f"
) ) );
64
65
PNS::ROUTER
router;
66
PNS_KICAD_IFACE_BASE
iface;
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
83
checkLineUsesOnlyTrackWidth
( pair.
PLine
() );
84
checkLineUsesOnlyTrackWidth
( pair.
NLine
() );
85
}
pcbIUScale
constexpr EDA_IU_SCALE pcbIUScale
Definition
base_units.h:121
board.h
board_test_utils.h
KIID
Definition
kiid.h:44
PCB_TRACK
Definition
pcb_track.h:57
PNS::DIFF_PAIR
Basic class for a differential pair.
Definition
pns_diff_pair.h:235
PNS::DIFF_PAIR::NLine
LINE & NLine()
Definition
pns_diff_pair.h:496
PNS::DIFF_PAIR::PLine
LINE & PLine()
Definition
pns_diff_pair.h:488
PNS::ITEM
Base class for PNS router board items.
Definition
pns_item.h:98
PNS::LINE
Represents a track on a PCB, connecting two non-trivial joints (that is, vias, pads,...
Definition
pns_line.h:62
PNS::LINE::Width
int Width() const
Return true if the line is geometrically identical as line aOther.
Definition
pns_line.h:162
PNS::LINKED_ITEM
Definition
pns_linked_item.h:30
PNS::LINK_HOLDER::Links
std::vector< LINKED_ITEM * > & Links()
Definition
pns_link_holder.h:66
PNS::LINK_HOLDER::LinkCount
int LinkCount() const
Definition
pns_link_holder.h:95
PNS::NODE::FindItemByParent
ITEM * FindItemByParent(const BOARD_ITEM *aParent)
Definition
pns_node.cpp:1815
PNS::ROUTER
Definition
pns_router.h:142
PNS::ROUTER::ClearWorld
void ClearWorld()
Definition
pns_router.cpp:107
PNS::ROUTER::SetInterface
void SetInterface(ROUTER_IFACE *aIface)
Definition
pns_router.cpp:1097
PNS::ROUTER::SyncWorld
void SyncWorld()
Definition
pns_router.cpp:95
PNS::ROUTER::GetWorld
NODE * GetWorld() const
Definition
pns_router.h:186
PNS::TOPOLOGY
Definition
pns_topology.h:43
PNS::TOPOLOGY::AssembleDiffPair
const DIFF_PAIR AssembleDiffPair(SEGMENT *aStart)
PNS_KICAD_IFACE_BASE
Definition
pns_kicad_iface.h:59
PNS_KICAD_IFACE_BASE::SetBoard
void SetBoard(BOARD *aBoard)
Definition
pns_kicad_iface.cpp:2131
SETTINGS_MANAGER
Definition
settings_manager.h:49
KI_TEST::LoadBoard
void LoadBoard(SETTINGS_MANAGER &aSettingsManager, const wxString &aRelPath, std::unique_ptr< BOARD > &aBoard)
Definition
board_test_utils.cpp:88
KI_TEST::RequireBoardItemWithTypeAndId
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.
Definition
board_test_utils.cpp:192
pcb_track.h
pns_diff_pair.h
pns_item.h
pns_kicad_iface.h
pns_line.h
pns_router.h
pns_topology.h
settings_manager.h
DIFF_PAIR_TUNING_WIDTH_FIXTURE
Definition
test_pns_diff_pair_tuning_width.cpp:38
DIFF_PAIR_TUNING_WIDTH_FIXTURE::m_settingsManager
SETTINGS_MANAGER m_settingsManager
Definition
test_pns_diff_pair_tuning_width.cpp:39
DIFF_PAIR_TUNING_WIDTH_FIXTURE::m_board
std::unique_ptr< BOARD > m_board
Definition
test_pns_diff_pair_tuning_width.cpp:40
BOOST_REQUIRE
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
BOOST_FIXTURE_TEST_CASE
BOOST_FIXTURE_TEST_CASE(DiffPairTuningStopsAtTrackWidthChanges, DIFF_PAIR_TUNING_WIDTH_FIXTURE)
Definition
test_pns_diff_pair_tuning_width.cpp:57
checkLineUsesOnlyTrackWidth
static void checkLineUsesOnlyTrackWidth(const PNS::LINE &aLine)
Definition
test_pns_diff_pair_tuning_width.cpp:44
BOOST_CHECK_EQUAL
BOOST_CHECK_EQUAL(result, "25.4")
PCB_TRACE_T
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)
Definition
typeinfo.h:89
unit_test_utils.h
src
qa
tests
pcbnew
test_pns_diff_pair_tuning_width.cpp
Generated on Sat Jul 25 2026 00:06:06 for KiCad PCB EDA Suite by
1.13.2