From: <bl...@us...> - 2003-04-06 15:10:05
|
Update of /cvsroot/cpptool/rfta/src/rftaparser In directory sc8-pr-cvs1:/tmp/cvs-serv10762/src/rftaparser Modified Files: SourceRange.cpp SourceRangeTest.cpp Log Message: * fixed bug in SourceRange::contains() Index: SourceRange.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rftaparser/SourceRange.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** SourceRange.cpp 22 Dec 2002 16:03:53 -0000 1.1 --- SourceRange.cpp 6 Apr 2003 15:09:58 -0000 1.2 *************** *** 73,78 **** SourceRange::contains( const SourceRange &other ) const { return other.startIndex_ >= startIndex_ && ! other.startIndex_ + other.length_ <= startIndex_ + length_; } --- 73,84 ---- SourceRange::contains( const SourceRange &other ) const { + if ( isEmpty() ) + return false; + + if ( other.isEmpty() && other.startIndex_ == getEndIndex() ) + return false; + return other.startIndex_ >= startIndex_ && ! other.getEndIndex() <= getEndIndex(); } Index: SourceRangeTest.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rftaparser/SourceRangeTest.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** SourceRangeTest.cpp 22 Dec 2002 16:03:53 -0000 1.1 --- SourceRangeTest.cpp 6 Apr 2003 15:09:59 -0000 1.2 *************** *** 65,73 **** SourceRange r_1_5( 1, 5 ); SourceRange r_2_3( 2, 3 ); ! SourceRange r_3_3( 3, 3); CPPUNIT_ASSERT( r_1_5.contains( r_2_3 ) ); CPPUNIT_ASSERT( r_1_5.contains( r_3_3 ) ); CPPUNIT_ASSERT( r_3_3.contains( r_3_3 ) ); CPPUNIT_ASSERT( ! r_2_3.contains( r_3_3 ) ); } --- 65,81 ---- SourceRange r_1_5( 1, 5 ); SourceRange r_2_3( 2, 3 ); ! SourceRange r_3_3( 3, 3 ); ! SourceRange r_6_0( 6, 0 ); ! SourceRange r_1_0( 1, 0 ); ! SourceRange r_5_0( 5, 0 ); CPPUNIT_ASSERT( r_1_5.contains( r_2_3 ) ); CPPUNIT_ASSERT( r_1_5.contains( r_3_3 ) ); CPPUNIT_ASSERT( r_3_3.contains( r_3_3 ) ); CPPUNIT_ASSERT( ! r_2_3.contains( r_3_3 ) ); + CPPUNIT_ASSERT( !r_1_5.contains( r_6_0 ) ); + CPPUNIT_ASSERT( r_1_5.contains( r_1_0 ) ); + CPPUNIT_ASSERT( r_1_5.contains( r_5_0 ) ); + CPPUNIT_ASSERT( !r_1_0.contains( r_1_0 ) ); + CPPUNIT_ASSERT( !r_6_0.contains( r_1_5 ) ); } |