mirror of https://github.com/ecmwf/eccodes.git
ECC-403: C and Python API tests
This commit is contained in:
parent
15652829ff
commit
52f75237f6
|
@ -15,7 +15,7 @@
|
|||
*/
|
||||
|
||||
#include "eccodes.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
|
@ -26,6 +26,7 @@ int main(int argc, char* argv[])
|
|||
|
||||
double doubleVal;
|
||||
int err = 0;
|
||||
int is_missing = 0;
|
||||
int cnt = 0;
|
||||
const char* infile = "../../data/bufr/syno_1.bufr";
|
||||
|
||||
|
@ -51,7 +52,6 @@ int main(int argc, char* argv[])
|
|||
|
||||
/* the value of this key is missing in the message*/
|
||||
CODES_CHECK(codes_get_double(h, "relativeHumidity", &doubleVal), 0);
|
||||
printf(" relativeHumidity: %.2f\n", doubleVal);
|
||||
|
||||
/* we will print "value missing" */
|
||||
if (doubleVal == CODES_MISSING_DOUBLE) {
|
||||
|
@ -61,6 +61,10 @@ int main(int argc, char* argv[])
|
|||
printf(" --> value present\n");
|
||||
}
|
||||
|
||||
is_missing = codes_is_missing(h, "relativeHumidity", &err);
|
||||
assert(!err);
|
||||
assert(is_missing == 1);
|
||||
|
||||
/* delete handle */
|
||||
codes_handle_delete(h);
|
||||
|
||||
|
|
|
@ -60,6 +60,7 @@ def example():
|
|||
print(' %s: %s' % (key, codes_get(bufr, key)))
|
||||
except CodesInternalError as err:
|
||||
print('Error with key="%s" : %s' % (key, err.msg))
|
||||
assert codes_is_missing(bufr, key) == 0
|
||||
|
||||
# Native type float
|
||||
key = 'airTemperatureAt2M'
|
||||
|
@ -67,6 +68,7 @@ def example():
|
|||
print(' %s: %s' % (key, codes_get(bufr, key)))
|
||||
except CodesInternalError as err:
|
||||
print('Error with key="%s" : %s' % (key, err.msg))
|
||||
assert codes_is_missing(bufr, key) == 0
|
||||
|
||||
# Native type string
|
||||
key = 'typicalDate'
|
||||
|
@ -75,6 +77,9 @@ def example():
|
|||
except CodesInternalError as err:
|
||||
print('Error with key="%s" : %s' % (key, err.msg))
|
||||
|
||||
assert codes_is_missing(bufr, 'relativeHumidity') == 1
|
||||
assert codes_is_missing(bufr, '#5#cloudAmount') == 1
|
||||
|
||||
# --------------------------------
|
||||
# get values for an array
|
||||
# --------------------------------
|
||||
|
|
Loading…
Reference in New Issue