GRASS Programmer's Manual
6.4.2(2012)
Main Page
Related Pages
Namespaces
Data Structures
Files
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Pages
test_main.c
Go to the documentation of this file.
1
2
/****************************************************************************
3
*
4
* MODULE: test.gpde.lib
5
*
6
* AUTHOR(S): Original author
7
* Soeren Gebbert soerengebbert <at> gmx <dot> de
8
* 27 11 2006 Berlin
9
*
10
* PURPOSE: Unit and integration tests for the gpde library
11
*
12
* COPYRIGHT: (C) 2006 by the GRASS Development Team
13
*
14
* This program is free software under the GNU General Public
15
* License (>=v2). Read the file COPYING that comes with GRASS
16
* for details.
17
*
18
*****************************************************************************/
19
#include <stdlib.h>
20
#include <string.h>
21
#include <grass/gis.h>
22
#include <grass/glocale.h>
23
#include <grass/N_pde.h>
24
#include "
test_gpde_lib.h
"
25
26
27
/*- Parameters and global variables -----------------------------------------*/
28
typedef
struct
29
{
30
struct
Option *
unit
, *integration;
31
struct
Flag *full, *
testunit
, *testint;
32
}
paramType
;
33
34
paramType
param
;
/*Parameters */
35
36
/*- prototypes --------------------------------------------------------------*/
37
static
void
set_params(
void
);
/*Fill the paramType structure */
38
39
/* ************************************************************************* */
40
/* Set up the arguments we are expecting ********************************** */
41
/* ************************************************************************* */
42
void
set_params(
void
)
43
{
44
param.
unit
=
G_define_option
();
45
param.
unit
->key =
"unit"
;
46
param.
unit
->type = TYPE_STRING;
47
param.
unit
->required = NO;
48
param.
unit
->options =
"array,assemble,geom,gradient,les,solver,tools"
;
49
param.
unit
->description = _(
"Choose the unit tests to run"
);
50
51
param.
integration
=
G_define_option
();
52
param.
integration
->key =
"integration"
;
53
param.
integration
->type = TYPE_STRING;
54
param.
integration
->required = NO;
55
param.
integration
->options =
"gwflow,heatflow,transport"
;
56
param.
integration
->description = _(
"Choose the integration tests to run"
);
57
58
59
param.
testunit
=
G_define_flag
();
60
param.
testunit
->key =
'u'
;
61
param.
testunit
->description = _(
"Run all unit tests"
);
62
63
param.
testint
=
G_define_flag
();
64
param.
testint
->key =
'i'
;
65
param.
testint
->description = _(
"Run all integration tests"
);
66
67
param.
full
=
G_define_flag
();
68
param.
full
->key =
'a'
;
69
param.
full
->description = _(
"Run all unit and integration tests"
);
70
71
}
72
73
/* ************************************************************************* */
74
/* Main function, open the G3D map and create the raster maps ************** */
75
/* ************************************************************************* */
76
int
main
(
int
argc,
char
*argv[])
77
{
78
struct
GModule *module;
79
int
returnstat = 0, i;
80
81
/* Initialize GRASS */
82
G_gisinit(argv[0]);
83
84
module =
G_define_module
();
85
module->keywords = _(
"test, gpde"
);
86
module->description =
87
_(
"Performs unit and integration tests for gpde library"
);
88
89
/* Get parameters from user */
90
set_params();
91
92
if
(
G_parser
(argc, argv))
93
exit(EXIT_FAILURE);
94
95
96
/*Run the unit tests */
97
if
(param.
testunit
->answer || param.
full
->answer) {
98
returnstat +=
unit_test_arrays
();
99
returnstat +=
unit_test_assemble
();
100
returnstat +=
unit_test_gradient
();
101
returnstat +=
unit_test_geom_data
();
102
returnstat +=
unit_test_les_creation
();
103
returnstat +=
unit_test_solvers
();
104
returnstat +=
unit_test_tools
();
105
106
}
107
108
/*Run the integration tests */
109
if
(param.
testint
->answer || param.
full
->answer) {
110
returnstat +=
integration_test_gwflow
();
111
returnstat +=
integration_test_solute_transport
();
112
}
113
114
/*Run single tests */
115
if
(!param.
full
->answer) {
116
/*unit tests */
117
if
(!param.
testunit
->answer) {
118
i = 0;
119
if
(param.
unit
->answers)
120
while
(param.
unit
->answers[i]) {
121
if
(strcmp(param.
unit
->answers[i],
"array"
) == 0)
122
returnstat +=
unit_test_arrays
();
123
124
if
(strcmp(param.
unit
->answers[i],
"assemble"
) == 0)
125
returnstat +=
unit_test_assemble
();
126
127
if
(strcmp(param.
unit
->answers[i],
"gradient"
) == 0)
128
returnstat +=
unit_test_gradient
();
129
130
if
(strcmp(param.
unit
->answers[i],
"geom"
) == 0)
131
returnstat +=
unit_test_geom_data
();
132
133
if
(strcmp(param.
unit
->answers[i],
"les"
) == 0)
134
returnstat +=
unit_test_les_creation
();
135
136
if
(strcmp(param.
unit
->answers[i],
"solver"
) == 0)
137
returnstat +=
unit_test_solvers
();
138
139
if
(strcmp(param.
unit
->answers[i],
"tools"
) == 0)
140
returnstat +=
unit_test_tools
();
141
142
i++;
143
}
144
}
145
/*integration tests */
146
if
(!param.
testint
->answer) {
147
i = 0;
148
if
(param.
integration
->answers)
149
while
(param.
integration
->answers[i]) {
150
if
(strcmp(param.
integration
->answers[i],
"gwflow"
) == 0)
151
returnstat +=
integration_test_gwflow
();
152
153
if
(strcmp(param.
integration
->answers[i],
"heatflow"
) == 0) ;
/*nothing to do for now */
154
155
if
(strcmp(param.
integration
->answers[i],
"transport"
) ==
156
0)
157
returnstat +=
integration_test_solute_transport
();
158
159
i++;
160
}
161
162
}
163
}
164
165
if
(returnstat != 0)
166
G_warning
(
"Errors detected while testing the gpde lib"
);
167
else
168
G_message
(
"\n-- gpde lib tests finished successfully --"
);
169
170
return
(returnstat);
171
}
lib
gpde
test
test_main.c
Generated on Sun Sep 9 2012 18:55:35 for GRASS Programmer's Manual by
1.8.1.2