KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_string_any_map.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 modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or (at your
9 * option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * 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#define BOOST_TEST_NO_MAIN
22
23#include <base_units.h>
24#include <string_any_map.h>
25
26
27BOOST_AUTO_TEST_SUITE( StringAnyMap )
28
29
30// 1.001 mm scales to 1000999.9999999999 nm, which a generator must not load 1 nm short
31BOOST_AUTO_TEST_CASE( GetToIuRoundsIntegralValues )
32{
33 STRING_ANY_MAP props( pcbIUScale.IU_PER_MM );
34 props.set_iu( "width", 1001000 );
35 props.set( "offset", -1.001 );
36 props.set( "length", 1.001 );
37
38 int value = 0;
39 long long length = 0;
40
41 BOOST_REQUIRE( props.get_to_iu( "width", value ) );
42 BOOST_CHECK_EQUAL( value, 1001000 );
43
44 BOOST_REQUIRE( props.get_to_iu( "offset", value ) );
45 BOOST_REQUIRE( props.get_to_iu( "length", length ) );
46 BOOST_CHECK_EQUAL( value, -1001000 );
47 BOOST_CHECK_EQUAL( length, 1001000 );
48}
49
50
constexpr EDA_IU_SCALE pcbIUScale
Definition base_units.h:128
A name/value tuple with unique names and wxAny values.
void set_iu(const std::string &aKey, const T &aVar)
void set(const std::string &aKey, const T &aVar)
bool get_to_iu(const std::string &aKey, T &aVar) const
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
BOOST_AUTO_TEST_SUITE_END()
BOOST_CHECK_EQUAL(result, "25.4")