KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_dimension_zero_suppression.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
#include <
pcb_dimension.h
>
22
23
BOOST_AUTO_TEST_CASE
( DimensionZeroSuppressionPreservesIntegerMagnitude )
24
{
25
PCB_DIM_ALIGNED
dimension(
nullptr
);
26
dimension.
SetUnits
(
EDA_UNITS::MM
);
27
dimension.
SetSuppressZeroes
(
true
);
28
29
for
(
DIM_PRECISION
precision : {
DIM_PRECISION::X
,
DIM_PRECISION::X_XXX
} )
30
{
31
dimension.
SetPrecision
( precision );
32
33
for
(
int
value : { 0, 10, 100, 1000 } )
34
{
35
dimension.
SetMeasuredValue
(
pcbIUScale
.mmToIU( value ) );
36
BOOST_CHECK_EQUAL
( dimension.
GetValueText
(), wxString::Format(
"%d"
, value ) );
37
}
38
}
39
40
dimension.
SetPrecision
(
DIM_PRECISION::X_XXX
);
41
dimension.
SetMeasuredValue
(
pcbIUScale
.mmToIU( 10.25 ) );
42
BOOST_CHECK_EQUAL
( dimension.
GetValueText
(),
"10.25"
);
43
dimension.
SetSuppressZeroes
(
false
);
44
BOOST_CHECK_EQUAL
( dimension.
GetValueText
(),
"10.250"
);
45
46
dimension.
SetUnits
(
EDA_UNITS::MILS
);
47
dimension.
SetPrecision
(
DIM_PRECISION::V_VV
);
48
dimension.
SetSuppressZeroes
(
true
);
49
dimension.
SetMeasuredValue
(
pcbIUScale
.MilsToIU( 10 ) );
50
BOOST_CHECK_EQUAL
( dimension.
GetValueText
(),
"10"
);
51
}
pcbIUScale
constexpr EDA_IU_SCALE pcbIUScale
Definition
base_units.h:128
PCB_DIMENSION_BASE::SetMeasuredValue
void SetMeasuredValue(int aValue)
Definition
pcb_dimension.h:183
PCB_DIMENSION_BASE::SetUnits
void SetUnits(EDA_UNITS aUnits)
Definition
pcb_dimension.cpp:593
PCB_DIMENSION_BASE::SetSuppressZeroes
void SetSuppressZeroes(bool aSuppress)
Definition
pcb_dimension.h:273
PCB_DIMENSION_BASE::SetPrecision
void SetPrecision(DIM_PRECISION aPrecision)
Definition
pcb_dimension.h:264
PCB_DIMENSION_BASE::GetValueText
wxString GetValueText() const
Definition
pcb_dimension.cpp:489
PCB_DIM_ALIGNED
For better understanding of the points that make a dimension:
Definition
pcb_dimension.h:476
EDA_UNITS::MILS
@ MILS
Definition
eda_units.h:50
EDA_UNITS::MM
@ MM
Definition
eda_units.h:46
pcb_dimension.h
DIM_PRECISION
DIM_PRECISION
Definition
pcb_dimension.h:45
DIM_PRECISION::X
@ X
Definition
pcb_dimension.h:46
DIM_PRECISION::V_VV
@ V_VV
Definition
pcb_dimension.h:52
DIM_PRECISION::X_XXX
@ X_XXX
Definition
pcb_dimension.h:49
BOOST_AUTO_TEST_CASE
BOOST_AUTO_TEST_CASE(DimensionZeroSuppressionPreservesIntegerMagnitude)
Definition
test_dimension_zero_suppression.cpp:23
BOOST_CHECK_EQUAL
BOOST_CHECK_EQUAL(result, "25.4")
unit_test_utils.h
src
qa
tests
pcbnew
test_dimension_zero_suppression.cpp
Generated on Tue Oct 27 2026 00:06:46 for KiCad PCB EDA Suite by
1.13.2