KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_libeval_compiler.cpp File Reference
#include <wx/wx.h>
#include <qa_utils/wx_utils/unit_test_utils.h>
#include <layer_ids.h>
#include <pcbnew/pcbexpr_evaluator.h>
#include <drc/drc_rule.h>
#include <pcbnew/board.h>
#include <pcbnew/pcb_track.h>

Go to the source code of this file.

Classes

struct  EXPR_TO_TEST
 

Typedefs

using VAL = LIBEVAL::VALUE
 

Functions

static bool testEvalExpr (const wxString &expr, const LIBEVAL::VALUE &expectedResult, bool expectError=false, BOARD_ITEM *itemA=nullptr, BOARD_ITEM *itemB=nullptr)
 
 BOOST_AUTO_TEST_CASE (SimpleExpressions)
 
 BOOST_AUTO_TEST_CASE (IntrospectedProperties)
 

Variables

static const std::vector< EXPR_TO_TESTsimpleExpressions
 
static const std::vector< EXPR_TO_TESTintrospectionExpressions
 

Typedef Documentation

◆ VAL

Definition at line 43 of file test_libeval_compiler.cpp.

Function Documentation

◆ BOOST_AUTO_TEST_CASE() [1/2]

◆ BOOST_AUTO_TEST_CASE() [2/2]

BOOST_AUTO_TEST_CASE ( SimpleExpressions  )

Definition at line 140 of file test_libeval_compiler.cpp.

References simpleExpressions, and testEvalExpr().

◆ testEvalExpr()

Variable Documentation

◆ introspectionExpressions

const std::vector<EXPR_TO_TEST> introspectionExpressions
static
Initial value:
= {
{ "A.type == 'Pad' && B.type == 'Pad' && (A.existsOnLayer('F.Cu'))", false, VAL( 0.0 ) },
{ "A.Width > B.Width", false, VAL( 0.0 ) },
{ "A.Width + B.Width", false, VAL( pcbIUScale.MilsToIU(10) + pcbIUScale.MilsToIU(20) ) },
{ "A.Netclass", false, VAL( "HV" ) },
{ "(A.Netclass == 'HV') && (B.netclass == 'otherClass') && (B.netclass != 'F.Cu')", false,
VAL( 1.0 ) },
{ "A.Netclass + 1.0", false, VAL( 1.0 ) },
{ "A.type == 'Track' && B.type == 'Track' && A.layer == 'F.Cu'", false, VAL( 1.0 ) },
{ "(A.type == 'Track') && (B.type == 'Track') && (A.layer == 'F.Cu')", false, VAL( 1.0 ) },
{ "A.type == 'Via' && A.isMicroVia()", false, VAL(0.0) }
}
constexpr EDA_IU_SCALE pcbIUScale
Definition: base_units.h:108
constexpr int MilsToIU(int mils) const
Definition: base_units.h:93
LIBEVAL::VALUE VAL

Definition at line 75 of file test_libeval_compiler.cpp.

Referenced by BOOST_AUTO_TEST_CASE().

◆ simpleExpressions

const std::vector<EXPR_TO_TEST> simpleExpressions
static
Initial value:
= {
{ "10mm + 20 mm", false, VAL( 30e6 ) },
{ "3*(7+8)", false, VAL( 3 * ( 7 + 8 ) ) },
{ "3*7+8", false, VAL( 3 * 7 + 8 ) },
{ "(3*7)+8", false, VAL( 3 * 7 + 8 ) },
{ "10mm + 20)", true, VAL( 0 ) },
{ "1", false, VAL(1) },
{ "1.5", false, VAL(1.5) },
{ "1,5", false, VAL(1.5) },
{ "1mm", false, VAL(1e6) },
{ " 1 + 2 ", false, VAL(3) },
{ "1.5 + 0.2 + 0.1", false, VAL(1.8) },
{ "3 - 10", false, VAL(-7) },
{ "1 + 2 + 10 + 1000.05", false, VAL(1013.05) },
{ "1 + 2 - 4 * 20 / 2", false, VAL(-37) },
{ "(1)", false, VAL(1) },
{ "-(1 + (2 - 4)) * 20.8 / 2", false, VAL(10.4) },
{ "+2 - 1", false, VAL(1) }
}

Definition at line 45 of file test_libeval_compiler.cpp.

Referenced by BOOST_AUTO_TEST_CASE().