KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_embedded_si_literals.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
22
23BOOST_AUTO_TEST_CASE( EmbeddedSiPrefixesAndUppercaseExponents )
24{
25 const std::pair<wxString, wxString> cases[] = {
26 { "@{4k7}", "4700" },
27 { "@{1m2}", "0.0012" },
28 { "@{1E3}", "1000" },
29 { "@{1e3}", "1000" },
30 { "@{1E-3}", "0.001" },
31 { "@{1E+3}", "1000" },
32 { "@{1E}", "1e+18" },
33 { "@{4.7k}", "4700" }
34 };
35 for( const auto& [expression, expected] : cases )
36 {
37 EXPRESSION_EVALUATOR evaluator;
38 BOOST_CHECK_EQUAL( evaluator.Evaluate( expression ), expected );
39 BOOST_CHECK( !evaluator.HasErrors() );
40 }
41}
High-level wrapper for evaluating mathematical and string expressions in wxString format.
wxString Evaluate(const wxString &aInput)
Main evaluation function - processes input string and evaluates all '@{}' expressions.
bool HasErrors() const
Check if the last evaluation had errors.
BOOST_CHECK(res.column_datatype(0)==SQL_NUMERIC||res.column_datatype(0)==SQL_DECIMAL)
BOOST_CHECK_EQUAL(std::any_cast< std::string >(rows[0].at("val")), "12345678901234567.89")
BOOST_AUTO_TEST_CASE(EmbeddedSiPrefixesAndUppercaseExponents)
VECTOR3I expected(15, 30, 45)