OpenWalnut  1.5.0dev
Public Member Functions | Private Member Functions | List of all members
WLineTest Class Reference

Unit tests the WLine class. More...

#include <WLine_test.h>

+ Inheritance diagram for WLineTest:
+ Collaboration diagram for WLineTest:

Public Member Functions

void testEqualsDeltaDifferentLength (void)
 If two lines have different lengths they are considered diffrent regardless on the given delta and the first point on which they differ should be returned. More...
 
void testEqualsDeltaOnRealDifferentLines (void)
 If both lines are of same size, but there is a point differing on more than the given delta the first point which differs should be returned. More...
 
void testEqualsDeltaOnDifferentLinesButWithinDelta (void)
 If both lines are of same size and every point pair don't differ in terms of the given delta, -1 should be returned. More...
 
void testOutputOperator (void)
 When printing a line to stdout it the output should be as follows: [first_pos, ..., last_pos] where the positions also should be in the same format, so in the end we would have: [[0,1,0],...[0,0,0]]. More...
 
void testEqualityOperator (void)
 Two Lines are equal if they have the same points in the same order. More...
 
void testAccessOperatorWithinValidBounds (void)
 When accessing an item within 0..length-1 a const reference to the WPosition object should be returned. More...
 
void testReverseOrdering (void)
 If for example the start and end points of two lines are in opposite direction we may want to change its direction. More...
 
void testPathLength (void)
 The path length of the line is the accumulated path lengths of all segements (point to point) in that line. More...
 
void testDownSampleLine (void)
 When resampling a line a new line is generated having the given number of sampling points. More...
 
void testSamplingWithSameNumberOfPoints (void)
 If the resampling rate of a line has as many points as the original line, no sampling should be applied. More...
 
void testSamplingPointsAreExactlyInTheOldSegmentCenterAndCorners (void)
 If the points are exactly in between of a segement nothing should fail. More...
 
void testNumericalStabilityOfResampling (void)
 When resampling with many sample points the numerical errors may sum up. More...
 
void testManySampelsInBetweenOfTwoOldPoints (void)
 If there are many new sample points between two old sample points nothing should fail either. More...
 
void testMidPointOnEvenSize (void)
 The mid point of a WLine is just the point in the middle of the line. More...
 
void testMidPointOnUnevenSize (void)
 When a line has uneven numbered size, the mid point is unique. More...
 
void testMidPointOnEmptyLine (void)
 When calling midPoint on empty lines => there is no point to return hence an exception is generated. More...
 
void testMaxSegementLength (void)
 The max segemnent length is the maximum length over all segments (p_i<->p_j). More...
 
void testEmptyLineOnMaxSegementLength (void)
 If there no points at all, 0.0 shall be returned. More...
 
void testRemoveAdjacentDuplicates (void)
 If there are duplicates next to each other => collapse them. More...
 
void testResamplingByNewSegmentLengthWithZeroLine (void)
 No sample points should remain no sample points. More...
 
void testResamplingByNewSegementLengthWithLineHavingJustOnePoint (void)
 Lines with size() == 1, should also remain untouched. More...
 
void testResamplingByNewSegementLengthOldSegmentLengthBiggerAsNewSegmentLength (void)
 If there is a segement bigger than the newSegmentLength, then the new segment should be inserted and then with the new point should be proceeded just the same. More...
 
void testResamplingByNewSegementLengthTravelingOutOfTheCircle (void)
 Only if a sample point comes out of the circle with radius newSegmentLength then append the point of intersection. More...
 

Private Member Functions

void assert_equals_delta (const WLine &first, const WLine &second, double delta=wlimits::DBL_EPS) const
 TS_ASSERT_DELTA needs the operator+, operator- and operator< to be implemented especially for WPositions the operator< and operator + makes not really sense. More...
 

Detailed Description

Unit tests the WLine class.

Definition at line 42 of file WLine_test.h.

Member Function Documentation

◆ assert_equals_delta()

void WLineTest::assert_equals_delta ( const WLine first,
const WLine second,
double  delta = wlimits::DBL_EPS 
) const
inlineprivate

TS_ASSERT_DELTA needs the operator+, operator- and operator< to be implemented especially for WPositions the operator< and operator + makes not really sense.

Hence I implemented an assert by my one, giving reasonable out put.

Parameters
firstFirst line to compare with
secondSecond line to compare with
deltaThe delta within two points are considered as equally

Definition at line 428 of file WLine_test.h.

References WMixinVector< ValueT >::size().

Referenced by testDownSampleLine(), testManySampelsInBetweenOfTwoOldPoints(), testNumericalStabilityOfResampling(), testRemoveAdjacentDuplicates(), testResamplingByNewSegementLengthOldSegmentLengthBiggerAsNewSegmentLength(), testResamplingByNewSegementLengthTravelingOutOfTheCircle(), testResamplingByNewSegementLengthWithLineHavingJustOnePoint(), testResamplingByNewSegmentLengthWithZeroLine(), testSamplingPointsAreExactlyInTheOldSegmentCenterAndCorners(), and testSamplingWithSameNumberOfPoints().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ testAccessOperatorWithinValidBounds()

void WLineTest::testAccessOperatorWithinValidBounds ( void  )
inline

When accessing an item within 0..length-1 a const reference to the WPosition object should be returned.

Definition at line 133 of file WLine_test.h.

References WMixinVector< ValueT >::push_back().

+ Here is the call graph for this function:

◆ testDownSampleLine()

void WLineTest::testDownSampleLine ( void  )
inline

When resampling a line a new line is generated having the given number of sampling points.

Its start and end points remain the same, but its curvature may change a bit and also its length! Down sampling means you will have

Definition at line 182 of file WLine_test.h.

References assert_equals_delta(), wlimits::DBL_EPS, WMixinVector< ValueT >::push_back(), and WLine::resampleByNumberOfPoints().

+ Here is the call graph for this function:

◆ testEmptyLineOnMaxSegementLength()

void WLineTest::testEmptyLineOnMaxSegementLength ( void  )
inline

If there no points at all, 0.0 shall be returned.

Definition at line 331 of file WLine_test.h.

References WMixinVector< ValueT >::push_back().

+ Here is the call graph for this function:

◆ testEqualityOperator()

void WLineTest::testEqualityOperator ( void  )
inline

Two Lines are equal if they have the same points in the same order.

Definition at line 114 of file WLine_test.h.

References WMixinVector< ValueT >::back(), and WMixinVector< ValueT >::push_back().

+ Here is the call graph for this function:

◆ testEqualsDeltaDifferentLength()

void WLineTest::testEqualsDeltaDifferentLength ( void  )
inline

If two lines have different lengths they are considered diffrent regardless on the given delta and the first point on which they differ should be returned.

Definition at line 50 of file WLine_test.h.

References WMixinVector< ValueT >::push_back().

+ Here is the call graph for this function:

◆ testEqualsDeltaOnDifferentLinesButWithinDelta()

void WLineTest::testEqualsDeltaOnDifferentLinesButWithinDelta ( void  )
inline

If both lines are of same size and every point pair don't differ in terms of the given delta, -1 should be returned.

Definition at line 80 of file WLine_test.h.

References wlimits::DBL_EPS, and WMixinVector< ValueT >::push_back().

+ Here is the call graph for this function:

◆ testEqualsDeltaOnRealDifferentLines()

void WLineTest::testEqualsDeltaOnRealDifferentLines ( void  )
inline

If both lines are of same size, but there is a point differing on more than the given delta the first point which differs should be returned.

Definition at line 65 of file WLine_test.h.

References wlimits::DBL_EPS, and WMixinVector< ValueT >::push_back().

+ Here is the call graph for this function:

◆ testManySampelsInBetweenOfTwoOldPoints()

void WLineTest::testManySampelsInBetweenOfTwoOldPoints ( void  )
inline

If there are many new sample points between two old sample points nothing should fail either.

Definition at line 258 of file WLine_test.h.

References assert_equals_delta(), WMixinVector< ValueT >::push_back(), and WLine::resampleByNumberOfPoints().

+ Here is the call graph for this function:

◆ testMaxSegementLength()

void WLineTest::testMaxSegementLength ( void  )
inline

The max segemnent length is the maximum length over all segments (p_i<->p_j).

BTW: If there are multiple max lengths (equidistant sampled tracts) the first shall be chosen

Definition at line 317 of file WLine_test.h.

References wlimits::DBL_EPS, and WMixinVector< ValueT >::push_back().

+ Here is the call graph for this function:

◆ testMidPointOnEmptyLine()

void WLineTest::testMidPointOnEmptyLine ( void  )
inline

When calling midPoint on empty lines => there is no point to return hence an exception is generated.

Definition at line 306 of file WLine_test.h.

References WException::what().

+ Here is the call graph for this function:

◆ testMidPointOnEvenSize()

void WLineTest::testMidPointOnEvenSize ( void  )
inline

The mid point of a WLine is just the point in the middle of the line.

For lines with even numbered size the element before that non existing midPoint is selected.

Definition at line 278 of file WLine_test.h.

References WMixinVector< ValueT >::push_back().

+ Here is the call graph for this function:

◆ testMidPointOnUnevenSize()

void WLineTest::testMidPointOnUnevenSize ( void  )
inline

When a line has uneven numbered size, the mid point is unique.

Definition at line 292 of file WLine_test.h.

References WMixinVector< ValueT >::push_back().

+ Here is the call graph for this function:

◆ testNumericalStabilityOfResampling()

void WLineTest::testNumericalStabilityOfResampling ( void  )
inline

When resampling with many sample points the numerical errors may sum up.

Hence I watch if it not breaks a certain threshold: 1.0e-10*newSegmentLength.

Definition at line 236 of file WLine_test.h.

References assert_equals_delta(), WMixinVector< ValueT >::pop_back(), WMixinVector< ValueT >::push_back(), and WLine::resampleByNumberOfPoints().

+ Here is the call graph for this function:

◆ testOutputOperator()

void WLineTest::testOutputOperator ( void  )
inline

When printing a line to stdout it the output should be as follows: [first_pos, ..., last_pos] where the positions also should be in the same format, so in the end we would have: [[0,1,0],...[0,0,0]].

Definition at line 97 of file WLine_test.h.

References WMixinVector< ValueT >::push_back().

+ Here is the call graph for this function:

◆ testPathLength()

void WLineTest::testPathLength ( void  )
inline

The path length of the line is the accumulated path lengths of all segements (point to point) in that line.

Definition at line 165 of file WLine_test.h.

References WMixinVector< ValueT >::push_back().

+ Here is the call graph for this function:

◆ testRemoveAdjacentDuplicates()

void WLineTest::testRemoveAdjacentDuplicates ( void  )
inline

If there are duplicates next to each other => collapse them.

Definition at line 342 of file WLine_test.h.

References assert_equals_delta(), WMixinVector< ValueT >::push_back(), and WLine::removeAdjacentDuplicates().

+ Here is the call graph for this function:

◆ testResamplingByNewSegementLengthOldSegmentLengthBiggerAsNewSegmentLength()

void WLineTest::testResamplingByNewSegementLengthOldSegmentLengthBiggerAsNewSegmentLength ( void  )
inline

If there is a segement bigger than the newSegmentLength, then the new segment should be inserted and then with the new point should be proceeded just the same.

Definition at line 387 of file WLine_test.h.

References assert_equals_delta(), WMixinVector< ValueT >::push_back(), and WLine::resampleBySegmentLength().

+ Here is the call graph for this function:

◆ testResamplingByNewSegementLengthTravelingOutOfTheCircle()

void WLineTest::testResamplingByNewSegementLengthTravelingOutOfTheCircle ( void  )
inline

Only if a sample point comes out of the circle with radius newSegmentLength then append the point of intersection.

Definition at line 403 of file WLine_test.h.

References assert_equals_delta(), WMixinVector< ValueT >::push_back(), and WLine::resampleBySegmentLength().

+ Here is the call graph for this function:

◆ testResamplingByNewSegementLengthWithLineHavingJustOnePoint()

void WLineTest::testResamplingByNewSegementLengthWithLineHavingJustOnePoint ( void  )
inline

Lines with size() == 1, should also remain untouched.

Definition at line 374 of file WLine_test.h.

References assert_equals_delta(), WMixinVector< ValueT >::push_back(), and WLine::resampleBySegmentLength().

+ Here is the call graph for this function:

◆ testResamplingByNewSegmentLengthWithZeroLine()

void WLineTest::testResamplingByNewSegmentLengthWithZeroLine ( void  )
inline

No sample points should remain no sample points.

Definition at line 364 of file WLine_test.h.

References assert_equals_delta(), and WLine::resampleBySegmentLength().

+ Here is the call graph for this function:

◆ testReverseOrdering()

void WLineTest::testReverseOrdering ( void  )
inline

If for example the start and end points of two lines are in opposite direction we may want to change its direction.

Definition at line 147 of file WLine_test.h.

References WMixinVector< ValueT >::push_back(), and WLine::reverseOrder().

+ Here is the call graph for this function:

◆ testSamplingPointsAreExactlyInTheOldSegmentCenterAndCorners()

void WLineTest::testSamplingPointsAreExactlyInTheOldSegmentCenterAndCorners ( void  )
inline

If the points are exactly in between of a segement nothing should fail.

Definition at line 217 of file WLine_test.h.

References assert_equals_delta(), WMixinVector< ValueT >::pop_back(), WMixinVector< ValueT >::push_back(), and WLine::resampleByNumberOfPoints().

+ Here is the call graph for this function:

◆ testSamplingWithSameNumberOfPoints()

void WLineTest::testSamplingWithSameNumberOfPoints ( void  )
inline

If the resampling rate of a line has as many points as the original line, no sampling should be applied.

Definition at line 201 of file WLine_test.h.

References assert_equals_delta(), WMixinVector< ValueT >::push_back(), WLine::resampleByNumberOfPoints(), and WMixinVector< ValueT >::size().

+ Here is the call graph for this function:

The documentation for this class was generated from the following file: