KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_altium_parser_sch.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, you may find one here:
18
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19
* or you may search the http://www.gnu.org website for the version 2 license,
20
* or you may write to the Free Software Foundation, Inc.,
21
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22
*/
23
28
29
#include <
qa_utils/wx_utils/unit_test_utils.h
>
30
31
#include <
eeschema/sch_io/altium/altium_parser_sch.h
>
32
33
// Function declarations of private methods to test
34
int
ReadKiCadUnitFrac
(
const
std::map<wxString, wxString>& aProps,
35
const
wxString& aKey );
36
37
38
struct
ALTIUM_PARSER_SCH_FIXTURE
39
{
40
ALTIUM_PARSER_SCH_FIXTURE
() {}
41
};
42
43
47
BOOST_FIXTURE_TEST_SUITE( AltiumParserSch,
ALTIUM_PARSER_SCH_FIXTURE
)
48
49
struct
ALTIUM_TO_KICAD_UNIT_FRAC_CASE
50
{
51
wxString
input
;
52
wxString
input_frac
;
53
int
exp_result
;
54
};
55
59
static
const
std::vector<ALTIUM_TO_KICAD_UNIT_FRAC_CASE>
altium_to_kicad_unit_frac
= {
60
// Some simple values
61
{
"0"
,
"0"
, 0 },
62
{
"1"
,
"0"
, 2540 },
63
{
"2"
,
"0"
, 5080 },
64
{
"-1"
,
"0"
, -2540 },
65
{
"-2"
,
"0"
, -5080 },
66
// Decimal Places
67
{
"0"
,
"1"
, 0 },
68
{
"0"
,
"10"
, 0 },
69
{
"0"
,
"100"
, 0 },
70
{
"0"
,
"1000"
, 30 },
71
{
"0"
,
"10000"
, 250 },
72
{
"1"
,
"10000"
, 2790 },
73
{
"0"
,
"-1"
, 0 },
74
{
"0"
,
"-10"
, 0 },
75
{
"0"
,
"-100"
, 0 },
76
{
"0"
,
"-1000"
, -30 },
77
{
"0"
,
"-10000"
, -250 },
78
{
"-1"
,
"-10000"
, -2790 },
79
// Edge Cases
80
// Clamp bigger values
81
// imperial rounded units as input
82
// metric rounded units as input
83
};
84
88
BOOST_AUTO_TEST_CASE
( PropertiesReadKiCadUnitFracConversation )
89
{
90
for
(
const
auto
& c :
altium_to_kicad_unit_frac
)
91
{
92
BOOST_TEST_CONTEXT
(
93
wxString::Format( wxT(
"%s FRAC %s -> %i"
), c.input, c.input_frac, c.exp_result ) )
94
{
95
std::map<wxString, wxString> properties = { {
"TEST"
, c.input },
96
{
"TEST_FRAC"
, c.input_frac } };
97
98
int
result
=
ReadKiCadUnitFrac
( properties,
"TEST"
);
99
100
// These are all valid
101
BOOST_CHECK_EQUAL
(
result
, c.exp_result );
102
}
103
}
104
}
105
106
107
BOOST_AUTO_TEST_SUITE_END
()
altium_parser_sch.h
ALTIUM_PARSER_SCH_FIXTURE
Definition
test_altium_parser_sch.cpp:39
ALTIUM_PARSER_SCH_FIXTURE::ALTIUM_PARSER_SCH_FIXTURE
ALTIUM_PARSER_SCH_FIXTURE()
Definition
test_altium_parser_sch.cpp:40
ALTIUM_TO_KICAD_UNIT_FRAC_CASE
Declares the struct as the Boost test fixture.
Definition
test_altium_parser_sch.cpp:50
ALTIUM_TO_KICAD_UNIT_FRAC_CASE::exp_result
int exp_result
Definition
test_altium_parser_sch.cpp:53
ALTIUM_TO_KICAD_UNIT_FRAC_CASE::input_frac
wxString input_frac
Definition
test_altium_parser_sch.cpp:52
ALTIUM_TO_KICAD_UNIT_FRAC_CASE::input
wxString input
Definition
test_altium_parser_sch.cpp:51
altium_to_kicad_unit_frac
static const std::vector< ALTIUM_TO_KICAD_UNIT_FRAC_CASE > altium_to_kicad_unit_frac
A list of valid internal unit conversation factors.
Definition
test_altium_parser_sch.cpp:59
ReadKiCadUnitFrac
int ReadKiCadUnitFrac(const std::map< wxString, wxString > &aProps, const wxString &aKey)
Definition
altium_parser_sch.cpp:57
BOOST_AUTO_TEST_CASE
BOOST_AUTO_TEST_CASE(PropertiesReadKiCadUnitFracConversation)
Test conversation from Altium internal units into KiCad internal units using properties with FRAC.
Definition
test_altium_parser_sch.cpp:88
BOOST_AUTO_TEST_SUITE_END
BOOST_AUTO_TEST_SUITE_END()
BOOST_TEST_CONTEXT
BOOST_TEST_CONTEXT("Test Clearance")
Definition
test_shape_arc.cpp:656
result
wxString result
Test unit parsing edge cases and error handling.
Definition
test_text_eval_numeric_compat.cpp:602
BOOST_CHECK_EQUAL
BOOST_CHECK_EQUAL(result, "25.4")
unit_test_utils.h
src
qa
tests
eeschema
sch_io
altium
test_altium_parser_sch.cpp
Generated on Mon Oct 13 2025 00:06:27 for KiCad PCB EDA Suite by
1.13.2