From: <bl...@us...> - 2003-05-03 17:39:22
|
Update of /cvsroot/cpptool/rfta/src/rftaparser In directory sc8-pr-cvs1:/tmp/cvs-serv663/src/rftaparser Modified Files: ParserToolsTest.cpp ParserToolsTest.h Log Message: * added expression skipper and makeComposite(). Index: ParserToolsTest.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rftaparser/ParserToolsTest.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ParserToolsTest.cpp 2 May 2003 06:22:25 -0000 1.3 --- ParserToolsTest.cpp 3 May 2003 17:39:18 -0000 1.4 *************** *** 37,40 **** --- 37,47 ---- + Xtl::CStringView + ParserToolsTest::makeString( const char *text ) + { + return Xtl::CStringView( text, text + std::string(text).length() ); + } + + void ParserToolsTest::testTryReadIdentifier() *************** *** 121,124 **** --- 128,161 ---- // :::: // ... + + + namespace Testing { + struct ExpressionSkipperAsserter : public Asserter<ExpressionSkipperAsserter> + { + void checkExpressionSkipper( std::string source, + int startIndex ) + { + source += ','; + Xtl::CStringView s( source.c_str(), source.c_str() + source.length() ); + Xtl::CStringEnumerator e( s ); + e += startIndex; + ParserTools::skipUntil( e, ',', ParserTools::SkipExpressionPolicy() ); + checkEquals( source.length(), e.getCurrentIndex(), "current: " + + Xtl::CStringView(e).str() ); + } + }; + + #define RFTA_TEMPLATE_SKIPPER_ASSERT \ + RFTA_CUSTOM_ASSERT( ::Refactoring::Testing::ExpressionSkipperAsserter ).checkExpressionSkipper + } + + + void + ParserToolsTest::testExpressionSkipper() + { + RFTA_TEMPLATE_SKIPPER_ASSERT( "T<A,B>::value", 0 ); + RFTA_TEMPLATE_SKIPPER_ASSERT( "x << 1", 0 ); + RFTA_TEMPLATE_SKIPPER_ASSERT( "sizeof(x)<3", 0 ); + } Index: ParserToolsTest.h =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rftaparser/ParserToolsTest.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ParserToolsTest.h 29 Apr 2003 09:46:07 -0000 1.2 --- ParserToolsTest.h 3 May 2003 17:39:19 -0000 1.3 *************** *** 21,25 **** CPPUNIT_TEST( testTryReadKeyword ); CPPUNIT_TEST( testBacktrackSkippingOverIdentifier ); ! CPPUNIT_TEST_SUITE_END(); --- 21,25 ---- CPPUNIT_TEST( testTryReadKeyword ); CPPUNIT_TEST( testBacktrackSkippingOverIdentifier ); ! CPPUNIT_TEST( testExpressionSkipper ); CPPUNIT_TEST_SUITE_END(); *************** *** 38,50 **** void testTryReadKeyword(); void testBacktrackSkippingOverIdentifier(); private: ! /// Prevents the use of the copy constructor. ! ParserToolsTest( const ParserToolsTest &other ); ! ! /// Prevents the use of the copy operator. ! void operator =( const ParserToolsTest &other ); ! ! private: }; --- 38,45 ---- void testTryReadKeyword(); void testBacktrackSkippingOverIdentifier(); + void testExpressionSkipper(); private: ! Xtl::CStringView makeString( const char *text ); }; |