KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_sexpr.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
24
26
27// Code under test
28#include <sexpr/sexpr.h>
29
30#include "sexpr_test_utils.h"
31
36
37
38BOOST_AUTO_TEST_CASE( BasicConstruction )
39{
40 SEXPR::SEXPR_INTEGER s_int{ 1 };
41 // not sure why cast is needed, but boost doesn't like it without
43
44 SEXPR::SEXPR_DOUBLE s_double{ 3.14 };
46
47 SEXPR::SEXPR_STRING s_string{ "string" };
49 KI_TEST::SexprIsStringWithValue, ( (SEXPR::SEXPR&) s_string )( "string" ) );
50
51 SEXPR::SEXPR_STRING s_symbol{ "symbol" };
53 KI_TEST::SexprIsStringWithValue, ( (SEXPR::SEXPR&) s_symbol )( "symbol" ) );
54}
55
57{
59 // not sure why cast is needed, but boost doesn't like it without
61}
62
63BOOST_AUTO_TEST_CASE( AsStringDouble )
64{
65 SEXPR::SEXPR_DOUBLE s{ 3.14 };
67}
68
69BOOST_AUTO_TEST_CASE( AsStringSymbol )
70{
71 SEXPR::SEXPR_SYMBOL s{ "symbol" };
73}
74
75BOOST_AUTO_TEST_CASE( AsStringString )
76{
77 SEXPR::SEXPR_STRING s{ "string" };
78
79 // strings get quotes
81}
82
83BOOST_AUTO_TEST_CASE( AsStringList )
84{
85 SEXPR::SEXPR_LIST s_list;
86
87 s_list.AddChild( new SEXPR::SEXPR_SYMBOL{ "symbol" } );
88
89 {
90 auto* s_SubList = new SEXPR::SEXPR_LIST();
91 *s_SubList << 2 << 42.42 << "substring";
92 s_list.AddChild( s_SubList );
93 }
94
95 s_list << 1 << 3.14 << "string";
96
98
99 // REVIEW: should there be a space at the end of the "symbol"?
101 ( (SEXPR::SEXPR&) s_list )( "(symbol \n"
102 " (2 42.42 \"substring\") 1 3.14 \"string\")" ) );
103}
104
void AddChild(SEXPR *aChild)
Definition sexpr.cpp:60
bool SexprIsDoubleWithValue(const SEXPR::SEXPR &aSexpr, double aVal)
Test predicate: is the s-expression a double with the given value?
bool SexprIsListOfLength(const SEXPR::SEXPR &aSexpr, size_t aExpectedLength)
Test predicate: is the s-expression a list with the given length?
bool SexprIsIntegerWithValue(const SEXPR::SEXPR &aSexpr, std::int64_t aVal)
Test predicate: is the s-expression an integer with the given value?
bool SexprIsStringWithValue(const SEXPR::SEXPR &aSexpr, const std::string &aVal)
Test predicate: is the s-expression a string with the given value?
bool SexprConvertsToString(const SEXPR::SEXPR &aSexpr, const std::string &aExpStr)
Predicate to check an SEXPR object converts to the expected string.
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_CASE(BasicConstruction)
Declare the test suite.
BOOST_CHECK_PREDICATE(ArePolylineEndPointsNearCircle,(chain)(c.m_geom.m_center_point)(radius)(accuracy+epsilon))