File: TePDIParameters_test.cpp

package info (click to toggle)
libterralib 4.3.0%2Bdfsg.2-14
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 61,564 kB
  • sloc: cpp: 225,052; ansic: 31,562; makefile: 807; sh: 80; xml: 37
file content (69 lines) | stat: -rw-r--r-- 2,088 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#define TEAGN_ENABLE_STDOUT_LOG

#include <TePDIParameters.hpp>
#include <TeAgnostic.h>

int main()
{
  TEAGN_LOGMSG( "Test started." );

  try{
    TePDIParameters params_copy;
    
    const int x1_int = 1;
    const double x1_double = 1;
    
    {
      TePDIParameters params;
      
      params.SetParameter( "int", x1_int );
      params.SetParameter( "double", x1_double );    
      
      TEAGN_TRUE_OR_THROW( params.CheckParameter< int >( "int" ), "" )
      TEAGN_TRUE_OR_THROW( params.CheckParameter< double >( "double" ), "" )
      
      int x2_int = 0;
      TEAGN_TRUE_OR_THROW( params.GetParameter( "int", x2_int ),
        "Missing parameter" );    
      TEAGN_CHECK_EPS( x2_int, x1_int, 0, "" )
      
      double x2_double = 0;
      TEAGN_TRUE_OR_THROW( params.GetParameter( "double", 
        x2_double ), "Missing parameter" );
      TEAGN_CHECK_EPS( x2_double, x1_double, 0, "" )      
      
      params_copy = params;
      
      TEAGN_TRUE_OR_THROW( ( params_copy == params ),
        "Invalid ==operator result" )
    }
    
    TEAGN_TRUE_OR_THROW( params_copy.CheckParameter< int >( "int" ), "" )
    TEAGN_TRUE_OR_THROW( params_copy.CheckParameter< double >( "double" ), "" )
    
    int x2_int = 0;
    TEAGN_TRUE_OR_THROW( params_copy.GetParameter( "int", x2_int ),
      "Missing paramter" );    
    TEAGN_CHECK_EPS( x2_int, x1_int, 0, "" )
    
    double x2_double = 0;
    TEAGN_TRUE_OR_THROW( params_copy.GetParameter( "double", 
      x2_double ), "Missing parameter" );
    TEAGN_CHECK_EPS( x2_double, x1_double, 0, "" )
    
    /* Checking parameter remotion */
    
    TEAGN_TRUE_OR_THROW( params_copy.CheckParameter< double >( 
      "double" ), "" )
    params_copy.RemoveParameter( "double" );
    TEAGN_TRUE_OR_THROW( ! params_copy.CheckParameter< double >( 
      "double" ), "" )    
  }
  catch( const TeException& e ){
    TEAGN_LOGERR( "Test Failed - " + e.message() );
    return EXIT_FAILURE;
  }  

  TEAGN_LOGMSG( "Test OK." );
  return EXIT_SUCCESS;
}