KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_meander_corner_radius.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
27
29#include <boost/test/unit_test.hpp>
30
31#include <router/pns_meander.h>
32
33BOOST_AUTO_TEST_SUITE( MeanderCornerRadius )
34
35
38BOOST_AUTO_TEST_CASE( DefaultSettings )
39{
40 PNS::MEANDER_SETTINGS settings;
41
42 // Default should be round corners
44
45 // Corner radius percentage default is 80%
47
48 // Default spacing
49 BOOST_CHECK_EQUAL( settings.m_spacing, 600000 ); // 0.6mm
50
51 // Minimum amplitude should be set
52 BOOST_CHECK_GT( settings.m_minAmplitude, 0 );
53}
54
62BOOST_AUTO_TEST_CASE( MinCornerRadiusThreshold )
63{
64 // Test the minimum corner radius calculation logic
65 // The threshold should be width / 2 to ensure visibly rounded corners
66
67 std::vector<int> widths = { 100000, 150000, 200000, 250000, 400000 };
68
69 for( int width : widths )
70 {
71 // The minimum acceptable corner radius is half the width
72 int minCornerRadius = width / 2;
73
74 // Verify the threshold is reasonable (not too large, not too small)
75 BOOST_CHECK_GT( minCornerRadius, 0 );
76 BOOST_CHECK_LE( minCornerRadius, width );
77
78 BOOST_TEST_MESSAGE( wxString::Format( "Width %d: minCornerRadius=%d",
79 width, minCornerRadius ) );
80 }
81}
82
93BOOST_AUTO_TEST_CASE( GeometricConstraints )
94{
95 int width = 250000; // 0.25mm track
96 int minCornerRadius = width / 2; // 0.125mm
97
98 // For corner radius to be at least minCornerRadius:
99 // 1. amplitude / 2 >= minCornerRadius => amplitude >= width
100 // 2. spacing / 2 >= minCornerRadius => spacing >= width
101
102 // Test various amplitude/spacing combinations
103 struct TestCase
104 {
105 int amplitude;
106 int spacing;
107 bool shouldFit;
108 };
109
110 std::vector<TestCase> testCases = {
111 { 500000, 600000, true }, // 0.5mm amp, 0.6mm spacing - plenty of room
112 { 250000, 600000, true }, // 0.25mm amp, 0.6mm spacing - minimum amplitude
113 { 500000, 250000, true }, // 0.5mm amp, 0.25mm spacing - minimum spacing
114 { 250000, 250000, true }, // 0.25mm amp, 0.25mm spacing - both at minimum
115 { 200000, 600000, false }, // 0.2mm amp < width - amplitude too small
116 { 500000, 200000, false }, // 0.2mm spacing < width - spacing too small
117 };
118
119 for( const auto& tc : testCases )
120 {
121 // Calculate maximum corner radius based on amplitude and spacing
122 int maxCrFromAmp = tc.amplitude / 2;
123 int maxCrFromSpacing = tc.spacing / 2;
124 int maxCr = std::min( maxCrFromAmp, maxCrFromSpacing );
125
126 bool wouldFit = maxCr >= minCornerRadius;
127
128 BOOST_CHECK_EQUAL( wouldFit, tc.shouldFit );
129
130 BOOST_TEST_MESSAGE( wxString::Format(
131 "amp=%d, spacing=%d: maxCr=%d, minRequired=%d, fits=%s (expected %s)",
132 tc.amplitude, tc.spacing, maxCr, minCornerRadius,
133 wouldFit ? "yes" : "no", tc.shouldFit ? "yes" : "no" ) );
134 }
135}
136
Dimensions for the meandering algorithm.
Definition pns_meander.h:70
int m_minAmplitude
Maximum meandering amplitude.
int m_cornerRadiusPercentage
Place meanders on one side.
MEANDER_STYLE m_cornerStyle
Rounding percentage (0 - 100).
int m_spacing
Amplitude/spacing adjustment step.
@ MEANDER_STYLE_ROUND
Definition pns_meander.h:54
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_CASE(DefaultSettings)
Test that MEANDER_SETTINGS has correct defaults for corner style.
BOOST_TEST_MESSAGE("\n=== Real-World Polygon PIP Benchmark ===\n"<< formatTable(table))
BOOST_CHECK_EQUAL(result, "25.4")