31 #include <cxxtest/TestSuite.h>
33 #include "../../exceptions/WOutOfBounds.h"
34 #include "../../WLimits.h"
36 #include "WLineTraits.h"
37 #include "WPositionTraits.h"
57 TS_ASSERT_EQUALS( equalsDelta( line, other, 0.0 ), 1 );
103 std::string expected(
"[1.0000000000000000e+00;1.0000000000000000e+00;3.1415000000000002e+00;, "
104 "0.0000000000000000e+00;0.0000000000000000e+00;4.4000000000000000e-01;, "
105 "1.0000000000000000e+00;1.0000000000000000e+00;1.0000000000000000e+00;]" );
106 std::stringstream ss;
108 TS_ASSERT_EQUALS( expected, ss.str() );
124 TS_ASSERT_EQUALS( line1, line2 );
125 line2.
back()[1] += 0.0000000001;
126 TS_ASSERT_DIFFERS( line1, line2 );
140 TS_ASSERT_EQUALS( expected, line[2] );
158 TS_ASSERT_EQUALS( line, expected );
173 TS_ASSERT_DELTA( expected, pathLength( line ), 1e-6 );
204 for(
size_t i = 0; i < 10; ++i )
208 TS_ASSERT( line.
size() == 10 );
209 WLine expected( line );
221 for(
int i = 0; i < 3; ++i )
240 for(
int i = 0; i < 100; ++i )
246 expected.
push_back(
WPosition( i + 0.75, std::pow( -1.0, ( i + 1 ) % 2 ) * 0.5, 0 ) );
266 for(
size_t i = 1; i < 1001; ++i )
286 TS_ASSERT_EQUALS( expected,
WPosition( midPoint( line ) ) );
299 TS_ASSERT_EQUALS( expected,
WPosition( midPoint( line ) ) );
310 TS_ASSERT_THROWS_EQUALS( midPoint( line ),
WOutOfBounds &e, std::string( e.
what() ),
"There is no midpoint for an empty line." );
326 TS_ASSERT_DELTA( maxSegmentLength( line ), std::sqrt( 2.0 ),
wlimits::DBL_EPS );
337 TS_ASSERT_EQUALS( maxSegmentLength( line ), 0.0 );
339 TS_ASSERT_EQUALS( maxSegmentLength( line ), 0.0 );
381 WLine expected( line );
434 if( ( diffPos = equalsDelta( first, second, delta ) ) != -1 )
436 using string_utils::operator<<;
437 std::stringstream msg;
438 msg <<
"Lines are different in at least point: " << diffPos;
439 TS_FAIL( msg.str() );
440 if( static_cast< int >( first.
size() ) > diffPos && static_cast< int >( second.
size() ) > diffPos )
442 std::cout <<
"first line at: " << diffPos << std::endl << first[diffPos] << std::endl;
443 std::cout <<
"second line at: " << diffPos << std::endl << second[diffPos] << std::endl;
447 std::cout <<
"lines does not have the same number of points: first=" << first.
size() <<
" second=" << second.
size() << std::endl;
449 std::cout <<
"first line: " << std::endl << first << std::endl;
450 std::cout <<
"second line: " << std::endl << second << std::endl;
454 #endif // WLINE_TEST_H