649 lines
17 KiB
C++
649 lines
17 KiB
C++
#include <lw/lib/Log.hh>
|
|
#include <cppunit/extensions/HelperMacros.h>
|
|
using namespace lw;
|
|
|
|
|
|
class LogLevelTest : public CppUnit::TestFixture
|
|
{
|
|
CPPUNIT_TEST_SUITE( LogLevelTest );
|
|
CPPUNIT_TEST( testToString );
|
|
CPPUNIT_TEST_SUITE_END( );
|
|
|
|
public:
|
|
void testToString( );
|
|
};
|
|
CPPUNIT_TEST_SUITE_REGISTRATION( LogLevelTest );
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
class LogPathTest : public CppUnit::TestFixture
|
|
{
|
|
CPPUNIT_TEST_SUITE( LogPathTest );
|
|
CPPUNIT_TEST( testEmpty );
|
|
|
|
CPPUNIT_TEST( testArrayCopy );
|
|
CPPUNIT_TEST( testArrayCopyEmpty );
|
|
CPPUNIT_TEST( testArrayCopyInvalidControl );
|
|
CPPUNIT_TEST( testArrayCopyInvalidSlash );
|
|
CPPUNIT_TEST( testArrayCopyInvalidEmpty );
|
|
|
|
CPPUNIT_TEST( testArrayMove );
|
|
CPPUNIT_TEST( testArrayMoveEmpty );
|
|
CPPUNIT_TEST( testArrayMoveInvalidControl );
|
|
CPPUNIT_TEST( testArrayMoveInvalidSlash );
|
|
CPPUNIT_TEST( testArrayMoveInvalidEmpty );
|
|
|
|
CPPUNIT_TEST( testInitList );
|
|
CPPUNIT_TEST( testInitListEmpty );
|
|
CPPUNIT_TEST( testInitListInvalidControl );
|
|
CPPUNIT_TEST( testInitListInvalidSlash );
|
|
CPPUNIT_TEST( testInitListInvalidEmpty );
|
|
|
|
CPPUNIT_TEST( testFromStringEmpty );
|
|
CPPUNIT_TEST( testFromStringSlash );
|
|
CPPUNIT_TEST( testFromStringSlashes );
|
|
CPPUNIT_TEST( testFromStringValid );
|
|
CPPUNIT_TEST( testFromStringValidSlashes );
|
|
CPPUNIT_TEST( testFromStringValidInitialSlash );
|
|
CPPUNIT_TEST( testFromStringValidTrailingSlash );
|
|
CPPUNIT_TEST( testFromStringInvalid );
|
|
|
|
CPPUNIT_TEST( testSwap );
|
|
|
|
CPPUNIT_TEST( testParentEmpty );
|
|
CPPUNIT_TEST( testParentOne );
|
|
CPPUNIT_TEST( testParentValid );
|
|
CPPUNIT_TEST( testParentInvalidChild );
|
|
CPPUNIT_TEST( testParentInvalid );
|
|
|
|
CPPUNIT_TEST( testChildValid );
|
|
CPPUNIT_TEST( testChildInvalidName );
|
|
CPPUNIT_TEST( testChildInvalidParent );
|
|
|
|
CPPUNIT_TEST( testToStringEmpty );
|
|
CPPUNIT_TEST( testToStringValid );
|
|
CPPUNIT_TEST( testToStringInvalidSlash );
|
|
CPPUNIT_TEST( testToStringInvalidControl );
|
|
CPPUNIT_TEST( testToStringInvalidEmpty );
|
|
|
|
CPPUNIT_TEST( testIsParentYes );
|
|
CPPUNIT_TEST( testIsParentNo );
|
|
CPPUNIT_TEST( testIsParentYesInvalidParent );
|
|
CPPUNIT_TEST( testIsParentYesInvalidChild );
|
|
CPPUNIT_TEST( testIsParentNoInvalidParent );
|
|
CPPUNIT_TEST( testIsParentNoInvalidChild );
|
|
|
|
CPPUNIT_TEST( testEquals );
|
|
CPPUNIT_TEST( testNotEquals );
|
|
CPPUNIT_TEST_SUITE_END( );
|
|
|
|
public:
|
|
void testEmpty( );
|
|
|
|
void testArrayCopy( );
|
|
void testArrayCopyEmpty( );
|
|
void testArrayCopyInvalidControl( );
|
|
void testArrayCopyInvalidSlash( );
|
|
void testArrayCopyInvalidEmpty( );
|
|
|
|
void testArrayMove( );
|
|
void testArrayMoveEmpty( );
|
|
void testArrayMoveInvalidControl( );
|
|
void testArrayMoveInvalidSlash( );
|
|
void testArrayMoveInvalidEmpty( );
|
|
|
|
void testInitList( );
|
|
void testInitListEmpty( );
|
|
void testInitListInvalidControl( );
|
|
void testInitListInvalidSlash( );
|
|
void testInitListInvalidEmpty( );
|
|
|
|
void testFromStringEmpty( );
|
|
void testFromStringSlash( );
|
|
void testFromStringSlashes( );
|
|
void testFromStringValid( );
|
|
void testFromStringValidSlashes( );
|
|
void testFromStringValidInitialSlash( );
|
|
void testFromStringValidTrailingSlash( );
|
|
void testFromStringInvalid( );
|
|
|
|
void testSwap( );
|
|
|
|
void testParentEmpty( );
|
|
void testParentOne( );
|
|
void testParentValid( );
|
|
void testParentInvalidChild( );
|
|
void testParentInvalid( );
|
|
|
|
void testChildValid( );
|
|
void testChildInvalidName( );
|
|
void testChildInvalidParent( );
|
|
|
|
void testToStringEmpty( );
|
|
void testToStringValid( );
|
|
void testToStringInvalidSlash( );
|
|
void testToStringInvalidControl( );
|
|
void testToStringInvalidEmpty( );
|
|
|
|
void testIsParentYes( );
|
|
void testIsParentNo( );
|
|
void testIsParentYesInvalidParent( );
|
|
void testIsParentYesInvalidChild( );
|
|
void testIsParentNoInvalidParent( );
|
|
void testIsParentNoInvalidChild( );
|
|
|
|
void testEquals( );
|
|
void testNotEquals( );
|
|
};
|
|
CPPUNIT_TEST_SUITE_REGISTRATION( LogPathTest );
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
void LogLevelTest::testToString( )
|
|
{
|
|
T_StringBuilder sb;
|
|
sb << E_LogLevel::TRACE << ' ' << E_LogLevel::DEBUG << ' '
|
|
<< E_LogLevel::INFO << ' ' << E_LogLevel::NOTICE << ' '
|
|
<< E_LogLevel::WARNING << ' ' << E_LogLevel::ERROR << ' '
|
|
<< E_LogLevel::CRITICAL;
|
|
|
|
T_String s( std::move( sb ) );
|
|
CPPUNIT_ASSERT( s == "trace debug info notice warning error critical" );
|
|
}
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
void LogPathTest::testEmpty( )
|
|
{
|
|
T_LogPath lp;
|
|
CPPUNIT_ASSERT( lp.isValid( ) );
|
|
CPPUNIT_ASSERT_EQUAL( uint32_t( 0 ) , lp.size( ) );
|
|
}
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
void LogPathTest::testArrayCopy( )
|
|
{
|
|
T_Array< T_String > test;
|
|
test.add( T_String::Pooled( "a" ) );
|
|
test.add( T_String::Pooled( "b" ) );
|
|
test.add( T_String::Pooled( "c" ) );
|
|
|
|
T_LogPath lp( test );
|
|
CPPUNIT_ASSERT( lp.isValid( ) );
|
|
CPPUNIT_ASSERT_EQUAL( uint32_t( 3 ) , lp.size( ) );
|
|
CPPUNIT_ASSERT( lp[ 0 ] == "a" );
|
|
CPPUNIT_ASSERT( lp[ 1 ] == "b" );
|
|
CPPUNIT_ASSERT( lp[ 2 ] == "c" );
|
|
}
|
|
|
|
void LogPathTest::testArrayCopyEmpty( )
|
|
{
|
|
T_Array< T_String > test;
|
|
T_LogPath lp( test );
|
|
CPPUNIT_ASSERT( lp.isValid( ) );
|
|
CPPUNIT_ASSERT_EQUAL( uint32_t( 0 ) , lp.size( ) );
|
|
}
|
|
|
|
void LogPathTest::testArrayCopyInvalidControl( )
|
|
{
|
|
T_Array< T_String > test;
|
|
test.add( T_String::Pooled( "a" ) );
|
|
test.add( T_String::Pooled( "b" ) );
|
|
test.add( T_String::Pooled( "c\n" ) );
|
|
|
|
T_LogPath lp( test );
|
|
CPPUNIT_ASSERT( !lp.isValid( ) );
|
|
CPPUNIT_ASSERT_EQUAL( uint32_t( 3 ) , lp.size( ) );
|
|
CPPUNIT_ASSERT( lp[ 0 ] == "a" );
|
|
CPPUNIT_ASSERT( lp[ 1 ] == "b" );
|
|
CPPUNIT_ASSERT( lp[ 2 ] == "c\n" );
|
|
}
|
|
|
|
void LogPathTest::testArrayCopyInvalidSlash( )
|
|
{
|
|
T_Array< T_String > test;
|
|
test.add( T_String::Pooled( "a" ) );
|
|
test.add( T_String::Pooled( "b" ) );
|
|
test.add( T_String::Pooled( "c/" ) );
|
|
|
|
T_LogPath lp( test );
|
|
CPPUNIT_ASSERT( !lp.isValid( ) );
|
|
CPPUNIT_ASSERT_EQUAL( uint32_t( 3 ) , lp.size( ) );
|
|
CPPUNIT_ASSERT( lp[ 0 ] == "a" );
|
|
CPPUNIT_ASSERT( lp[ 1 ] == "b" );
|
|
CPPUNIT_ASSERT( lp[ 2 ] == "c/" );
|
|
}
|
|
|
|
void LogPathTest::testArrayCopyInvalidEmpty( )
|
|
{
|
|
T_Array< T_String > test;
|
|
test.add( T_String::Pooled( "a" ) );
|
|
test.add( T_String::Pooled( "b" ) );
|
|
test.add( T_String::Pooled( "" ) );
|
|
|
|
T_LogPath lp( test );
|
|
CPPUNIT_ASSERT( !lp.isValid( ) );
|
|
CPPUNIT_ASSERT_EQUAL( uint32_t( 3 ) , lp.size( ) );
|
|
CPPUNIT_ASSERT( lp[ 0 ] == "a" );
|
|
CPPUNIT_ASSERT( lp[ 1 ] == "b" );
|
|
CPPUNIT_ASSERT( lp[ 2 ] == "" );
|
|
}
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
void LogPathTest::testArrayMove( )
|
|
{
|
|
T_Array< T_String > test;
|
|
test.add( T_String::Pooled( "a" ) );
|
|
test.add( T_String::Pooled( "b" ) );
|
|
test.add( T_String::Pooled( "c" ) );
|
|
|
|
RPC_String s0( &test[ 0 ] );
|
|
RPC_String s1( &test[ 1 ] );
|
|
RPC_String s2( &test[ 2 ] );
|
|
|
|
T_LogPath lp( std::move( test ) );
|
|
CPPUNIT_ASSERT( lp.isValid( ) );
|
|
CPPUNIT_ASSERT_EQUAL( uint32_t( 3 ) , lp.size( ) );
|
|
CPPUNIT_ASSERT( lp[ 0 ] == "a" );
|
|
CPPUNIT_ASSERT( lp[ 1 ] == "b" );
|
|
CPPUNIT_ASSERT( lp[ 2 ] == "c" );
|
|
CPPUNIT_ASSERT_EQUAL( s0 , &lp[ 0 ] );
|
|
CPPUNIT_ASSERT_EQUAL( s1 , &lp[ 1 ] );
|
|
CPPUNIT_ASSERT_EQUAL( s2 , &lp[ 2 ] );
|
|
}
|
|
|
|
void LogPathTest::testArrayMoveEmpty( )
|
|
{
|
|
T_Array< T_String > test;
|
|
T_LogPath lp( std::move( test ) );
|
|
CPPUNIT_ASSERT( lp.isValid( ) );
|
|
CPPUNIT_ASSERT_EQUAL( uint32_t( 0 ) , lp.size( ) );
|
|
}
|
|
|
|
void LogPathTest::testArrayMoveInvalidControl( )
|
|
{
|
|
T_Array< T_String > test;
|
|
test.add( T_String::Pooled( "a" ) );
|
|
test.add( T_String::Pooled( "b" ) );
|
|
test.add( T_String::Pooled( "c\n" ) );
|
|
|
|
T_LogPath lp( std::move( test ) );
|
|
CPPUNIT_ASSERT( !lp.isValid( ) );
|
|
CPPUNIT_ASSERT_EQUAL( uint32_t( 3 ) , lp.size( ) );
|
|
CPPUNIT_ASSERT( lp[ 0 ] == "a" );
|
|
CPPUNIT_ASSERT( lp[ 1 ] == "b" );
|
|
CPPUNIT_ASSERT( lp[ 2 ] == "c\n" );
|
|
}
|
|
|
|
void LogPathTest::testArrayMoveInvalidSlash( )
|
|
{
|
|
T_Array< T_String > test;
|
|
test.add( T_String::Pooled( "a" ) );
|
|
test.add( T_String::Pooled( "b" ) );
|
|
test.add( T_String::Pooled( "c/" ) );
|
|
|
|
T_LogPath lp( std::move( test ) );
|
|
CPPUNIT_ASSERT( !lp.isValid( ) );
|
|
CPPUNIT_ASSERT_EQUAL( uint32_t( 3 ) , lp.size( ) );
|
|
CPPUNIT_ASSERT( lp[ 0 ] == "a" );
|
|
CPPUNIT_ASSERT( lp[ 1 ] == "b" );
|
|
CPPUNIT_ASSERT( lp[ 2 ] == "c/" );
|
|
}
|
|
|
|
void LogPathTest::testArrayMoveInvalidEmpty( )
|
|
{
|
|
T_Array< T_String > test;
|
|
test.add( T_String::Pooled( "a" ) );
|
|
test.add( T_String::Pooled( "b" ) );
|
|
test.add( T_String::Pooled( "" ) );
|
|
|
|
T_LogPath lp( std::move( test ) );
|
|
CPPUNIT_ASSERT( !lp.isValid( ) );
|
|
CPPUNIT_ASSERT_EQUAL( uint32_t( 3 ) , lp.size( ) );
|
|
CPPUNIT_ASSERT( lp[ 0 ] == "a" );
|
|
CPPUNIT_ASSERT( lp[ 1 ] == "b" );
|
|
CPPUNIT_ASSERT( lp[ 2 ] == "" );
|
|
}
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
void LogPathTest::testInitList( )
|
|
{
|
|
T_LogPath lp{ "a" , "b" , "c" };
|
|
CPPUNIT_ASSERT( lp.isValid( ) );
|
|
CPPUNIT_ASSERT_EQUAL( uint32_t( 3 ) , lp.size( ) );
|
|
CPPUNIT_ASSERT( lp[ 0 ] == "a" );
|
|
CPPUNIT_ASSERT( lp[ 1 ] == "b" );
|
|
CPPUNIT_ASSERT( lp[ 2 ] == "c" );
|
|
}
|
|
|
|
void LogPathTest::testInitListEmpty( )
|
|
{
|
|
T_LogPath lp{ };
|
|
CPPUNIT_ASSERT( lp.isValid( ) );
|
|
CPPUNIT_ASSERT_EQUAL( uint32_t( 0 ) , lp.size( ) );
|
|
}
|
|
|
|
void LogPathTest::testInitListInvalidControl( )
|
|
{
|
|
T_LogPath lp{ "a" , "b" , "c\n" };
|
|
CPPUNIT_ASSERT( !lp.isValid( ) );
|
|
CPPUNIT_ASSERT_EQUAL( uint32_t( 3 ) , lp.size( ) );
|
|
CPPUNIT_ASSERT( lp[ 0 ] == "a" );
|
|
CPPUNIT_ASSERT( lp[ 1 ] == "b" );
|
|
CPPUNIT_ASSERT( lp[ 2 ] == "c\n" );
|
|
}
|
|
|
|
void LogPathTest::testInitListInvalidSlash( )
|
|
{
|
|
T_LogPath lp{ "a" , "b" , "c/" };
|
|
CPPUNIT_ASSERT( !lp.isValid( ) );
|
|
CPPUNIT_ASSERT_EQUAL( uint32_t( 3 ) , lp.size( ) );
|
|
CPPUNIT_ASSERT( lp[ 0 ] == "a" );
|
|
CPPUNIT_ASSERT( lp[ 1 ] == "b" );
|
|
CPPUNIT_ASSERT( lp[ 2 ] == "c/" );
|
|
}
|
|
|
|
void LogPathTest::testInitListInvalidEmpty( )
|
|
{
|
|
T_LogPath lp{ "a" , "b" , "" };
|
|
CPPUNIT_ASSERT( !lp.isValid( ) );
|
|
CPPUNIT_ASSERT_EQUAL( uint32_t( 3 ) , lp.size( ) );
|
|
CPPUNIT_ASSERT( lp[ 0 ] == "a" );
|
|
CPPUNIT_ASSERT( lp[ 1 ] == "b" );
|
|
CPPUNIT_ASSERT( lp[ 2 ] == "" );
|
|
}
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
void LogPathTest::testFromStringEmpty( )
|
|
{
|
|
T_LogPath lp( T_LogPath::FromString( "" ) );
|
|
CPPUNIT_ASSERT( lp.isValid( ) );
|
|
CPPUNIT_ASSERT_EQUAL( uint32_t( 0 ) , lp.size( ) );
|
|
}
|
|
|
|
void LogPathTest::testFromStringSlash( )
|
|
{
|
|
T_LogPath lp( T_LogPath::FromString( "/" ) );
|
|
CPPUNIT_ASSERT( lp.isValid( ) );
|
|
CPPUNIT_ASSERT_EQUAL( uint32_t( 0 ) , lp.size( ) );
|
|
}
|
|
|
|
void LogPathTest::testFromStringSlashes( )
|
|
{
|
|
T_LogPath lp( T_LogPath::FromString( "/////" ) );
|
|
CPPUNIT_ASSERT( lp.isValid( ) );
|
|
CPPUNIT_ASSERT_EQUAL( uint32_t( 0 ) , lp.size( ) );
|
|
}
|
|
|
|
void LogPathTest::testFromStringValid( )
|
|
{
|
|
T_LogPath lp( T_LogPath::FromString( "a/b/c" ) );
|
|
CPPUNIT_ASSERT( lp.isValid( ) );
|
|
CPPUNIT_ASSERT_EQUAL( uint32_t( 3 ) , lp.size( ) );
|
|
CPPUNIT_ASSERT( lp[ 0 ] == "a" );
|
|
CPPUNIT_ASSERT( lp[ 1 ] == "b" );
|
|
CPPUNIT_ASSERT( lp[ 2 ] == "c" );
|
|
}
|
|
|
|
void LogPathTest::testFromStringValidSlashes( )
|
|
{
|
|
T_LogPath lp( T_LogPath::FromString( "a//b////c" ) );
|
|
CPPUNIT_ASSERT( lp.isValid( ) );
|
|
CPPUNIT_ASSERT_EQUAL( uint32_t( 3 ) , lp.size( ) );
|
|
CPPUNIT_ASSERT( lp[ 0 ] == "a" );
|
|
CPPUNIT_ASSERT( lp[ 1 ] == "b" );
|
|
CPPUNIT_ASSERT( lp[ 2 ] == "c" );
|
|
}
|
|
|
|
void LogPathTest::testFromStringValidInitialSlash( )
|
|
{
|
|
T_LogPath lp( T_LogPath::FromString( "/a/b/c" ) );
|
|
CPPUNIT_ASSERT( lp.isValid( ) );
|
|
CPPUNIT_ASSERT_EQUAL( uint32_t( 3 ) , lp.size( ) );
|
|
CPPUNIT_ASSERT( lp[ 0 ] == "a" );
|
|
CPPUNIT_ASSERT( lp[ 1 ] == "b" );
|
|
CPPUNIT_ASSERT( lp[ 2 ] == "c" );
|
|
}
|
|
|
|
void LogPathTest::testFromStringValidTrailingSlash( )
|
|
{
|
|
T_LogPath lp( T_LogPath::FromString( "a/b/c/" ) );
|
|
CPPUNIT_ASSERT( lp.isValid( ) );
|
|
CPPUNIT_ASSERT_EQUAL( uint32_t( 3 ) , lp.size( ) );
|
|
CPPUNIT_ASSERT( lp[ 0 ] == "a" );
|
|
CPPUNIT_ASSERT( lp[ 1 ] == "b" );
|
|
CPPUNIT_ASSERT( lp[ 2 ] == "c" );
|
|
}
|
|
|
|
void LogPathTest::testFromStringInvalid( )
|
|
{
|
|
T_LogPath lp( T_LogPath::FromString( "a/b\n/c" ) );
|
|
CPPUNIT_ASSERT( !lp.isValid( ) );
|
|
CPPUNIT_ASSERT_EQUAL( uint32_t( 3 ) , lp.size( ) );
|
|
CPPUNIT_ASSERT( lp[ 0 ] == "a" );
|
|
CPPUNIT_ASSERT( lp[ 1 ] == "b\n" );
|
|
CPPUNIT_ASSERT( lp[ 2 ] == "c" );
|
|
}
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
void LogPathTest::testSwap( )
|
|
{
|
|
T_LogPath lp1{ "a" };
|
|
T_LogPath lp2{ "b" , "c" };
|
|
|
|
RPC_String p[] = {
|
|
&lp1[ 0 ] , &lp2[ 0 ] , &lp2[ 1 ]
|
|
};
|
|
|
|
swap( lp1 , lp2 );
|
|
CPPUNIT_ASSERT_EQUAL( uint32_t( 2 ) , lp1.size( ) );
|
|
CPPUNIT_ASSERT_EQUAL( uint32_t( 1 ) , lp2.size( ) );
|
|
CPPUNIT_ASSERT_EQUAL( p[ 0 ] , &lp2[ 0 ] );
|
|
CPPUNIT_ASSERT_EQUAL( p[ 1 ] , &lp1[ 0 ] );
|
|
CPPUNIT_ASSERT_EQUAL( p[ 2 ] , &lp1[ 1 ] );
|
|
}
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
void LogPathTest::testParentEmpty( )
|
|
{
|
|
T_LogPath lp;
|
|
T_LogPath plp( lp.parent( ) );
|
|
CPPUNIT_ASSERT( plp.isValid( ) );
|
|
CPPUNIT_ASSERT_EQUAL( uint32_t( 0 ) , plp.size( ) );
|
|
}
|
|
|
|
void LogPathTest::testParentOne( )
|
|
{
|
|
T_LogPath lp{ "a" };
|
|
T_LogPath plp( lp.parent( ) );
|
|
CPPUNIT_ASSERT( plp.isValid( ) );
|
|
CPPUNIT_ASSERT_EQUAL( uint32_t( 0 ) , plp.size( ) );
|
|
}
|
|
|
|
void LogPathTest::testParentValid( )
|
|
{
|
|
T_LogPath lp{ "a" , "b" };
|
|
T_LogPath plp( lp.parent( ) );
|
|
CPPUNIT_ASSERT( plp.isValid( ) );
|
|
CPPUNIT_ASSERT_EQUAL( uint32_t( 1 ) , plp.size( ) );
|
|
CPPUNIT_ASSERT( plp[ 0 ] == "a" );
|
|
}
|
|
|
|
void LogPathTest::testParentInvalidChild( )
|
|
{
|
|
T_LogPath lp{ "a" , "b/" };
|
|
T_LogPath plp( lp.parent( ) );
|
|
CPPUNIT_ASSERT( plp.isValid( ) );
|
|
CPPUNIT_ASSERT_EQUAL( uint32_t( 1 ) , plp.size( ) );
|
|
CPPUNIT_ASSERT( plp[ 0 ] == "a" );
|
|
}
|
|
|
|
void LogPathTest::testParentInvalid( )
|
|
{
|
|
T_LogPath lp{ "a/" , "b" };
|
|
T_LogPath plp( lp.parent( ) );
|
|
CPPUNIT_ASSERT( !plp.isValid( ) );
|
|
CPPUNIT_ASSERT_EQUAL( uint32_t( 1 ) , plp.size( ) );
|
|
CPPUNIT_ASSERT( plp[ 0 ] == "a/" );
|
|
}
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
void LogPathTest::testChildValid( )
|
|
{
|
|
T_LogPath lp{ "a" };
|
|
T_LogPath clp( lp.child( "b" ) );
|
|
|
|
CPPUNIT_ASSERT( clp.isValid( ) );
|
|
CPPUNIT_ASSERT_EQUAL( uint32_t( 2 ) , clp.size( ) );
|
|
CPPUNIT_ASSERT( clp[ 0 ] == "a" );
|
|
CPPUNIT_ASSERT( clp[ 1 ] == "b" );
|
|
}
|
|
|
|
void LogPathTest::testChildInvalidName( )
|
|
{
|
|
T_LogPath lp{ "a" };
|
|
T_LogPath clp( lp.child( "b\n" ) );
|
|
|
|
CPPUNIT_ASSERT( !clp.isValid( ) );
|
|
CPPUNIT_ASSERT_EQUAL( uint32_t( 2 ) , clp.size( ) );
|
|
CPPUNIT_ASSERT( clp[ 0 ] == "a" );
|
|
CPPUNIT_ASSERT( clp[ 1 ] == "b\n" );
|
|
}
|
|
|
|
void LogPathTest::testChildInvalidParent( )
|
|
{
|
|
T_LogPath lp{ "a\n" };
|
|
T_LogPath clp( lp.child( "b" ) );
|
|
|
|
CPPUNIT_ASSERT( !clp.isValid( ) );
|
|
CPPUNIT_ASSERT_EQUAL( uint32_t( 2 ) , clp.size( ) );
|
|
CPPUNIT_ASSERT( clp[ 0 ] == "a\n" );
|
|
CPPUNIT_ASSERT( clp[ 1 ] == "b" );
|
|
}
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
void LogPathTest::testToStringEmpty( )
|
|
{
|
|
T_LogPath lp;
|
|
CPPUNIT_ASSERT( lp.toString( ) == "/" );
|
|
}
|
|
|
|
void LogPathTest::testToStringValid( )
|
|
{
|
|
T_LogPath lp{ "a" , "b" , "c" };
|
|
CPPUNIT_ASSERT( lp.toString( ) == "/a/b/c" );
|
|
}
|
|
|
|
void LogPathTest::testToStringInvalidSlash( )
|
|
{
|
|
T_LogPath lp{ "a" , "/b" , "c" };
|
|
CPPUNIT_ASSERT( lp.toString( ) == "/a//b/c" );
|
|
}
|
|
|
|
void LogPathTest::testToStringInvalidControl( )
|
|
{
|
|
T_LogPath lp{ "a" , "b\n" , "c" };
|
|
CPPUNIT_ASSERT( lp.toString( ) == "/a/b\n/c" );
|
|
}
|
|
|
|
void LogPathTest::testToStringInvalidEmpty( )
|
|
{
|
|
T_LogPath lp{ "a" , "" , "c" };
|
|
CPPUNIT_ASSERT( lp.toString( ) == "/a//c" );
|
|
}
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
void LogPathTest::testIsParentYes( )
|
|
{
|
|
T_LogPath gc{ "a" , "b" };
|
|
T_LogPath c{ "a" };
|
|
T_LogPath p;
|
|
|
|
CPPUNIT_ASSERT( p.isParentOf( c ) );
|
|
CPPUNIT_ASSERT( c.isParentOf( gc ) );
|
|
|
|
CPPUNIT_ASSERT( c.isChildOf( p ) );
|
|
CPPUNIT_ASSERT( gc.isChildOf( c ) );
|
|
}
|
|
|
|
void LogPathTest::testIsParentNo( )
|
|
{
|
|
T_LogPath p1{ "a" , "b" , "c" };
|
|
T_LogPath p2{ "a" , "b" , "d" , "e" };
|
|
CPPUNIT_ASSERT( !p1.isParentOf( p2 ) );
|
|
CPPUNIT_ASSERT( !p2.isParentOf( p1 ) );
|
|
CPPUNIT_ASSERT( !p1.isChildOf( p2 ) );
|
|
CPPUNIT_ASSERT( !p2.isChildOf( p1 ) );
|
|
}
|
|
|
|
void LogPathTest::testIsParentYesInvalidParent( )
|
|
{
|
|
T_LogPath p1{ "a\n" };
|
|
T_LogPath p2{ "a\n" , "b" };
|
|
CPPUNIT_ASSERT( p1.isParentOf( p2 ) );
|
|
CPPUNIT_ASSERT( p2.isChildOf( p1 ) );
|
|
}
|
|
|
|
void LogPathTest::testIsParentYesInvalidChild( )
|
|
{
|
|
T_LogPath p1{ "a" };
|
|
T_LogPath p2{ "a" , "b\n" };
|
|
CPPUNIT_ASSERT( p1.isParentOf( p2 ) );
|
|
CPPUNIT_ASSERT( p2.isChildOf( p1 ) );
|
|
}
|
|
|
|
void LogPathTest::testIsParentNoInvalidParent( )
|
|
{
|
|
T_LogPath p1{ "b\n" };
|
|
T_LogPath p2{ "c" , "b" };
|
|
CPPUNIT_ASSERT( !p1.isParentOf( p2 ) );
|
|
CPPUNIT_ASSERT( !p2.isParentOf( p1 ) );
|
|
CPPUNIT_ASSERT( !p1.isChildOf( p2 ) );
|
|
CPPUNIT_ASSERT( !p2.isChildOf( p1 ) );
|
|
}
|
|
|
|
void LogPathTest::testIsParentNoInvalidChild( )
|
|
{
|
|
T_LogPath p1{ "b" };
|
|
T_LogPath p2{ "c" , "b\n" };
|
|
CPPUNIT_ASSERT( !p1.isParentOf( p2 ) );
|
|
CPPUNIT_ASSERT( !p2.isParentOf( p1 ) );
|
|
CPPUNIT_ASSERT( !p1.isChildOf( p2 ) );
|
|
CPPUNIT_ASSERT( !p2.isChildOf( p1 ) );
|
|
}
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
void LogPathTest::testEquals( )
|
|
{
|
|
T_LogPath p1{ "a" };
|
|
T_LogPath p2( p1 );
|
|
T_LogPath p3{ "b" , "c" };
|
|
T_LogPath p4{ "d" };
|
|
CPPUNIT_ASSERT( p1 == p1 );
|
|
CPPUNIT_ASSERT( p1 == p2 );
|
|
CPPUNIT_ASSERT( !( p1 == p3 ) );
|
|
CPPUNIT_ASSERT( !( p1 == p4 ) );
|
|
}
|
|
|
|
void LogPathTest::testNotEquals( )
|
|
{
|
|
T_LogPath p1{ "a" };
|
|
T_LogPath p2( p1 );
|
|
T_LogPath p3{ "b" , "c" };
|
|
T_LogPath p4{ "d" };
|
|
CPPUNIT_ASSERT( !( p1 != p1 ) );
|
|
CPPUNIT_ASSERT( !( p1 != p2 ) );
|
|
CPPUNIT_ASSERT( p1 != p3 );
|
|
CPPUNIT_ASSERT( p1 != p4 );
|
|
}
|
|
|