File: TePDIMathFunctions_test.cpp

package info (click to toggle)
libterralib 4.3.0%2Bdfsg.1-2
  • links: PTS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 70,928 kB
  • sloc: cpp: 254,330; ansic: 82,910; makefile: 814; sh: 80; xml: 37
file content (117 lines) | stat: -rw-r--r-- 3,273 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#define TEAGN_ENABLE_STDOUT_LOG

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


void DecimLevels_test()
{
  TEAGN_TRUE_OR_THROW( 
    ( TePDIMathFunctions::DecimLevels( 0 ) == 0 ),
    "Invalid result" );
  TEAGN_TRUE_OR_THROW( 
    ( TePDIMathFunctions::DecimLevels( 1 ) == 0 ),
    "Invalid result" );
  TEAGN_TRUE_OR_THROW( 
    ( TePDIMathFunctions::DecimLevels( 2 ) == 1 ),
    "Invalid result" );
  TEAGN_TRUE_OR_THROW( 
    ( TePDIMathFunctions::DecimLevels( 3 ) == 2 ),
    "Invalid result" );
  TEAGN_TRUE_OR_THROW( 
    ( TePDIMathFunctions::DecimLevels( 4 ) == 2 ),
    "Invalid result" );
}


void DecimLevelSize_test()
{
  TEAGN_TRUE_OR_THROW( 
    ( TePDIMathFunctions::DecimLevelSize( 1, 2 ) == 1 ),
    "Invalid result" );
    
  TEAGN_TRUE_OR_THROW( 
    ( TePDIMathFunctions::DecimLevelSize( 1, 3 ) == 2 ),
    "Invalid result" );
  TEAGN_TRUE_OR_THROW( 
    ( TePDIMathFunctions::DecimLevelSize( 2, 3 ) == 1 ),
    "Invalid result" );
    
  TEAGN_TRUE_OR_THROW( 
    ( TePDIMathFunctions::DecimLevelSize( 1, 4 ) == 2 ),
    "Invalid result" );
  TEAGN_TRUE_OR_THROW( 
    ( TePDIMathFunctions::DecimLevelSize( 2, 4 ) == 1 ),
    "Invalid result" );

  TEAGN_TRUE_OR_THROW( 
    ( TePDIMathFunctions::DecimLevelSize( 1, 5 ) == 3 ),
    "Invalid result" );
  TEAGN_TRUE_OR_THROW( 
    ( TePDIMathFunctions::DecimLevelSize( 2, 5 ) == 2 ),
    "Invalid result" );
  TEAGN_TRUE_OR_THROW( 
    ( TePDIMathFunctions::DecimLevelSize( 3, 5 ) == 1 ),
    "Invalid result" );
    
  TEAGN_TRUE_OR_THROW( 
    ( TePDIMathFunctions::DecimLevelSize( 1, 6 ) == 3 ),
    "Invalid result" );
  TEAGN_TRUE_OR_THROW( 
    ( TePDIMathFunctions::DecimLevelSize( 2, 6 ) == 2 ),
    "Invalid result" );
  TEAGN_TRUE_OR_THROW( 
    ( TePDIMathFunctions::DecimLevelSize( 3, 6 ) == 1 ),
    "Invalid result" );
    
  TEAGN_TRUE_OR_THROW( 
    ( TePDIMathFunctions::DecimLevelSize( 1, 7 ) == 4 ),
    "Invalid result" );
  TEAGN_TRUE_OR_THROW( 
    ( TePDIMathFunctions::DecimLevelSize( 2, 7 ) == 2 ),
    "Invalid result" );
  TEAGN_TRUE_OR_THROW( 
    ( TePDIMathFunctions::DecimLevelSize( 3, 7 ) == 1 ),
    "Invalid result" );
    
  TEAGN_TRUE_OR_THROW( 
    ( TePDIMathFunctions::DecimLevelSize( 1, 8 ) == 4 ),
    "Invalid result" );
  TEAGN_TRUE_OR_THROW( 
    ( TePDIMathFunctions::DecimLevelSize( 2, 8 ) == 2 ),
    "Invalid result" );
  TEAGN_TRUE_OR_THROW( 
    ( TePDIMathFunctions::DecimLevelSize( 3, 8 ) == 1 ),
    "Invalid result" );
    
  TEAGN_TRUE_OR_THROW( 
    ( TePDIMathFunctions::DecimLevelSize( 1, 9 ) == 5 ),
    "Invalid result" );
  TEAGN_TRUE_OR_THROW( 
    ( TePDIMathFunctions::DecimLevelSize( 2, 9 ) == 3 ),
    "Invalid result" );
  TEAGN_TRUE_OR_THROW( 
    ( TePDIMathFunctions::DecimLevelSize( 3, 9 ) == 2 ),
    "Invalid result" );
  TEAGN_TRUE_OR_THROW( 
    ( TePDIMathFunctions::DecimLevelSize( 4, 9 ) == 1 ),
    "Invalid result" );
}


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

  try{
    DecimLevels_test();
    DecimLevelSize_test();
  }
  catch( const TeException& excpt ){
    TEAGN_LOGERR( excpt.message() )
    return EXIT_FAILURE;
  }

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