165 lines
4.8 KiB
C++
165 lines
4.8 KiB
C++
#include "srd-preproc-cmd-common.hh"
|
|
|
|
|
|
class SRDPreprocCmdMiscTest : public CppUnit::TestFixture
|
|
{
|
|
CPPUNIT_TEST_SUITE( SRDPreprocCmdMiscTest );
|
|
|
|
CPPUNIT_TEST( testIgnore );
|
|
|
|
CPPUNIT_TEST( testUnwrapMissingArg );
|
|
CPPUNIT_TEST( testUnwrapBadArg );
|
|
CPPUNIT_TEST( testUnwrapEmptyList );
|
|
CPPUNIT_TEST( testUnwrapList );
|
|
CPPUNIT_TEST( testUnwrapExtraArgs );
|
|
|
|
CPPUNIT_TEST( testLengthMissingArg );
|
|
CPPUNIT_TEST( testLengthExtraArgs );
|
|
CPPUNIT_TEST( testLengthBadArg );
|
|
CPPUNIT_TEST( testLengthList );
|
|
CPPUNIT_TEST( testLengthWord );
|
|
CPPUNIT_TEST( testLengthString );
|
|
CPPUNIT_TEST( testLengthBinary );
|
|
|
|
CPPUNIT_TEST_SUITE_END( );
|
|
|
|
public:
|
|
void testIgnore( );
|
|
|
|
void testUnwrapMissingArg( );
|
|
void testUnwrapBadArg( );
|
|
void testUnwrapEmptyList( );
|
|
void testUnwrapList( );
|
|
void testUnwrapExtraArgs( );
|
|
|
|
void testLengthMissingArg( );
|
|
void testLengthExtraArgs( );
|
|
void testLengthBadArg( );
|
|
void testLengthList( );
|
|
void testLengthWord( );
|
|
void testLengthString( );
|
|
void testLengthBinary( );
|
|
};
|
|
CPPUNIT_TEST_SUITE_REGISTRATION( SRDPreprocCmdMiscTest );
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
void SRDPreprocCmdMiscTest::testIgnore( )
|
|
{
|
|
T_SRDErrors errors;
|
|
T_SRDList output( process( "( -ignore $does-not-exist ( -fail ) bleh )" , errors ) );
|
|
CPPUNIT_ASSERT_EQUAL( uint32_t( 0 ) , errors.size( ) );
|
|
CPPUNIT_ASSERT( check( "" , output ) );
|
|
}
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
void SRDPreprocCmdMiscTest::testUnwrapMissingArg( )
|
|
{
|
|
T_SRDErrors errors;
|
|
T_SRDList output( process( "( -unwrap )" , errors ) );
|
|
CPPUNIT_ASSERT_EQUAL( 2u , errors.size( ) );
|
|
M_CKERR_( 0 , "not enough arguments" , 1 , 3 );
|
|
M_CKERR_( 1 , "previous error cause" , 1 , 11 );
|
|
CPPUNIT_ASSERT( check( "" , output ) );
|
|
}
|
|
|
|
void SRDPreprocCmdMiscTest::testUnwrapBadArg( )
|
|
{
|
|
T_SRDErrors errors;
|
|
T_SRDList output( process( "( -unwrap a )" , errors ) );
|
|
CPPUNIT_ASSERT_EQUAL( 2u , errors.size( ) );
|
|
M_CKERR_( 0 , "list expected" , 1 , 3 );
|
|
M_CKERR_( 1 , "previous error cause" , 1 , 11 );
|
|
CPPUNIT_ASSERT( check( "" , output ) );
|
|
}
|
|
|
|
void SRDPreprocCmdMiscTest::testUnwrapEmptyList( )
|
|
{
|
|
T_SRDErrors errors;
|
|
T_SRDList output( process( "( -unwrap ( ) )" , errors ) );
|
|
CPPUNIT_ASSERT_EQUAL( uint32_t( 0 ) , errors.size( ) );
|
|
CPPUNIT_ASSERT( check( "" , output ) );
|
|
}
|
|
|
|
void SRDPreprocCmdMiscTest::testUnwrapList( )
|
|
{
|
|
T_SRDErrors errors;
|
|
T_SRDList output( process( "( -unwrap ( a b c ) )" , errors ) );
|
|
CPPUNIT_ASSERT_EQUAL( uint32_t( 0 ) , errors.size( ) );
|
|
CPPUNIT_ASSERT( check( "a b c" , output ) );
|
|
}
|
|
|
|
void SRDPreprocCmdMiscTest::testUnwrapExtraArgs( )
|
|
{
|
|
T_SRDErrors errors;
|
|
T_SRDList output( process( "( -unwrap ( a ) ( b c ) )" , errors ) );
|
|
CPPUNIT_ASSERT_EQUAL( 2u , errors.size( ) );
|
|
M_CKERR_( 0 , "too many arguments" , 1 , 3 );
|
|
M_CKERR_( 1 , "previous error cause" , 1 , 17 );
|
|
CPPUNIT_ASSERT( check( "a" , output ) );
|
|
}
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
void SRDPreprocCmdMiscTest::testLengthMissingArg( )
|
|
{
|
|
T_SRDErrors errors;
|
|
T_SRDList output( process( "( -length )" , errors ) );
|
|
CPPUNIT_ASSERT_EQUAL( 2u , errors.size( ) );
|
|
M_CKERR_( 0 , "not enough arguments" , 1 , 3 );
|
|
M_CKERR_( 1 , "previous error cause" , 1 , 11 );
|
|
CPPUNIT_ASSERT( check( "-1" , output ) );
|
|
}
|
|
|
|
void SRDPreprocCmdMiscTest::testLengthExtraArgs( )
|
|
{
|
|
T_SRDErrors errors;
|
|
T_SRDList output( process( "( -length a b c )" , errors ) );
|
|
CPPUNIT_ASSERT_EQUAL( 2u , errors.size( ) );
|
|
M_CKERR_( 0 , "too many arguments" , 1 , 3 );
|
|
M_CKERR_( 1 , "previous error cause" , 1 , 13 );
|
|
CPPUNIT_ASSERT( check( "1" , output ) );
|
|
}
|
|
|
|
void SRDPreprocCmdMiscTest::testLengthBadArg( )
|
|
{
|
|
T_SRDErrors errors;
|
|
T_SRDList output( process( "( -length 1 )" , errors ) );
|
|
CPPUNIT_ASSERT_EQUAL( 2u , errors.size( ) );
|
|
M_CKERR_( 0 , "list, word, string or binary array expected" , 1 , 3 );
|
|
M_CKERR_( 1 , "previous error cause" , 1 , 11 );
|
|
CPPUNIT_ASSERT( check( "-1" , output ) );
|
|
}
|
|
|
|
void SRDPreprocCmdMiscTest::testLengthList( )
|
|
{
|
|
T_SRDErrors errors;
|
|
T_SRDList output( process( "( -length ( a ( b ) ) )" , errors ) );
|
|
CPPUNIT_ASSERT_EQUAL( uint32_t( 0 ) , errors.size( ) );
|
|
CPPUNIT_ASSERT( check( "2" , output ) );
|
|
}
|
|
|
|
void SRDPreprocCmdMiscTest::testLengthWord( )
|
|
{
|
|
T_SRDErrors errors;
|
|
T_SRDList output( process( "( -length abc )" , errors ) );
|
|
CPPUNIT_ASSERT_EQUAL( uint32_t( 0 ) , errors.size( ) );
|
|
CPPUNIT_ASSERT( check( "3" , output ) );
|
|
}
|
|
|
|
void SRDPreprocCmdMiscTest::testLengthString( )
|
|
{
|
|
T_SRDErrors errors;
|
|
T_SRDList output( process( "( -length \"some string\" )" , errors ) );
|
|
CPPUNIT_ASSERT_EQUAL( uint32_t( 0 ) , errors.size( ) );
|
|
CPPUNIT_ASSERT( check( "11" , output ) );
|
|
}
|
|
|
|
void SRDPreprocCmdMiscTest::testLengthBinary( )
|
|
{
|
|
T_SRDErrors errors;
|
|
T_SRDList output( process( "( -length [ 01 02 03 ] )" , errors ) );
|
|
CPPUNIT_ASSERT_EQUAL( uint32_t( 0 ) , errors.size( ) );
|
|
CPPUNIT_ASSERT( check( "3" , output ) );
|
|
}
|