OpenWalnut  1.4.0
Public Member Functions | Private Member Functions
WLineTest Class Reference

Unit tests the WLine class. More...

#include <WLine_test.h>

+ Inheritance diagram for WLineTest:

List of all members.

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.
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.
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.
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]].
void testEqualityOperator (void)
 Two Lines are equal if they have the same points in the same order.
void testAccessOperatorWithinValidBounds (void)
 When accessing an item within 0..length-1 a const reference to the WPosition object should be returned.
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.
void testPathLength (void)
 The path length of the line is the accumulated path lengths of all segements (point to point) in that line.
void testDownSampleLine (void)
 When resampling a line a new line is generated having the given number of sampling points.
void testSamplingWithSameNumberOfPoints (void)
 If the resampling rate of a line has as many points as the original line, no sampling should be applied.
void testSamplingPointsAreExactlyInTheOldSegmentCenterAndCorners (void)
 If the points are exactly in between of a segement nothing should fail.
void testNumericalStabilityOfResampling (void)
 When resampling with many sample points the numerical errors may sum up.
void testManySampelsInBetweenOfTwoOldPoints (void)
 If there are many new sample points between two old sample points nothing should fail either.
void testMidPointOnEvenSize (void)
 The mid point of a WLine is just the point in the middle of the line.
void testMidPointOnUnevenSize (void)
 When a line has uneven numbered size, the mid point is unique.
void testMidPointOnEmptyLine (void)
 When calling midPoint on empty lines => there is no point to return hence an exception is generated.
void testMaxSegementLength (void)
 The max segemnent length is the maximum length over all segments (p_i<->p_j).
void testEmptyLineOnMaxSegementLength (void)
 If there no points at all, 0.0 shall be returned.
void testRemoveAdjacentDuplicates (void)
 If there are duplicates next to each other => collapse them.
void testResamplingByNewSegmentLengthWithZeroLine (void)
 No sample points should remain no sample points.
void testResamplingByNewSegementLengthWithLineHavingJustOnePoint (void)
 Lines with size() == 1, should also remain untouched.
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.
void testResamplingByNewSegementLengthTravelingOutOfTheCircle (void)
 Only if a sample point comes out of the circle with radius newSegmentLength then append the point of intersection.

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.

Detailed Description

Unit tests the WLine class.

Definition at line 42 of file WLine_test.h.


Member Function Documentation

void WLineTest::assert_equals_delta ( const WLine first,
const WLine second,
double  delta = wlimits::DBL_EPS 
) const [inline, private]

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 431 of file WLine_test.h.

References WMixinVector< ValueT >::size().

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

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().

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().

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

Definition at line 334 of file WLine_test.h.

References WMixinVector< ValueT >::push_back().

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().

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().

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().

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().

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().

void WLineTest::testMaxSegementLength ( void  ) [inline]

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

For further information look just on the name of the test function, I think this is really precised ;). (Ha one more line in hg churn!) BTW: If there are multiple max lengths (equidistant sampled tracts) the first shall be chosen, BTW: this is totally stupid!, if they are equals it doesn't matter anyway, huh???

Definition at line 320 of file WLine_test.h.

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

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().

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().

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().

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().

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().

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().

void WLineTest::testRemoveAdjacentDuplicates ( void  ) [inline]

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

Definition at line 345 of file WLine_test.h.

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

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 390 of file WLine_test.h.

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

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

Definition at line 406 of file WLine_test.h.

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

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

Definition at line 377 of file WLine_test.h.

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

No sample points should remain no sample points.

Definition at line 367 of file WLine_test.h.

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

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().

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().

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().


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