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
21#include <pcb_dimension.h>
22
23BOOST_AUTO_TEST_CASE( DimensionZeroSuppressionPreservesIntegerMagnitude )
24{
25 PCB_DIM_ALIGNED dimension( nullptr );
26 dimension.SetUnits( EDA_UNITS::MM );
27 dimension.SetSuppressZeroes( true );
28
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
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 );
48 dimension.SetSuppressZeroes( true );
49 dimension.SetMeasuredValue( pcbIUScale.MilsToIU( 10 ) );
50 BOOST_CHECK_EQUAL( dimension.GetValueText(), "10" );
51}
constexpr EDA_IU_SCALE pcbIUScale
Definition base_units.h:128
void SetMeasuredValue(int aValue)
void SetUnits(EDA_UNITS aUnits)
void SetSuppressZeroes(bool aSuppress)
void SetPrecision(DIM_PRECISION aPrecision)
wxString GetValueText() const
For better understanding of the points that make a dimension:
DIM_PRECISION
BOOST_AUTO_TEST_CASE(DimensionZeroSuppressionPreservesIntegerMagnitude)
BOOST_CHECK_EQUAL(result, "25.4")