corelib/tests/srd-preproc-cmd-input.cc

544 lines
18 KiB
C++
Raw Normal View History

#include "srd-preproc-cmd-common.hh"
#include "srd-preproc-location.hh"
class SRDPreprocCmdInputTest : public CppUnit::TestFixture
{
CPPUNIT_TEST_SUITE( SRDPreprocCmdInputTest );
CPPUNIT_TEST( testFromSourceNoName );
CPPUNIT_TEST( testFromSourceNamed );
CPPUNIT_TEST( testFromSourceError );
CPPUNIT_TEST( testFromSourceErrorNamed );
CPPUNIT_TEST( testFromSourceTooManyErrors );
CPPUNIT_TEST( testFromSourceLocation );
CPPUNIT_TEST( testFromSourceLocationNamed );
CPPUNIT_TEST( testFromSourceLocationChaining );
CPPUNIT_TEST( testFromSourceLocationRewind );
CPPUNIT_TEST( testFromSourceLocationRewindTooMuch );
CPPUNIT_TEST( testFromSourceArgsNone );
CPPUNIT_TEST( testFromSourceArgsExtra );
CPPUNIT_TEST( testFromSourceArgsBadSource );
CPPUNIT_TEST( testFromSourceArgsBadName );
CPPUNIT_TEST( testFromSourceArgsBadChaining );
CPPUNIT_TEST( testFromSourceArgsBadRewind );
CPPUNIT_TEST( testFromSRBNoName );
CPPUNIT_TEST( testFromSRBNamed );
CPPUNIT_TEST( testFromSRBError );
CPPUNIT_TEST( testFromSRBErrorNamed );
CPPUNIT_TEST( testFromSRBLocation );
CPPUNIT_TEST( testFromSRBLocationNamed );
CPPUNIT_TEST( testFromSRBLocationChaining );
CPPUNIT_TEST( testFromSRBLocationRewind );
CPPUNIT_TEST( testFromSRBLocationRewindTooMuch );
CPPUNIT_TEST( testFromSRBArgsNone );
CPPUNIT_TEST( testFromSRBArgsExtra );
CPPUNIT_TEST( testFromSRBArgsBadInput );
CPPUNIT_TEST( testFromSRBArgsBadName );
CPPUNIT_TEST( testFromSRBArgsBadChaining );
CPPUNIT_TEST( testFromSRBArgsBadRewind );
CPPUNIT_TEST_SUITE_END( );
public:
void testFromSourceNoName( );
void testFromSourceNamed( );
void testFromSourceError( );
void testFromSourceErrorNamed( );
void testFromSourceTooManyErrors( );
void testFromSourceLocation( );
void testFromSourceLocationNamed( );
void testFromSourceLocationChaining( );
void testFromSourceLocationRewind( );
void testFromSourceLocationRewindTooMuch( );
void testFromSourceArgsNone( );
void testFromSourceArgsExtra( );
void testFromSourceArgsBadSource( );
void testFromSourceArgsBadName( );
void testFromSourceArgsBadChaining( );
void testFromSourceArgsBadRewind( );
void testFromSRBNoName( );
void testFromSRBNamed( );
void testFromSRBError( );
void testFromSRBErrorNamed( );
void testFromSRBLocation( );
void testFromSRBLocationNamed( );
void testFromSRBLocationChaining( );
void testFromSRBLocationRewind( );
void testFromSRBLocationRewindTooMuch( );
void testFromSRBArgsNone( );
void testFromSRBArgsExtra( );
void testFromSRBArgsBadInput( );
void testFromSRBArgsBadName( );
void testFromSRBArgsBadChaining( );
void testFromSRBArgsBadRewind( );
};
CPPUNIT_TEST_SUITE_REGISTRATION( SRDPreprocCmdInputTest );
/*----------------------------------------------------------------------------*/
void SRDPreprocCmdInputTest::testFromSourceNoName( )
{
T_SRDErrors errors;
T_SRDList output( process( "( -from-source \"word \\\"string\\\" 123 5000000000 1.2 $x ( some list )\" )" ,
errors ) );
CPPUNIT_ASSERT_EQUAL( uint32_t( 0 ) , errors.size( ) );
CPPUNIT_ASSERT( check( "word \"string\" 123 5000000000 1.2 $x ( some list )" , output ) );
}
void SRDPreprocCmdInputTest::testFromSourceNamed( )
{
T_SRDErrors errors;
T_SRDList output( process(
"( -from-source \"word \\\"string\\\" 123 5000000000 1.2 $x ( some list )\"\n"
"\"some_random_file.srd\" )" ,
errors ) );
CPPUNIT_ASSERT_EQUAL( uint32_t( 0 ) , errors.size( ) );
CPPUNIT_ASSERT( check( "word \"string\" 123 5000000000 1.2 $x ( some list )" , output ) );
}
void SRDPreprocCmdInputTest::testFromSourceError( )
{
T_SRDErrors errors;
T_SRDList output( process( "( -from-source\n\"( a\" )" , errors ) );
CPPUNIT_ASSERT_EQUAL( uint32_t( 1 ) , errors.size( ) );
M_CKERR_( 0 , "unterminated list" , 1 , 1 );
CPPUNIT_ASSERT( errors[ 0 ].location( ).source( ) == "-from-source" );
CPPUNIT_ASSERT( check( "( a )" , output ) );
}
void SRDPreprocCmdInputTest::testFromSourceErrorNamed( )
{
T_SRDErrors errors;
T_SRDList output( process( "( -from-source\n\"( a\" \"some_random_file.srd\" )" , errors ) );
CPPUNIT_ASSERT_EQUAL( uint32_t( 1 ) , errors.size( ) );
M_CKERR_( 0 , "unterminated list" , 1 , 1 );
CPPUNIT_ASSERT( errors[ 0 ].location( ).source( ) == "some_random_file.srd" );
CPPUNIT_ASSERT( check( "( a )" , output ) );
}
void SRDPreprocCmdInputTest::testFromSourceTooManyErrors( )
{
T_StringBuilder sb( "( -from-source \"" );
for ( auto i = 0u ; i < T_SRDErrors::MAX_ERRORS + 1 ; i ++ ) {
sb << "(\\u00a1";
}
sb << "\" )" << '\0';
try {
T_SRDErrors errors;
T_SRDList output( process( sb.data( ) , errors ) );
CPPUNIT_ASSERT_EQUAL( uint32_t( T_SRDErrors::MAX_ERRORS + 1 ) , errors.size( ) );
for ( auto i = 0u ; i < T_SRDErrors::MAX_ERRORS ; i ++ ) {
M_CKERR_( i , "unexpected character" , 1 , ( i + 1 ) * 2 );
}
M_CKERR_( T_SRDErrors::MAX_ERRORS , "too many errors" , 1 , 80 );
sb.clear( );
for ( auto i = 0u ; i < T_SRDErrors::MAX_ERRORS ; i ++ ) {
sb << '(';
}
for ( auto i = 0u ; i < T_SRDErrors::MAX_ERRORS ; i ++ ) {
sb << ')';
}
sb << '\0';
CPPUNIT_ASSERT( check( sb.data( ) , output ) );
} catch ( X_SRDErrors const& e ) {
auto const& errors( e.errors );
for ( auto i = 0u ; i < errors.size( ) ; i ++ ) {
M_PRINTERR_( i );
}
CPPUNIT_FAIL( "Shouldn't fail with exception" );
}
}
void SRDPreprocCmdInputTest::testFromSourceLocation( )
{
T_SRDErrors errors;
T_SRDList output( process( "( -from-source \"test\\ntest\" )" , errors ) );
CPPUNIT_ASSERT_EQUAL( uint32_t( 0 ) , errors.size( ) );
CPPUNIT_ASSERT( check( "test test" , output ) );
M_CKTOKDEPTH_( 0 , 1 );
M_CKTOKLOC_( 0 , "-from-source" , 1 , 1 );
M_CKTOKCHAIN_( 0 , 0 , GENERATED , "test" , 1 , 3 , 0 );
M_CKTOKDEPTH_( 1 , 1 );
M_CKTOKLOC_( 1 , "-from-source" , 2 , 1 );
M_CKTOKCHAIN_( 1 , 0 , GENERATED , "test" , 1 , 3 , 0 );
}
void SRDPreprocCmdInputTest::testFromSourceLocationNamed( )
{
T_SRDErrors errors;
T_SRDList output( process( "( -from-source \"test\\ntest\" \"test.srd\" )" , errors ) );
CPPUNIT_ASSERT_EQUAL( uint32_t( 0 ) , errors.size( ) );
CPPUNIT_ASSERT( check( "test test" , output ) );
M_CKTOKDEPTH_( 0 , 1 );
M_CKTOKLOC_( 0 , "test.srd" , 1 , 1 );
M_CKTOKCHAIN_( 0 , 0 , GENERATED , "test" , 1 , 3 , 0 );
M_CKTOKDEPTH_( 1 , 1 );
M_CKTOKLOC_( 1 , "test.srd" , 2 , 1 );
M_CKTOKCHAIN_( 1 , 0 , GENERATED , "test" , 1 , 3 , 0 );
}
void SRDPreprocCmdInputTest::testFromSourceLocationChaining( )
{
T_SRDErrors errors;
T_SRDList output( process( "( -from-source \"test\\ntest\" \"test.srd\" loaded )" , errors ) );
CPPUNIT_ASSERT_EQUAL( uint32_t( 0 ) , errors.size( ) );
CPPUNIT_ASSERT( check( "test test" , output ) );
M_CKTOKDEPTH_( 0 , 1 );
M_CKTOKLOC_( 0 , "test.srd" , 1 , 1 );
M_CKTOKCHAIN_( 0 , 0 , LOADED , "test" , 1 , 3 , 0 );
M_CKTOKDEPTH_( 1 , 1 );
M_CKTOKLOC_( 1 , "test.srd" , 2 , 1 );
M_CKTOKCHAIN_( 1 , 0 , LOADED , "test" , 1 , 3 , 0 );
}
void SRDPreprocCmdInputTest::testFromSourceLocationRewind( )
{
T_SRDErrors errors;
T_SRDList output( process(
"(-set doit ((-raw ()\n"
"( -from-source \"test\" \"test.srd\" loaded 2 )\n"
")))\n"
"(-set tfn ((-raw (x)\n"
"(-if (-lt $x 1) (\n"
"($doit)\n"
")(\n"
"($tfn (-sub $x 1))\n"
"))\n"
")))\n"
"(-bless tfn doit)\n"
"($tfn 5)" , errors ) );
CPPUNIT_ASSERT_EQUAL( uint32_t( 0 ) , errors.size( ) );
CPPUNIT_ASSERT( check( "test" , output ) );
M_CKTOKDEPTH_( 0 , 1 );
M_CKTOKLOC_( 0 , "test.srd" , 1 , 1 );
M_CKTOKCHAIN_( 0 , 0 , LOADED , "test" , 12 , 2 , 0 );
}
void SRDPreprocCmdInputTest::testFromSourceLocationRewindTooMuch( )
{
T_SRDErrors errors;
T_SRDList output( process( "( -from-source \"test\" \"test.srd\" loaded 2 )" , errors ) );
CPPUNIT_ASSERT_EQUAL( uint32_t( 0 ) , errors.size( ) );
CPPUNIT_ASSERT( check( "test" , output ) );
M_CKTOKDEPTH_( 0 , 1 );
M_CKTOKLOC_( 0 , "test.srd" , 1 , 1 );
M_CKTOKCHAIN_( 0 , 0 , LOADED , "test" , 1 , 3 , 0 );
}
/*----------------------------------------------------------------------------*/
void SRDPreprocCmdInputTest::testFromSourceArgsNone( )
{
T_SRDErrors errors;
T_SRDList output( process( "( -from-source )" , errors ) );
CPPUNIT_ASSERT_EQUAL( 2u , errors.size( ) );
M_CKERR_( 0 , "not enough arguments" , 1 , 3 );
M_CKERR_( 1 , "previous error cause" , 1 , 16 );
CPPUNIT_ASSERT( check( "" , output ) );
}
void SRDPreprocCmdInputTest::testFromSourceArgsExtra( )
{
T_SRDErrors errors;
T_SRDList output( process( "( -from-source \"x\" \"y\" generated 0 c )" , errors ) );
CPPUNIT_ASSERT_EQUAL( 2u , errors.size( ) );
M_CKERR_( 0 , "too many arguments" , 1 , 3 );
M_CKERR_( 1 , "previous error cause" , 1 , 36 );
CPPUNIT_ASSERT( check( "x" , output ) );
}
void SRDPreprocCmdInputTest::testFromSourceArgsBadSource( )
{
T_SRDErrors errors;
T_SRDList output( process( "( -from-source 12 )" , errors ) );
CPPUNIT_ASSERT_EQUAL( 2u , errors.size( ) );
M_CKERR_( 0 , "text argument expected" , 1 , 3 );
M_CKERR_( 1 , "previous error cause" , 1 , 16 );
CPPUNIT_ASSERT( check( "" , output ) );
}
void SRDPreprocCmdInputTest::testFromSourceArgsBadName( )
{
T_SRDErrors errors;
T_SRDList output( process(
"( -from-source \"test\"\n"
"12 )" ,
errors ) );
CPPUNIT_ASSERT_EQUAL( 2u , errors.size( ) );
M_CKERR_( 0 , "text argument expected" , 1 , 3 );
M_CKERR_( 1 , "previous error cause" , 2 , 1 );
CPPUNIT_ASSERT( check( "test" , output ) );
M_CKTOKDEPTH_( 0 , 1 );
M_CKTOKLOC_( 0 , "-from-source" , 1 , 1 );
M_CKTOKCHAIN_( 0 , 0 , GENERATED , "test" , 1 , 3 , 0 );
}
void SRDPreprocCmdInputTest::testFromSourceArgsBadChaining( )
{
T_SRDErrors errors;
T_SRDList output( process(
"( -from-source \"test\" \"test.srd\"\n"
"nope )\n"
"( -from-source \"test\" \"test2.srd\"\n"
"12 )\n" ,
errors ) );
CPPUNIT_ASSERT_EQUAL( 4u , errors.size( ) );
M_CKERR_( 0 , "'generated', 'included' or 'loaded' expected" , 1 , 3 );
M_CKERR_( 1 , "previous error cause" , 2 , 1 );
M_CKERR_( 2 , "'generated', 'included' or 'loaded' expected" , 3 , 3 );
M_CKERR_( 3 , "previous error cause" , 4 , 1 );
CPPUNIT_ASSERT( check( "test test" , output ) );
M_CKTOKDEPTH_( 0 , 1 );
M_CKTOKLOC_( 0 , "test.srd" , 1 , 1 );
M_CKTOKCHAIN_( 0 , 0 , GENERATED , "test" , 1 , 3 , 0 );
M_CKTOKDEPTH_( 1 , 1 );
M_CKTOKLOC_( 1 , "test2.srd" , 1 , 1 );
M_CKTOKCHAIN_( 1 , 0 , GENERATED , "test" , 3 , 3 , 0 );
}
void SRDPreprocCmdInputTest::testFromSourceArgsBadRewind( )
{
T_SRDErrors errors;
T_SRDList output( process(
"( -from-source \"test\" \"test.srd\" generated\n"
"-1 )\n"
"( -from-source \"test\" \"test2.srd\" generated\n"
"nope )\n" ,
errors ) );
CPPUNIT_ASSERT_EQUAL( 4u , errors.size( ) );
M_CKERR_( 0 , "invalid argument value" , 1 , 3 );
M_CKERR_( 1 , "previous error cause" , 2 , 1 );
M_CKERR_( 2 , "integer argument expected" , 3 , 3 );
M_CKERR_( 3 , "previous error cause" , 4 , 1 );
CPPUNIT_ASSERT( check( "test test" , output ) );
M_CKTOKDEPTH_( 0 , 1 );
M_CKTOKLOC_( 0 , "test.srd" , 1 , 1 );
M_CKTOKCHAIN_( 0 , 0 , GENERATED , "test" , 1 , 3 , 0 );
M_CKTOKDEPTH_( 1 , 1 );
M_CKTOKLOC_( 1 , "test2.srd" , 1 , 1 );
M_CKTOKCHAIN_( 1 , 0 , GENERATED , "test" , 3 , 3 , 0 );
}
/*----------------------------------------------------------------------------*/
#define SRB_PROLOGUE_ \
"ce a1 7c ea " \
"00 ee ff c0"
#define SRB_DATA_ \
"[ " \
SRB_PROLOGUE_ \
"02 03 00 00 00 4c 4f 4c" \
"00" \
"]"
/*----------------------------------------------------------------------------*/
void SRDPreprocCmdInputTest::testFromSRBNoName( )
{
T_SRDErrors errors;
T_SRDList output( process( "( -from-srb " SRB_DATA_ " )" , errors ) );
CPPUNIT_ASSERT_EQUAL( uint32_t( 0 ) , errors.size( ) );
CPPUNIT_ASSERT( check( "LOL" , output ) );
}
void SRDPreprocCmdInputTest::testFromSRBNamed( )
{
T_SRDErrors errors;
T_SRDList output( process(
"( -from-srb " SRB_DATA_ "\n"
"\"some_random_file.srb\" )" ,
errors ) );
CPPUNIT_ASSERT_EQUAL( uint32_t( 0 ) , errors.size( ) );
CPPUNIT_ASSERT( check( "LOL" , output ) );
}
void SRDPreprocCmdInputTest::testFromSRBError( )
{
T_SRDErrors errors;
T_SRDList output( process( "( -from-srb\n[ " SRB_PROLOGUE_ " ] )" , errors ) );
CPPUNIT_ASSERT_EQUAL( uint32_t( 1 ) , errors.size( ) );
M_CKERR_( 0 , "unexpected end of file" , 0 , 8 );
CPPUNIT_ASSERT( errors[ 0 ].location( ).source( ) == "-from-srb" );
CPPUNIT_ASSERT( check( "" , output ) );
}
void SRDPreprocCmdInputTest::testFromSRBErrorNamed( )
{
T_SRDErrors errors;
T_SRDList output( process(
"( -from-srb\n[ "
SRB_PROLOGUE_
" ] \"some_random_file.srb\" )" , errors ) );
CPPUNIT_ASSERT_EQUAL( uint32_t( 1 ) , errors.size( ) );
M_CKERR_( 0 , "unexpected end of file" , 0 , 8 );
CPPUNIT_ASSERT( errors[ 0 ].location( ).source( ) == "some_random_file.srb" );
CPPUNIT_ASSERT( check( "" , output ) );
}
void SRDPreprocCmdInputTest::testFromSRBLocation( )
{
T_SRDErrors errors;
T_SRDList output( process( "( -from-srb " SRB_DATA_ " )\n" , errors ) );
CPPUNIT_ASSERT_EQUAL( uint32_t( 0 ) , errors.size( ) );
CPPUNIT_ASSERT( check( "LOL" , output ) );
M_CKTOKDEPTH_( 0 , 1 );
M_CKTOKLOC_( 0 , "-from-srb" , 0 , 8 );
M_CKTOKCHAIN_( 0 , 0 , GENERATED , "test" , 1 , 3 , 0 );
}
void SRDPreprocCmdInputTest::testFromSRBLocationNamed( )
{
T_SRDErrors errors;
T_SRDList output( process( "( -from-srb " SRB_DATA_ " \"test.srb\" )" , errors ) );
CPPUNIT_ASSERT_EQUAL( uint32_t( 0 ) , errors.size( ) );
CPPUNIT_ASSERT( check( "LOL" , output ) );
M_CKTOKDEPTH_( 0 , 1 );
M_CKTOKLOC_( 0 , "test.srb" , 0 , 8 );
M_CKTOKCHAIN_( 0 , 0 , GENERATED , "test" , 1 , 3 , 0 );
}
void SRDPreprocCmdInputTest::testFromSRBLocationChaining( )
{
T_SRDErrors errors;
T_SRDList output( process( "( -from-srb " SRB_DATA_ " \"test.srb\" loaded )" , errors ) );
CPPUNIT_ASSERT_EQUAL( uint32_t( 0 ) , errors.size( ) );
CPPUNIT_ASSERT( check( "LOL" , output ) );
M_CKTOKDEPTH_( 0 , 1 );
M_CKTOKLOC_( 0 , "test.srb" , 0 , 8 );
M_CKTOKCHAIN_( 0 , 0 , LOADED , "test" , 1 , 3 , 0 );
}
void SRDPreprocCmdInputTest::testFromSRBLocationRewind( )
{
T_SRDErrors errors;
T_SRDList output( process(
"(-set doit ((-raw ()\n"
"( -from-srb " SRB_DATA_ " \"test.srb\" loaded 2 )\n"
")))\n"
"(-set tfn ((-raw (x)\n"
"(-if (-lt $x 1) (\n"
"($doit)\n"
")(\n"
"($tfn (-sub $x 1))\n"
"))\n"
")))\n"
"(-bless tfn doit)\n"
"($tfn 5)" , errors ) );
CPPUNIT_ASSERT_EQUAL( uint32_t( 0 ) , errors.size( ) );
CPPUNIT_ASSERT( check( "LOL" , output ) );
M_CKTOKDEPTH_( 0 , 1 );
M_CKTOKLOC_( 0 , "test.srb" , 0 , 8 );
M_CKTOKCHAIN_( 0 , 0 , LOADED , "test" , 12 , 2 , 0 );
}
void SRDPreprocCmdInputTest::testFromSRBLocationRewindTooMuch( )
{
T_SRDErrors errors;
T_SRDList output( process( "( -from-srb " SRB_DATA_ " \"test.srb\" loaded 2 )" , errors ) );
CPPUNIT_ASSERT_EQUAL( uint32_t( 0 ) , errors.size( ) );
CPPUNIT_ASSERT( check( "LOL" , output ) );
M_CKTOKDEPTH_( 0 , 1 );
M_CKTOKLOC_( 0 , "test.srb" , 0 , 8 );
M_CKTOKCHAIN_( 0 , 0 , LOADED , "test" , 1 , 3 , 0 );
}
/*----------------------------------------------------------------------------*/
void SRDPreprocCmdInputTest::testFromSRBArgsNone( )
{
T_SRDErrors errors;
T_SRDList output( process( "( -from-srb )" , errors ) );
CPPUNIT_ASSERT_EQUAL( 2u , errors.size( ) );
M_CKERR_( 0 , "not enough arguments" , 1 , 3 );
M_CKERR_( 1 , "previous error cause" , 1 , 13 );
CPPUNIT_ASSERT( check( "" , output ) );
}
void SRDPreprocCmdInputTest::testFromSRBArgsExtra( )
{
T_SRDErrors errors;
T_SRDList output( process( "( -from-srb " SRB_DATA_ " a loaded 0\nnope )" , errors ) );
CPPUNIT_ASSERT_EQUAL( 2u , errors.size( ) );
M_CKERR_( 0 , "too many arguments" , 1 , 3 );
M_CKERR_( 1 , "previous error cause" , 2 , 1 );
CPPUNIT_ASSERT( check( "LOL" , output ) );
}
void SRDPreprocCmdInputTest::testFromSRBArgsBadInput( )
{
T_SRDErrors errors;
T_SRDList output( process( "( -from-srb \"x\" )" , errors ) );
CPPUNIT_ASSERT_EQUAL( 2u , errors.size( ) );
M_CKERR_( 0 , "binary array argument expected" , 1 , 3 );
M_CKERR_( 1 , "previous error cause" , 1 , 13 );
CPPUNIT_ASSERT( check( "" , output ) );
}
void SRDPreprocCmdInputTest::testFromSRBArgsBadName( )
{
T_SRDErrors errors;
T_SRDList output( process(
"( -from-srb " SRB_DATA_ "\n12 )" ,
errors ) );
CPPUNIT_ASSERT_EQUAL( 2u , errors.size( ) );
M_CKERR_( 0 , "text argument expected" , 1 , 3 );
M_CKERR_( 1 , "previous error cause" , 2 , 1 );
CPPUNIT_ASSERT( check( "LOL" , output ) );
}
void SRDPreprocCmdInputTest::testFromSRBArgsBadChaining( )
{
T_SRDErrors errors;
T_SRDList output( process(
"( -from-srb " SRB_DATA_ " \"test.srb\"\n"
"nope )\n"
"( -from-srb " SRB_DATA_ " \"test2.srb\"\n"
"12 )\n" ,
errors ) );
CPPUNIT_ASSERT_EQUAL( 4u , errors.size( ) );
M_CKERR_( 0 , "'generated', 'included' or 'loaded' expected" , 1 , 3 );
M_CKERR_( 1 , "previous error cause" , 2 , 1 );
M_CKERR_( 2 , "'generated', 'included' or 'loaded' expected" , 3 , 3 );
M_CKERR_( 3 , "previous error cause" , 4 , 1 );
CPPUNIT_ASSERT( check( "LOL LOL" , output ) );
M_CKTOKDEPTH_( 0 , 1 );
M_CKTOKLOC_( 0 , "test.srb" , 0 , 8 );
M_CKTOKCHAIN_( 0 , 0 , GENERATED , "test" , 1 , 3 , 0 );
M_CKTOKDEPTH_( 1 , 1 );
M_CKTOKLOC_( 1 , "test2.srb" , 0 , 8 );
M_CKTOKCHAIN_( 1 , 0 , GENERATED , "test" , 3 , 3 , 0 );
}
void SRDPreprocCmdInputTest::testFromSRBArgsBadRewind( )
{
T_SRDErrors errors;
T_SRDList output( process(
"( -from-srb " SRB_DATA_ " \"test.srd\" generated\n"
"-1 )\n"
"( -from-srb " SRB_DATA_ " \"test2.srd\" generated\n"
"nope )\n" ,
errors ) );
CPPUNIT_ASSERT_EQUAL( 4u , errors.size( ) );
M_CKERR_( 0 , "invalid argument value" , 1 , 3 );
M_CKERR_( 1 , "previous error cause" , 2 , 1 );
M_CKERR_( 2 , "integer argument expected" , 3 , 3 );
M_CKERR_( 3 , "previous error cause" , 4 , 1 );
CPPUNIT_ASSERT( check( "LOL LOL" , output ) );
M_CKTOKDEPTH_( 0 , 1 );
M_CKTOKLOC_( 0 , "test.srd" , 0 , 8 );
M_CKTOKCHAIN_( 0 , 0 , GENERATED , "test" , 1 , 3 , 0 );
M_CKTOKDEPTH_( 1 , 1 );
M_CKTOKLOC_( 1 , "test2.srd" , 0 , 8 );
M_CKTOKCHAIN_( 1 , 0 , GENERATED , "test" , 3 , 3 , 0 );
}