610 lines
17 KiB
C++
610 lines
17 KiB
C++
|
#include "srd-preproc-cmd-common.hh"
|
||
|
|
||
|
|
||
|
class SRDPreprocCmdLogicTest : public CppUnit::TestFixture
|
||
|
{
|
||
|
CPPUNIT_TEST_SUITE( SRDPreprocCmdLogicTest );
|
||
|
|
||
|
CPPUNIT_TEST( testNotNoArgs );
|
||
|
CPPUNIT_TEST( testNotTooManyArgs );
|
||
|
CPPUNIT_TEST( testNotBadArg );
|
||
|
CPPUNIT_TEST( testNotZero );
|
||
|
CPPUNIT_TEST( testNotNonZeroInt );
|
||
|
CPPUNIT_TEST( testNotNonZeroLong );
|
||
|
|
||
|
CPPUNIT_TEST( testBwNotNoArgs );
|
||
|
CPPUNIT_TEST( testBwNotTooManyArgs );
|
||
|
CPPUNIT_TEST( testBwNotBadArg );
|
||
|
CPPUNIT_TEST( testBwNotInt );
|
||
|
CPPUNIT_TEST( testBwNotLong );
|
||
|
|
||
|
CPPUNIT_TEST( testAndNoArgs );
|
||
|
CPPUNIT_TEST( testAndBadArgs );
|
||
|
CPPUNIT_TEST( testAnd00 );
|
||
|
CPPUNIT_TEST( testAnd01 );
|
||
|
CPPUNIT_TEST( testAnd10 );
|
||
|
CPPUNIT_TEST( testAnd11 );
|
||
|
CPPUNIT_TEST( testAndMultiple );
|
||
|
CPPUNIT_TEST( testAndLong );
|
||
|
CPPUNIT_TEST( testAndSillyValues );
|
||
|
|
||
|
CPPUNIT_TEST( testBwAndNoArgs );
|
||
|
CPPUNIT_TEST( testBwAndBadArgs );
|
||
|
CPPUNIT_TEST( testBwAndInts );
|
||
|
CPPUNIT_TEST( testBwAndLongs );
|
||
|
CPPUNIT_TEST( testBwAndMultiple );
|
||
|
|
||
|
CPPUNIT_TEST( testOrNoArgs );
|
||
|
CPPUNIT_TEST( testOrBadArgs );
|
||
|
CPPUNIT_TEST( testOr00 );
|
||
|
CPPUNIT_TEST( testOr01 );
|
||
|
CPPUNIT_TEST( testOr10 );
|
||
|
CPPUNIT_TEST( testOr11 );
|
||
|
CPPUNIT_TEST( testOrMultiple );
|
||
|
CPPUNIT_TEST( testOrLong );
|
||
|
CPPUNIT_TEST( testOrSillyValues );
|
||
|
|
||
|
CPPUNIT_TEST( testBwOrNoArgs );
|
||
|
CPPUNIT_TEST( testBwOrBadArgs );
|
||
|
CPPUNIT_TEST( testBwOrInts );
|
||
|
CPPUNIT_TEST( testBwOrLongs );
|
||
|
CPPUNIT_TEST( testBwOrMultiple );
|
||
|
|
||
|
CPPUNIT_TEST( testXorNoArgs );
|
||
|
CPPUNIT_TEST( testXorBadArgs );
|
||
|
CPPUNIT_TEST( testXor00 );
|
||
|
CPPUNIT_TEST( testXor01 );
|
||
|
CPPUNIT_TEST( testXor10 );
|
||
|
CPPUNIT_TEST( testXor11 );
|
||
|
CPPUNIT_TEST( testXorMultiple );
|
||
|
CPPUNIT_TEST( testXorLong );
|
||
|
CPPUNIT_TEST( testXorSillyValues );
|
||
|
|
||
|
CPPUNIT_TEST( testBwXorNoArgs );
|
||
|
CPPUNIT_TEST( testBwXorBadArgs );
|
||
|
CPPUNIT_TEST( testBwXorInts );
|
||
|
CPPUNIT_TEST( testBwXorLongs );
|
||
|
CPPUNIT_TEST( testBwXorMultiple );
|
||
|
|
||
|
CPPUNIT_TEST_SUITE_END( );
|
||
|
|
||
|
public:
|
||
|
void testNotNoArgs( );
|
||
|
void testNotTooManyArgs( );
|
||
|
void testNotBadArg( );
|
||
|
void testNotZero( );
|
||
|
void testNotNonZeroInt( );
|
||
|
void testNotNonZeroLong( );
|
||
|
|
||
|
void testBwNotNoArgs( );
|
||
|
void testBwNotTooManyArgs( );
|
||
|
void testBwNotBadArg( );
|
||
|
void testBwNotInt( );
|
||
|
void testBwNotLong( );
|
||
|
|
||
|
void testAndNoArgs( );
|
||
|
void testAndBadArgs( );
|
||
|
void testAnd00( );
|
||
|
void testAnd01( );
|
||
|
void testAnd10( );
|
||
|
void testAnd11( );
|
||
|
void testAndMultiple( );
|
||
|
void testAndLong( );
|
||
|
void testAndSillyValues( );
|
||
|
|
||
|
void testBwAndNoArgs( );
|
||
|
void testBwAndBadArgs( );
|
||
|
void testBwAndInts( );
|
||
|
void testBwAndLongs( );
|
||
|
void testBwAndMultiple( );
|
||
|
|
||
|
void testOrNoArgs( );
|
||
|
void testOrBadArgs( );
|
||
|
void testOr00( );
|
||
|
void testOr01( );
|
||
|
void testOr10( );
|
||
|
void testOr11( );
|
||
|
void testOrMultiple( );
|
||
|
void testOrLong( );
|
||
|
void testOrSillyValues( );
|
||
|
|
||
|
void testBwOrNoArgs( );
|
||
|
void testBwOrBadArgs( );
|
||
|
void testBwOrInts( );
|
||
|
void testBwOrLongs( );
|
||
|
void testBwOrMultiple( );
|
||
|
|
||
|
void testXorNoArgs( );
|
||
|
void testXorBadArgs( );
|
||
|
void testXor00( );
|
||
|
void testXor01( );
|
||
|
void testXor10( );
|
||
|
void testXor11( );
|
||
|
void testXorMultiple( );
|
||
|
void testXorLong( );
|
||
|
void testXorSillyValues( );
|
||
|
|
||
|
void testBwXorNoArgs( );
|
||
|
void testBwXorBadArgs( );
|
||
|
void testBwXorInts( );
|
||
|
void testBwXorLongs( );
|
||
|
void testBwXorMultiple( );
|
||
|
};
|
||
|
CPPUNIT_TEST_SUITE_REGISTRATION( SRDPreprocCmdLogicTest );
|
||
|
|
||
|
/*----------------------------------------------------------------------------*/
|
||
|
|
||
|
void SRDPreprocCmdLogicTest::testNotNoArgs( )
|
||
|
{
|
||
|
T_SRDErrors errors;
|
||
|
T_SRDList output( process( "( -not )" , errors ) );
|
||
|
CPPUNIT_ASSERT_EQUAL( 2u , errors.size( ) );
|
||
|
M_CKERR_( 0 , "not enough arguments" , 1 , 3 );
|
||
|
M_CKERR_( 1 , "previous error cause" , 1 , 8 );
|
||
|
CPPUNIT_ASSERT( check( "0" , output ) );
|
||
|
}
|
||
|
|
||
|
void SRDPreprocCmdLogicTest::testNotTooManyArgs( )
|
||
|
{
|
||
|
T_SRDErrors errors;
|
||
|
T_SRDList output( process( "( -not 0 2 )" , errors ) );
|
||
|
CPPUNIT_ASSERT_EQUAL( 2u , errors.size( ) );
|
||
|
M_CKERR_( 0 , "too many arguments" , 1 , 3 );
|
||
|
M_CKERR_( 1 , "previous error cause" , 1 , 10 );
|
||
|
CPPUNIT_ASSERT( check( "1" , output ) );
|
||
|
}
|
||
|
|
||
|
void SRDPreprocCmdLogicTest::testNotBadArg( )
|
||
|
{
|
||
|
T_SRDErrors errors;
|
||
|
T_SRDList output( process( "( -not 0. )" , errors ) );
|
||
|
CPPUNIT_ASSERT_EQUAL( 2u , errors.size( ) );
|
||
|
M_CKERR_( 0 , "integer argument expected" , 1 , 3 );
|
||
|
M_CKERR_( 1 , "previous error cause" , 1 , 8 );
|
||
|
CPPUNIT_ASSERT( check( "1" , output ) );
|
||
|
}
|
||
|
|
||
|
void SRDPreprocCmdLogicTest::testNotZero( )
|
||
|
{
|
||
|
T_SRDErrors errors;
|
||
|
T_SRDList output( process( "( -not 0 )" , errors ) );
|
||
|
CPPUNIT_ASSERT_EQUAL( uint32_t( 0 ) , errors.size( ) );
|
||
|
CPPUNIT_ASSERT( check( "1" , output ) );
|
||
|
}
|
||
|
|
||
|
void SRDPreprocCmdLogicTest::testNotNonZeroInt( )
|
||
|
{
|
||
|
T_SRDErrors errors;
|
||
|
T_SRDList output( process( "( -not 12 )" , errors ) );
|
||
|
CPPUNIT_ASSERT_EQUAL( uint32_t( 0 ) , errors.size( ) );
|
||
|
CPPUNIT_ASSERT( check( "0" , output ) );
|
||
|
}
|
||
|
|
||
|
void SRDPreprocCmdLogicTest::testNotNonZeroLong( )
|
||
|
{
|
||
|
T_SRDErrors errors;
|
||
|
T_SRDList output( process( "(-set x ( -not 12000000000 ))(-to-integer $x)(-type-of $x)" , errors ) );
|
||
|
CPPUNIT_ASSERT_EQUAL( uint32_t( 0 ) , errors.size( ) );
|
||
|
CPPUNIT_ASSERT( check( "0 long" , output ) );
|
||
|
}
|
||
|
|
||
|
/*----------------------------------------------------------------------------*/
|
||
|
|
||
|
void SRDPreprocCmdLogicTest::testBwNotNoArgs( )
|
||
|
{
|
||
|
T_SRDErrors errors;
|
||
|
T_SRDList output( process( "( -bw-not )" , 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( "0" , output ) );
|
||
|
}
|
||
|
|
||
|
void SRDPreprocCmdLogicTest::testBwNotTooManyArgs( )
|
||
|
{
|
||
|
T_SRDErrors errors;
|
||
|
T_SRDList output( process( "( -bw-not 1 2 )" , 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( "-2" , output ) );
|
||
|
}
|
||
|
|
||
|
void SRDPreprocCmdLogicTest::testBwNotBadArg( )
|
||
|
{
|
||
|
T_SRDErrors errors;
|
||
|
T_SRDList output( process( "( -bw-not 2.2 )" , errors ) );
|
||
|
CPPUNIT_ASSERT_EQUAL( 2u , errors.size( ) );
|
||
|
M_CKERR_( 0 , "integer argument expected" , 1 , 3 );
|
||
|
M_CKERR_( 1 , "previous error cause" , 1 , 11 );
|
||
|
CPPUNIT_ASSERT( check( "-3" , output ) );
|
||
|
}
|
||
|
|
||
|
void SRDPreprocCmdLogicTest::testBwNotInt( )
|
||
|
{
|
||
|
T_SRDErrors errors;
|
||
|
T_SRDList output( process( "( -bw-not 129 )" , errors ) );
|
||
|
CPPUNIT_ASSERT_EQUAL( uint32_t( 0 ) , errors.size( ) );
|
||
|
CPPUNIT_ASSERT( check( "-130" , output ) );
|
||
|
}
|
||
|
|
||
|
void SRDPreprocCmdLogicTest::testBwNotLong( )
|
||
|
{
|
||
|
T_SRDErrors errors;
|
||
|
T_SRDList output( process( "( -bw-not 12000000000 )" , errors ) );
|
||
|
CPPUNIT_ASSERT_EQUAL( uint32_t( 0 ) , errors.size( ) );
|
||
|
CPPUNIT_ASSERT( check( "-12000000001" , output ) );
|
||
|
}
|
||
|
|
||
|
/*----------------------------------------------------------------------------*/
|
||
|
|
||
|
void SRDPreprocCmdLogicTest::testAndNoArgs( )
|
||
|
{
|
||
|
T_SRDErrors errors;
|
||
|
T_SRDList output( process( "( -and )" , errors ) );
|
||
|
CPPUNIT_ASSERT_EQUAL( 2u , errors.size( ) );
|
||
|
M_CKERR_( 0 , "not enough arguments" , 1 , 3 );
|
||
|
M_CKERR_( 1 , "previous error cause" , 1 , 8 );
|
||
|
CPPUNIT_ASSERT( check( "0" , output ) );
|
||
|
}
|
||
|
|
||
|
void SRDPreprocCmdLogicTest::testAndBadArgs( )
|
||
|
{
|
||
|
T_SRDErrors errors;
|
||
|
T_SRDList output( process( "( -and 1 1. ( ) )" , errors ) );
|
||
|
CPPUNIT_ASSERT_EQUAL( 2u , errors.size( ) );
|
||
|
M_CKERR_( 0 , "integer argument expected" , 1 , 3 );
|
||
|
M_CKERR_( 1 , "previous error cause" , 1 , 10 );
|
||
|
CPPUNIT_ASSERT( check( "1" , output ) );
|
||
|
}
|
||
|
|
||
|
void SRDPreprocCmdLogicTest::testAnd00( )
|
||
|
{
|
||
|
T_SRDErrors errors;
|
||
|
T_SRDList output( process( "( -and 0 0 )" , errors ) );
|
||
|
CPPUNIT_ASSERT_EQUAL( 0u , errors.size( ) );
|
||
|
CPPUNIT_ASSERT( check( "0" , output ) );
|
||
|
}
|
||
|
|
||
|
void SRDPreprocCmdLogicTest::testAnd01( )
|
||
|
{
|
||
|
T_SRDErrors errors;
|
||
|
T_SRDList output( process( "( -and 0 1 )" , errors ) );
|
||
|
CPPUNIT_ASSERT_EQUAL( 0u , errors.size( ) );
|
||
|
CPPUNIT_ASSERT( check( "0" , output ) );
|
||
|
}
|
||
|
|
||
|
void SRDPreprocCmdLogicTest::testAnd10( )
|
||
|
{
|
||
|
T_SRDErrors errors;
|
||
|
T_SRDList output( process( "( -and 1 0 )" , errors ) );
|
||
|
CPPUNIT_ASSERT_EQUAL( 0u , errors.size( ) );
|
||
|
CPPUNIT_ASSERT( check( "0" , output ) );
|
||
|
}
|
||
|
|
||
|
void SRDPreprocCmdLogicTest::testAnd11( )
|
||
|
{
|
||
|
T_SRDErrors errors;
|
||
|
T_SRDList output( process( "( -and 1 1 )" , errors ) );
|
||
|
CPPUNIT_ASSERT_EQUAL( 0u , errors.size( ) );
|
||
|
CPPUNIT_ASSERT( check( "1" , output ) );
|
||
|
}
|
||
|
|
||
|
void SRDPreprocCmdLogicTest::testAndMultiple( )
|
||
|
{
|
||
|
T_SRDErrors errors;
|
||
|
T_SRDList output( process( "( -and 1 1 1 1 )( -and 1 0 1 1 )" , errors ) );
|
||
|
CPPUNIT_ASSERT_EQUAL( 0u , errors.size( ) );
|
||
|
CPPUNIT_ASSERT( check( "1 0" , output ) );
|
||
|
}
|
||
|
|
||
|
void SRDPreprocCmdLogicTest::testAndLong( )
|
||
|
{
|
||
|
T_SRDErrors errors;
|
||
|
T_SRDList output( process( "( -and 1 ( -to-long 1 ) )" , errors ) );
|
||
|
CPPUNIT_ASSERT_EQUAL( uint32_t( 0 ) , errors.size( ) );
|
||
|
CPPUNIT_ASSERT( check( "1" , output ) );
|
||
|
}
|
||
|
|
||
|
void SRDPreprocCmdLogicTest::testAndSillyValues( )
|
||
|
{
|
||
|
T_SRDErrors errors;
|
||
|
T_SRDList output( process( "( -and -42384 35845 )" , errors ) );
|
||
|
CPPUNIT_ASSERT_EQUAL( 0u , errors.size( ) );
|
||
|
CPPUNIT_ASSERT( check( "1" , output ) );
|
||
|
}
|
||
|
|
||
|
/*----------------------------------------------------------------------------*/
|
||
|
|
||
|
void SRDPreprocCmdLogicTest::testBwAndNoArgs( )
|
||
|
{
|
||
|
T_SRDErrors errors;
|
||
|
T_SRDList output( process( "( -bw-and )" , 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( "0" , output ) );
|
||
|
}
|
||
|
|
||
|
void SRDPreprocCmdLogicTest::testBwAndBadArgs( )
|
||
|
{
|
||
|
T_SRDErrors errors;
|
||
|
T_SRDList output( process( "( -bw-and 1.2 ( ) )" , errors ) );
|
||
|
CPPUNIT_ASSERT_EQUAL( 2u , errors.size( ) );
|
||
|
M_CKERR_( 0 , "integer argument expected" , 1 , 3 );
|
||
|
M_CKERR_( 1 , "previous error cause" , 1 , 11 );
|
||
|
CPPUNIT_ASSERT( check( "1" , output ) );
|
||
|
}
|
||
|
|
||
|
void SRDPreprocCmdLogicTest::testBwAndInts( )
|
||
|
{
|
||
|
T_SRDErrors errors;
|
||
|
T_SRDList output( process( "( -bw-and 5 6 )" , errors ) );
|
||
|
CPPUNIT_ASSERT_EQUAL( 0u , errors.size( ) );
|
||
|
CPPUNIT_ASSERT( check( "4" , output ) );
|
||
|
}
|
||
|
|
||
|
void SRDPreprocCmdLogicTest::testBwAndLongs( )
|
||
|
{
|
||
|
T_SRDErrors errors;
|
||
|
T_SRDList output( process( "( -bw-and 12884901888 4294967296 )" , errors ) );
|
||
|
CPPUNIT_ASSERT_EQUAL( 0u , errors.size( ) );
|
||
|
CPPUNIT_ASSERT( check( "4294967296" , output ) );
|
||
|
}
|
||
|
|
||
|
void SRDPreprocCmdLogicTest::testBwAndMultiple( )
|
||
|
{
|
||
|
T_SRDErrors errors;
|
||
|
T_SRDList output( process( "( -bw-and 15 7 3 )" , errors ) );
|
||
|
CPPUNIT_ASSERT_EQUAL( 0u , errors.size( ) );
|
||
|
CPPUNIT_ASSERT( check( "3" , output ) );
|
||
|
}
|
||
|
|
||
|
/*----------------------------------------------------------------------------*/
|
||
|
|
||
|
void SRDPreprocCmdLogicTest::testOrNoArgs( )
|
||
|
{
|
||
|
T_SRDErrors errors;
|
||
|
T_SRDList output( process( "( -or )" , errors ) );
|
||
|
CPPUNIT_ASSERT_EQUAL( 2u , errors.size( ) );
|
||
|
M_CKERR_( 0 , "not enough arguments" , 1 , 3 );
|
||
|
M_CKERR_( 1 , "previous error cause" , 1 , 7 );
|
||
|
CPPUNIT_ASSERT( check( "0" , output ) );
|
||
|
}
|
||
|
|
||
|
void SRDPreprocCmdLogicTest::testOrBadArgs( )
|
||
|
{
|
||
|
T_SRDErrors errors;
|
||
|
T_SRDList output( process( "( -or 1 1. ( ) )" , errors ) );
|
||
|
CPPUNIT_ASSERT_EQUAL( 2u , errors.size( ) );
|
||
|
M_CKERR_( 0 , "integer argument expected" , 1 , 3 );
|
||
|
M_CKERR_( 1 , "previous error cause" , 1 , 9 );
|
||
|
CPPUNIT_ASSERT( check( "1" , output ) );
|
||
|
}
|
||
|
|
||
|
void SRDPreprocCmdLogicTest::testOr00( )
|
||
|
{
|
||
|
T_SRDErrors errors;
|
||
|
T_SRDList output( process( "( -or 0 0 )" , errors ) );
|
||
|
CPPUNIT_ASSERT_EQUAL( 0u , errors.size( ) );
|
||
|
CPPUNIT_ASSERT( check( "0" , output ) );
|
||
|
}
|
||
|
|
||
|
void SRDPreprocCmdLogicTest::testOr01( )
|
||
|
{
|
||
|
T_SRDErrors errors;
|
||
|
T_SRDList output( process( "( -or 0 1 )" , errors ) );
|
||
|
CPPUNIT_ASSERT_EQUAL( 0u , errors.size( ) );
|
||
|
CPPUNIT_ASSERT( check( "1" , output ) );
|
||
|
}
|
||
|
|
||
|
void SRDPreprocCmdLogicTest::testOr10( )
|
||
|
{
|
||
|
T_SRDErrors errors;
|
||
|
T_SRDList output( process( "( -or 1 0 )" , errors ) );
|
||
|
CPPUNIT_ASSERT_EQUAL( 0u , errors.size( ) );
|
||
|
CPPUNIT_ASSERT( check( "1" , output ) );
|
||
|
}
|
||
|
|
||
|
void SRDPreprocCmdLogicTest::testOr11( )
|
||
|
{
|
||
|
T_SRDErrors errors;
|
||
|
T_SRDList output( process( "( -or 1 1 )" , errors ) );
|
||
|
CPPUNIT_ASSERT_EQUAL( 0u , errors.size( ) );
|
||
|
CPPUNIT_ASSERT( check( "1" , output ) );
|
||
|
}
|
||
|
|
||
|
void SRDPreprocCmdLogicTest::testOrMultiple( )
|
||
|
{
|
||
|
T_SRDErrors errors;
|
||
|
T_SRDList output( process( "( -or 1 1 1 1 )( -or 1 0 1 1 )" , errors ) );
|
||
|
CPPUNIT_ASSERT_EQUAL( 0u , errors.size( ) );
|
||
|
CPPUNIT_ASSERT( check( "1 1" , output ) );
|
||
|
}
|
||
|
|
||
|
void SRDPreprocCmdLogicTest::testOrLong( )
|
||
|
{
|
||
|
T_SRDErrors errors;
|
||
|
T_SRDList output( process( "( -or 1 ( -to-long 1 ) )" , errors ) );
|
||
|
CPPUNIT_ASSERT_EQUAL( uint32_t( 0 ) , errors.size( ) );
|
||
|
CPPUNIT_ASSERT( check( "1" , output ) );
|
||
|
}
|
||
|
|
||
|
void SRDPreprocCmdLogicTest::testOrSillyValues( )
|
||
|
{
|
||
|
T_SRDErrors errors;
|
||
|
T_SRDList output( process( "( -or 0 35845 )" , errors ) );
|
||
|
CPPUNIT_ASSERT_EQUAL( 0u , errors.size( ) );
|
||
|
CPPUNIT_ASSERT( check( "1" , output ) );
|
||
|
}
|
||
|
|
||
|
/*----------------------------------------------------------------------------*/
|
||
|
|
||
|
void SRDPreprocCmdLogicTest::testBwOrNoArgs( )
|
||
|
{
|
||
|
T_SRDErrors errors;
|
||
|
T_SRDList output( process( "( -bw-or )" , errors ) );
|
||
|
CPPUNIT_ASSERT_EQUAL( 2u , errors.size( ) );
|
||
|
M_CKERR_( 0 , "not enough arguments" , 1 , 3 );
|
||
|
M_CKERR_( 1 , "previous error cause" , 1 , 10 );
|
||
|
CPPUNIT_ASSERT( check( "0" , output ) );
|
||
|
}
|
||
|
|
||
|
void SRDPreprocCmdLogicTest::testBwOrBadArgs( )
|
||
|
{
|
||
|
T_SRDErrors errors;
|
||
|
T_SRDList output( process( "( -bw-or 1.2 ( ) )" , errors ) );
|
||
|
CPPUNIT_ASSERT_EQUAL( 2u , errors.size( ) );
|
||
|
M_CKERR_( 0 , "integer argument expected" , 1 , 3 );
|
||
|
M_CKERR_( 1 , "previous error cause" , 1 , 10 );
|
||
|
CPPUNIT_ASSERT( check( "1" , output ) );
|
||
|
}
|
||
|
|
||
|
void SRDPreprocCmdLogicTest::testBwOrInts( )
|
||
|
{
|
||
|
T_SRDErrors errors;
|
||
|
T_SRDList output( process( "( -bw-or 5 6 )" , errors ) );
|
||
|
CPPUNIT_ASSERT_EQUAL( 0u , errors.size( ) );
|
||
|
CPPUNIT_ASSERT( check( "7" , output ) );
|
||
|
}
|
||
|
|
||
|
void SRDPreprocCmdLogicTest::testBwOrLongs( )
|
||
|
{
|
||
|
T_SRDErrors errors;
|
||
|
T_SRDList output( process( "( -bw-or 8589934592 4294967296 )" , errors ) );
|
||
|
CPPUNIT_ASSERT_EQUAL( 0u , errors.size( ) );
|
||
|
CPPUNIT_ASSERT( check( "12884901888" , output ) );
|
||
|
}
|
||
|
|
||
|
void SRDPreprocCmdLogicTest::testBwOrMultiple( )
|
||
|
{
|
||
|
T_SRDErrors errors;
|
||
|
T_SRDList output( process( "( -bw-or 2 4 8 6 )" , errors ) );
|
||
|
CPPUNIT_ASSERT_EQUAL( 0u , errors.size( ) );
|
||
|
CPPUNIT_ASSERT( check( "14" , output ) );
|
||
|
}
|
||
|
|
||
|
/*----------------------------------------------------------------------------*/
|
||
|
|
||
|
void SRDPreprocCmdLogicTest::testXorNoArgs( )
|
||
|
{
|
||
|
T_SRDErrors errors;
|
||
|
T_SRDList output( process( "( -xor )" , errors ) );
|
||
|
CPPUNIT_ASSERT_EQUAL( 2u , errors.size( ) );
|
||
|
M_CKERR_( 0 , "not enough arguments" , 1 , 3 );
|
||
|
M_CKERR_( 1 , "previous error cause" , 1 , 8 );
|
||
|
CPPUNIT_ASSERT( check( "0" , output ) );
|
||
|
}
|
||
|
|
||
|
void SRDPreprocCmdLogicTest::testXorBadArgs( )
|
||
|
{
|
||
|
T_SRDErrors errors;
|
||
|
T_SRDList output( process( "( -xor 1 1. ( ) )" , errors ) );
|
||
|
CPPUNIT_ASSERT_EQUAL( 2u , errors.size( ) );
|
||
|
M_CKERR_( 0 , "integer argument expected" , 1 , 3 );
|
||
|
M_CKERR_( 1 , "previous error cause" , 1 , 10 );
|
||
|
CPPUNIT_ASSERT( check( "0" , output ) );
|
||
|
}
|
||
|
|
||
|
void SRDPreprocCmdLogicTest::testXor00( )
|
||
|
{
|
||
|
T_SRDErrors errors;
|
||
|
T_SRDList output( process( "( -xor 0 0 )" , errors ) );
|
||
|
CPPUNIT_ASSERT_EQUAL( 0u , errors.size( ) );
|
||
|
CPPUNIT_ASSERT( check( "0" , output ) );
|
||
|
}
|
||
|
|
||
|
void SRDPreprocCmdLogicTest::testXor01( )
|
||
|
{
|
||
|
T_SRDErrors errors;
|
||
|
T_SRDList output( process( "( -xor 0 1 )" , errors ) );
|
||
|
CPPUNIT_ASSERT_EQUAL( 0u , errors.size( ) );
|
||
|
CPPUNIT_ASSERT( check( "1" , output ) );
|
||
|
}
|
||
|
|
||
|
void SRDPreprocCmdLogicTest::testXor10( )
|
||
|
{
|
||
|
T_SRDErrors errors;
|
||
|
T_SRDList output( process( "( -xor 1 0 )" , errors ) );
|
||
|
CPPUNIT_ASSERT_EQUAL( 0u , errors.size( ) );
|
||
|
CPPUNIT_ASSERT( check( "1" , output ) );
|
||
|
}
|
||
|
|
||
|
void SRDPreprocCmdLogicTest::testXor11( )
|
||
|
{
|
||
|
T_SRDErrors errors;
|
||
|
T_SRDList output( process( "( -xor 1 1 )" , errors ) );
|
||
|
CPPUNIT_ASSERT_EQUAL( 0u , errors.size( ) );
|
||
|
CPPUNIT_ASSERT( check( "0" , output ) );
|
||
|
}
|
||
|
|
||
|
void SRDPreprocCmdLogicTest::testXorMultiple( )
|
||
|
{
|
||
|
T_SRDErrors errors;
|
||
|
T_SRDList output( process( "( -xor 1 0 0 0 )( -xor 1 0 1 0 )" , errors ) );
|
||
|
CPPUNIT_ASSERT_EQUAL( 0u , errors.size( ) );
|
||
|
CPPUNIT_ASSERT( check( "1 0" , output ) );
|
||
|
}
|
||
|
|
||
|
void SRDPreprocCmdLogicTest::testXorLong( )
|
||
|
{
|
||
|
T_SRDErrors errors;
|
||
|
T_SRDList output( process( "( -xor 1 ( -to-long 1 ) )" , errors ) );
|
||
|
CPPUNIT_ASSERT_EQUAL( uint32_t( 0 ) , errors.size( ) );
|
||
|
CPPUNIT_ASSERT( check( "0" , output ) );
|
||
|
}
|
||
|
|
||
|
void SRDPreprocCmdLogicTest::testXorSillyValues( )
|
||
|
{
|
||
|
T_SRDErrors errors;
|
||
|
T_SRDList output( process( "( -xor 0 35845 )" , errors ) );
|
||
|
CPPUNIT_ASSERT_EQUAL( 0u , errors.size( ) );
|
||
|
CPPUNIT_ASSERT( check( "1" , output ) );
|
||
|
}
|
||
|
|
||
|
/*----------------------------------------------------------------------------*/
|
||
|
|
||
|
void SRDPreprocCmdLogicTest::testBwXorNoArgs( )
|
||
|
{
|
||
|
T_SRDErrors errors;
|
||
|
T_SRDList output( process( "( -bw-xor )" , 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( "0" , output ) );
|
||
|
}
|
||
|
|
||
|
void SRDPreprocCmdLogicTest::testBwXorBadArgs( )
|
||
|
{
|
||
|
T_SRDErrors errors;
|
||
|
T_SRDList output( process( "( -bw-xor 1.2 ( ) )" , errors ) );
|
||
|
CPPUNIT_ASSERT_EQUAL( 2u , errors.size( ) );
|
||
|
M_CKERR_( 0 , "integer argument expected" , 1 , 3 );
|
||
|
M_CKERR_( 1 , "previous error cause" , 1 , 11 );
|
||
|
CPPUNIT_ASSERT( check( "1" , output ) );
|
||
|
}
|
||
|
|
||
|
void SRDPreprocCmdLogicTest::testBwXorInts( )
|
||
|
{
|
||
|
T_SRDErrors errors;
|
||
|
T_SRDList output( process( "( -bw-xor 5 6 )" , errors ) );
|
||
|
CPPUNIT_ASSERT_EQUAL( 0u , errors.size( ) );
|
||
|
CPPUNIT_ASSERT( check( "3" , output ) );
|
||
|
}
|
||
|
|
||
|
void SRDPreprocCmdLogicTest::testBwXorLongs( )
|
||
|
{
|
||
|
T_SRDErrors errors;
|
||
|
T_SRDList output( process( "( -bw-xor 21474836480 25769803776 )" , errors ) );
|
||
|
CPPUNIT_ASSERT_EQUAL( 0u , errors.size( ) );
|
||
|
CPPUNIT_ASSERT( check( "12884901888" , output ) );
|
||
|
}
|
||
|
|
||
|
void SRDPreprocCmdLogicTest::testBwXorMultiple( )
|
||
|
{
|
||
|
T_SRDErrors errors;
|
||
|
T_SRDList output( process( "( -bw-xor 2 4 8 6 )" , errors ) );
|
||
|
CPPUNIT_ASSERT_EQUAL( 0u , errors.size( ) );
|
||
|
CPPUNIT_ASSERT( check( "8" , output ) );
|
||
|
}
|