DGtal  1.5.beta
testLemniscate2D.cpp File Reference
#include <iostream>
#include <random>
#include "DGtalCatch.h"
#include "DGtal/helpers/StdDefs.h"
#include "DGtal/shapes/parametric/Lemniscate2D.h"
Include dependency graph for testLemniscate2D.cpp:

Go to the source code of this file.

Typedefs

typedef Lemniscate2D< SpaceShape
 

Functions

double notNullValue (std::uniform_real_distribution< double > &unif, std::default_random_engine &re)
 
RealPoint notNullRealPoint (std::uniform_real_distribution< double > &unif, std::default_random_engine &re)
 
 TEST_CASE ("Lemniscate2D")
 

Detailed Description

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Author
Adrien Krähenbühl (krahe.nosp@m.nbuh.nosp@m.l@uni.nosp@m.stra.nosp@m..fr ) Laboratoire ICube, UMR 7357, Université de Strasbourg, France
Date
2019/07/18

Functions for testing the methods of the Lemniscate2D shape. In particular, test the x(), xp() and xpp() methods for cases leadind to a division by 0.

This file is part of the DGtal library.

Definition in file testLemniscate2D.cpp.

Typedef Documentation

◆ Shape

Definition at line 44 of file testLemniscate2D.cpp.

Function Documentation

◆ notNullRealPoint()

RealPoint notNullRealPoint ( std::uniform_real_distribution< double > &  unif,
std::default_random_engine &  re 
)

Definition at line 58 of file testLemniscate2D.cpp.

61 {
62  return RealPoint(notNullValue(unif,re),notNullValue(unif,re));
63 }
double notNullValue(std::uniform_real_distribution< double > &unif, std::default_random_engine &re)
PointVector< 3, double > RealPoint

References notNullValue().

◆ notNullValue()

double notNullValue ( std::uniform_real_distribution< double > &  unif,
std::default_random_engine &  re 
)

Definition at line 46 of file testLemniscate2D.cpp.

49 {
50  double res;
51  do {
52  res = unif(re);
53  }
54  while ( res == Approx(0.) );
55  return res;
56 }

Referenced by notNullRealPoint().

◆ TEST_CASE()

TEST_CASE ( "Lemniscate2D"  )

Definition at line 65 of file testLemniscate2D.cpp.

66 {
67  std::uniform_real_distribution<double> unif(-10000,10000);
68  std::default_random_engine re;
69 
70  SECTION("center()")
71  {
72  const RealPoint center(unif(re),unif(re));
73  Shape shape( center, unif(re) );
74  REQUIRE( shape.center() == center );
75  }
76 
77  SECTION("Lower and upper bounds")
78  {
79  Shape shape( unif(re), unif(re), unif(re) );
80  REQUIRE( shape.getLowerBound() <= shape.getUpperBound() );
81  }
82 
83  SECTION("x() with Pi parameter.")
84  {
85  Shape shape( unif(re), unif(re), unif(re) );
86  REQUIRE_NOTHROW( shape.x(M_PI) );
87  }
88 
89  SECTION("x() with Pi parameter -> division by 0.")
90  {
91  Shape shape( unif(re), unif(re), unif(re) );
92  REQUIRE_NOTHROW( shape.x(M_PI) );
93  }
94 
95  SECTION("xp() with Pi parameter -> division by 0.")
96  {
97  Shape shape( unif(re), unif(re), unif(re) );
98  REQUIRE_NOTHROW( shape.xp(M_PI) );
99  }
100 
101  SECTION("xpp() with Pi parameter -> division by 0.")
102  {
103  Shape shape( unif(re), unif(re), unif(re) );
104  REQUIRE_NOTHROW( shape.xp(M_PI) );
105  }
106 }
Aim: Implements basic operations that will be used in Point and Vector classes.
Definition: PointVector.h:593
Point center(const std::vector< Point > &points)
SECTION("Testing constant forward iterators")
REQUIRE(domain.isInside(aPoint))

References DGtal::Astroid2D< TSpace >::center(), DGtal::Astroid2D< TSpace >::getLowerBound(), DGtal::Astroid2D< TSpace >::getUpperBound(), REQUIRE(), SECTION(), DGtal::Astroid2D< TSpace >::x(), and DGtal::Astroid2D< TSpace >::xp().