ResInsight/ApplicationLibCode/UnitTests/RiaPolyArcLineSampler-Test.cpp

68 lines
2.1 KiB
C++
Raw Normal View History

#include "gtest/gtest.h"
#include "RiaPolyArcLineSampler.h"
#include <iostream>
//--------------------------------------------------------------------------------------------------
TEST( RiaPolyArcLineSampler, Basic )
{
2020-11-06 03:46:38 -06:00
std::vector<cvf::Vec3d> points{ { 0, 0, 0 }, { 0, 0, -10 }, { 0, 10, -20 }, { 0, 20, -20 }, { 0, 30, -30 } };
2020-11-06 03:46:38 -06:00
RiaPolyArcLineSampler sampler( { 0, 0, -1 }, points );
2020-10-06 05:37:16 -05:00
auto [sampledPoints, mds] = sampler.sampledPointsAndMDs( 2, true );
#if 1
for ( size_t pIdx = 0; pIdx < sampledPoints.size(); ++pIdx )
{
std::cout << sampledPoints[pIdx].x() << " " << sampledPoints[pIdx].y() << " " << sampledPoints[pIdx].z() << " md: " << mds[pIdx]
<< std::endl;
}
#endif
EXPECT_EQ( 55, (int)sampledPoints.size() );
EXPECT_NEAR( 51.4159, mds.back(), 1e-4 );
EXPECT_NEAR( points[2].y(), sampledPoints[27].y(), 2 );
EXPECT_NEAR( points[2].z(), sampledPoints[27].z(), 2 );
EXPECT_NEAR( points[4].y(), sampledPoints.back().y(), 2 );
EXPECT_NEAR( points[4].z(), sampledPoints.back().z(), 2 );
}
//--------------------------------------------------------------------------------------------------
TEST( RiaPolyArcLineSampler, TestInvalidInput )
{
{
// Two identical points after each other
2020-11-06 03:46:38 -06:00
std::vector<cvf::Vec3d> points{ { 0, 0, -20 }, { 0, 0, -20 } };
2020-11-06 03:46:38 -06:00
RiaPolyArcLineSampler sampler( { 0, 0, -1 }, points );
2020-10-06 05:37:16 -05:00
auto [sampledPoints, mds] = sampler.sampledPointsAndMDs( 2, true );
EXPECT_EQ( 0, (int)sampledPoints.size() );
EXPECT_EQ( 0, (int)mds.size() );
}
{
std::vector<cvf::Vec3d> points;
2020-11-06 03:46:38 -06:00
RiaPolyArcLineSampler sampler( { 0, 0, -1 }, points );
2020-10-06 05:37:16 -05:00
auto [sampledPoints, mds] = sampler.sampledPointsAndMDs( 2, true );
EXPECT_EQ( 0, (int)sampledPoints.size() );
EXPECT_EQ( 0, (int)mds.size() );
}
{
2020-11-06 03:46:38 -06:00
std::vector<cvf::Vec3d> points{ { 0, 0, 0 } };
2020-11-06 03:46:38 -06:00
RiaPolyArcLineSampler sampler( { 0, 0, -1 }, points );
2020-10-06 05:37:16 -05:00
auto [sampledPoints, mds] = sampler.sampledPointsAndMDs( 2, true );
EXPECT_EQ( 0, (int)sampledPoints.size() );
EXPECT_EQ( 0, (int)mds.size() );
}
}