DGtal  1.3.beta
testParameters.cpp
Go to the documentation of this file.
1 
30 #include <iostream>
32 #include <string>
33 #include "DGtal/base/Common.h"
34 #include "DGtal/helpers/Parameters.h"
35 
36 #include "DGtalCatch.h"
38 
39 using namespace std;
40 using namespace DGtal;
41 
42 
44 // Functions for testing class Parameters
46 
47 SCENARIO( "Parameters decimal conversion tests", "[parameters]" )
48 {
49  GIVEN( "A Parameters object" ) {
50  Parameters params;
51  WHEN( "initialized with strings" ) {
52  params( "foo", "bar" )( "Laurel", "Hardy" );
53  THEN( "it does store strings" ) {
54  REQUIRE( params[ "foo" ].as<string>() == "bar" );
55  REQUIRE( params[ "Laurel" ].as<string>() == "Hardy" );
56  }
57  }
58  WHEN( "initialized with integers" ) {
59  params( "prime", 7 )( "negative-int", -2 );
60  THEN( "it does store ints" ) {
61  REQUIRE( params[ "prime" ].as<int>() == 7 );
62  REQUIRE( params[ "negative-int" ].as<int>() == -2 );
63  }
64  }
65  WHEN( "initialized with doubles" ) {
66  params( "pi", 3.14159 )( "planck", 6.62607004e-34 )( "g", 9.80665 );
67  THEN( "it does store ints" ) {
68  REQUIRE( params[ "pi" ].as<double>() == Approx( 3.14159 ) );
69  REQUIRE( params[ "planck" ].as<double>() == Approx( 6.62607004e-34 ) );
70  REQUIRE( params[ "g" ].as<double>() == Approx( 9.80665 ) );
71  }
72  }
73  }
74 }
REQUIRE
REQUIRE(domain.isInside(aPoint))
SCENARIO
SCENARIO("Parameters decimal conversion tests", "[parameters]")
Definition: testParameters.cpp:47
DGtal::Parameters
Definition: Parameters.h:146
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
GIVEN
GIVEN("A cubical complex with random 3-cells")
Definition: testCubicalComplex.cpp:70