KiCad PCB EDA Suite
test_altium_rule_transformer.cpp File Reference

Test suite for ALTIUM_RULE_TOKENIZER. More...

Go to the source code of this file.

Classes

struct  ALTIUM_RULE_TRANSFORMER_FIXTURE
 
struct  ALTIUM_RULE_TOKENIZER_INPUT_OUTPUT
 

Functions

 BOOST_AUTO_TEST_CASE (AltiumRuleTokenizerEmptyInput)
 Declares the struct as the Boost test fixture. More...
 
 BOOST_AUTO_TEST_CASE (AltiumRuleTokenizerOnlySpaces)
 
 BOOST_AUTO_TEST_CASE (AltiumRuleTokenizerSingleCharIdentifier)
 
 BOOST_AUTO_TEST_CASE (AltiumRuleTokenizerParameterizedTest)
 Test conversation from wxString to Altium tokens. More...
 

Variables

static const std::vector< ALTIUM_RULE_TOKENIZER_INPUT_OUTPUTaltium_rule_tokens_property
 A list of valid test strings and the expected results. More...
 

Detailed Description

Test suite for ALTIUM_RULE_TOKENIZER.

Definition in file test_altium_rule_transformer.cpp.

Function Documentation

◆ BOOST_AUTO_TEST_CASE() [1/4]

BOOST_AUTO_TEST_CASE ( AltiumRuleTokenizerEmptyInput  )

Declares the struct as the Boost test fixture.

Definition at line 45 of file test_altium_rule_transformer.cpp.

46{
47 ALTIUM_RULE_TOKENIZER tokenizer( "" );
48
49 const ALTIUM_RULE_TOKEN& peek = tokenizer.Peek();
51 BOOST_CHECK_EQUAL( 0, peek.pos );
52
53 const ALTIUM_RULE_TOKEN& next = tokenizer.Next();
55 BOOST_CHECK_EQUAL( 0, next.pos );
56
57 const ALTIUM_RULE_TOKEN& peek2 = tokenizer.Peek();
59 BOOST_CHECK_EQUAL( 0, peek2.pos );
60}
CITER next(CITER it)
Definition: ptree.cpp:126
ALTIUM_RULE_TOKEN_KIND kind
BOOST_CHECK(v2.Cross(v1)==1)

References BOOST_CHECK(), END_OF_EXPR, ALTIUM_RULE_TOKEN::kind, ALTIUM_RULE_TOKENIZER::Next(), next(), ALTIUM_RULE_TOKENIZER::Peek(), and ALTIUM_RULE_TOKEN::pos.

◆ BOOST_AUTO_TEST_CASE() [2/4]

BOOST_AUTO_TEST_CASE ( AltiumRuleTokenizerOnlySpaces  )

Definition at line 62 of file test_altium_rule_transformer.cpp.

63{
64 ALTIUM_RULE_TOKENIZER tokenizer( " " );
65
66 const ALTIUM_RULE_TOKEN& peek = tokenizer.Peek();
68 BOOST_CHECK_EQUAL( 3, peek.pos );
69
70 const ALTIUM_RULE_TOKEN& next = tokenizer.Next();
72 BOOST_CHECK_EQUAL( 3, next.pos );
73
74 const ALTIUM_RULE_TOKEN& peek2 = tokenizer.Peek();
76 BOOST_CHECK_EQUAL( 3, peek2.pos );
77}

References BOOST_CHECK(), END_OF_EXPR, ALTIUM_RULE_TOKEN::kind, ALTIUM_RULE_TOKENIZER::Next(), next(), ALTIUM_RULE_TOKENIZER::Peek(), and ALTIUM_RULE_TOKEN::pos.

◆ BOOST_AUTO_TEST_CASE() [3/4]

BOOST_AUTO_TEST_CASE ( AltiumRuleTokenizerParameterizedTest  )

Test conversation from wxString to Altium tokens.

Definition at line 367 of file test_altium_rule_transformer.cpp.

368{
369 for( const auto& c : altium_rule_tokens_property )
370 {
371 BOOST_TEST_CONTEXT( wxString::Format( wxT( "'%s'" ), c.input ) )
372 {
373 ALTIUM_RULE_TOKENIZER tokenizer( c.input );
374
375 for( const auto& expected : c.exp_token )
376 {
377 const ALTIUM_RULE_TOKEN& token = tokenizer.Next();
378 BOOST_CHECK( ( expected.kind == token.kind ) );
379 BOOST_CHECK_EQUAL( expected.pos, token.pos );
380 BOOST_CHECK_EQUAL( expected.iValue, token.iValue );
381 BOOST_CHECK_EQUAL( expected.fValue, token.fValue );
382 BOOST_CHECK_EQUAL( expected.sValue, token.sValue );
383 }
384 }
385 }
386}
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
static const std::vector< ALTIUM_RULE_TOKENIZER_INPUT_OUTPUT > altium_rule_tokens_property
A list of valid test strings and the expected results.
#define BOOST_TEST_CONTEXT(A)

References altium_rule_tokens_property, BOOST_CHECK(), BOOST_TEST_CONTEXT, Format(), ALTIUM_RULE_TOKEN::fValue, ALTIUM_RULE_TOKEN::iValue, ALTIUM_RULE_TOKEN::kind, ALTIUM_RULE_TOKENIZER::Next(), ALTIUM_RULE_TOKEN::pos, and ALTIUM_RULE_TOKEN::sValue.

◆ BOOST_AUTO_TEST_CASE() [4/4]

BOOST_AUTO_TEST_CASE ( AltiumRuleTokenizerSingleCharIdentifier  )

Definition at line 79 of file test_altium_rule_transformer.cpp.

80{
81 ALTIUM_RULE_TOKENIZER tokenizer( "a" );
82
83 const ALTIUM_RULE_TOKEN& next = tokenizer.Next();
85 BOOST_CHECK_EQUAL( 0, next.pos );
86 BOOST_CHECK_EQUAL( "a", next.sValue );
87
88 const ALTIUM_RULE_TOKEN& peek = tokenizer.Peek();
90 BOOST_CHECK_EQUAL( 1, peek.pos );
91
92 const ALTIUM_RULE_TOKEN& next2 = tokenizer.Next();
94 BOOST_CHECK_EQUAL( 1, next2.pos );
95}

References BOOST_CHECK(), END_OF_EXPR, IDENT, ALTIUM_RULE_TOKEN::kind, ALTIUM_RULE_TOKENIZER::Next(), next(), ALTIUM_RULE_TOKENIZER::Peek(), and ALTIUM_RULE_TOKEN::pos.

Variable Documentation

◆ altium_rule_tokens_property

const std::vector<ALTIUM_RULE_TOKENIZER_INPUT_OUTPUT> altium_rule_tokens_property
static

A list of valid test strings and the expected results.

Definition at line 107 of file test_altium_rule_transformer.cpp.

Referenced by BOOST_AUTO_TEST_CASE().