25#include <boost/test/data/test_case.hpp>
53 {
"10mm + 20 mm",
false,
VAL( 30e6 ) },
54 {
"3*(7+8)",
false,
VAL( 3 * ( 7 + 8 ) ) },
55 {
"3*7+8",
false,
VAL( 3 * 7 + 8 ) },
56 {
"(3*7)+8",
false,
VAL( 3 * 7 + 8 ) },
57 {
"10mm + 20)",
true,
VAL( 0 ) },
59 {
"1",
false,
VAL(1) },
60 {
"1.5",
false,
VAL(1.5) },
61 {
"1,5",
false,
VAL(1.5) },
62 {
"1mm",
false,
VAL(1e6) },
64 {
" 1 + 2 ",
false,
VAL(3) },
66 {
"1.5 + 0.2 + 0.1",
false,
VAL(1.8) },
68 {
"3 - 10",
false,
VAL(-7) },
70 {
"1 + 2 + 10 + 1000.05",
false,
VAL(1013.05) },
72 {
"1 + 2 - 4 * 20 / 2",
false,
VAL(-37) },
74 {
"(1)",
false,
VAL(1) },
76 {
"-(1 + (2 - 4)) * 20.8 / 2",
false,
VAL(10.4) },
78 {
"+2 - 1",
false,
VAL(1) }
83 {
"A.type == 'Pad' && B.type == 'Pad' && (A.existsOnLayer('F.Cu'))",
false,
VAL( 0.0 ) },
84 {
"A.Width > B.Width",
false,
VAL( 0.0 ) },
86 {
"A.Netclass",
false,
VAL(
"HV" ) },
87 {
"(A.Netclass == 'HV') && (B.netclass == 'otherClass') && (B.netclass != 'F.Cu')",
false,
89 {
"A.Netclass + 1.0",
false,
VAL( 1.0 ) },
90 {
"A.type == 'Track' && B.type == 'Track' && A.layer == 'F.Cu'",
false,
VAL( 1.0 ) },
91 {
"(A.type == 'Track') && (B.type == 'Track') && (A.layer == 'F.Cu')",
false,
VAL( 1.0 ) },
92 {
"A.type == 'Via' && A.isMicroVia()",
false,
VAL(0.0) }
97 bool expectError =
false,
BOARD_ITEM* itemA =
nullptr,
111 bool error = !compiler.
Compile( expr, &ucode, &preflightContext );
115 if( error != expectError )
130 result = ucode.
Run( &context );
131 ok = ( result->
EqualTo( &context, &expectedResult ) );
149 testEvalExpr( expr.expression, expr.expectedResult, expr.expectError );
162 std::shared_ptr<NETCLASS> netclass1(
new NETCLASS(
"HV" ) );
163 std::shared_ptr<NETCLASS> netclass2(
new NETCLASS(
"otherClass" ) );
168 net1info->SetNetClass( netclass1 );
169 net2info->SetNetClass( netclass2 );
174 trackA.
SetNet( net1info );
175 trackB.
SetNet( net2info );
184 testEvalExpr( expr.expression, expr.expectedResult, expr.expectError, &trackA, &trackB );
constexpr EDA_IU_SCALE pcbIUScale
void SetNet(NETINFO_ITEM *aNetInfo)
Set a NET_INFO object for the item.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
Information pertinent to a Pcbnew printed circuit board.
const NETINFO_LIST & GetNetInfo() const
const ERROR_STATUS & GetError() const
bool Compile(const wxString &aString, UCODE *aCode, CONTEXT *aPreflightContext)
VALUE * Run(CONTEXT *ctx)
virtual const wxString & AsString() const
virtual double AsDouble() const
VAR_TYPE_T GetType() const
virtual bool EqualTo(CONTEXT *aCtx, const VALUE *b) const
A collection of nets and the parameters used to route or test these nets.
Handle the data for a net.
Container for NETINFO_ITEM elements, which are the nets.
void SetItems(BOARD_ITEM *a, BOARD_ITEM *b=nullptr)
virtual void SetWidth(int aWidth)
Provide class metadata.Helper macro to map type hashes to names.
static PROPERTY_MANAGER & Instance()
void Rebuild()
Rebuild the list of all registered properties.
constexpr int MilsToIU(int mils) const
friend std::ostream & operator<<(std::ostream &os, const EXPR_TO_TEST &expr)
LIBEVAL::VALUE expectedResult
BOOST_DATA_TEST_CASE(ConvertToKicadUnit, boost::unit_test::data::make(altium_to_kicad_unit), input_value, expected_result)
Test conversation from Altium internal units into KiCad internal units.
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_CHECK_EQUAL(ret, c.m_exp_result)
BOOST_AUTO_TEST_SUITE_END()
static const std::vector< EXPR_TO_TEST > simpleExpressions
static bool testEvalExpr(const wxString &expr, const LIBEVAL::VALUE &expectedResult, bool expectError=false, BOARD_ITEM *itemA=nullptr, BOARD_ITEM *itemB=nullptr)
static const std::vector< EXPR_TO_TEST > introspectionExpressions
BOOST_AUTO_TEST_CASE(IntrospectedProperties)
BOOST_TEST_MESSAGE("Polyline has "<< chain.PointCount()<< " points")