SyntaxTree - Location field

This commit is contained in:
Emmanuel BENOîT 2018-03-31 22:38:26 +02:00
parent b659f2f237
commit 6f52668540
3 changed files with 95 additions and 57 deletions

View file

@ -10,6 +10,7 @@ class SyntaxTreeTest : public CppUnit::TestFixture
CPPUNIT_TEST( testUpdateData );
CPPUNIT_TEST( testAddChildren );
CPPUNIT_TEST( testVisit );
CPPUNIT_TEST( testLocation );
CPPUNIT_TEST_SUITE_END( );
public:
@ -18,6 +19,7 @@ public:
void testUpdateData( );
void testAddChildren( );
void testVisit( );
void testLocation( );
};
CPPUNIT_TEST_SUITE_REGISTRATION( SyntaxTreeTest );
@ -30,7 +32,7 @@ enum class E_TestNode_
VALUE
};
using T_Test_ = T_SyntaxTree< E_TestNode_ >;
using T_Test_ = T_SyntaxTree< E_TestNode_ , uint32_t >;
/*----------------------------------------------------------------------------*/
@ -139,3 +141,11 @@ void SyntaxTreeTest::testVisit( )
CPPUNIT_ASSERT_EQUAL( 0u , std::get< 1 >( visitData[ 7 ] ) );
CPPUNIT_ASSERT( !std::get< 2 >( visitData[ 6 ] ) );
}
void SyntaxTreeTest::testLocation( )
{
T_Test_ st{ E_TestNode_::ROOT };
CPPUNIT_ASSERT_EQUAL( 0u , st.locationOf( 0 ) );
st.locationOf( 0 ) = 123;
CPPUNIT_ASSERT_EQUAL( 123u , st.locationOf( 0 ) );
}