mirror of https://github.com/ecmwf/eccodes.git
ECC-1764: Add test
This commit is contained in:
parent
07382ee77f
commit
4f446ffc61
|
@ -45,6 +45,7 @@ list(APPEND test_c_bins
|
||||||
grib_ecc-1467
|
grib_ecc-1467
|
||||||
grib_ecc-1431
|
grib_ecc-1431
|
||||||
grib_ecc-1433
|
grib_ecc-1433
|
||||||
|
grib_ecc-1764
|
||||||
bufr_ecc-517
|
bufr_ecc-517
|
||||||
bufr_ecc-1288
|
bufr_ecc-1288
|
||||||
bufr_get_element
|
bufr_get_element
|
||||||
|
@ -259,6 +260,7 @@ if( HAVE_BUILD_TOOLS )
|
||||||
grib_ecc-1397
|
grib_ecc-1397
|
||||||
grib_ecc-1425
|
grib_ecc-1425
|
||||||
grib_ecc-1467
|
grib_ecc-1467
|
||||||
|
grib_ecc-1764
|
||||||
grib_sub_hourly
|
grib_sub_hourly
|
||||||
grib_set_bytes
|
grib_set_bytes
|
||||||
grib_set_force
|
grib_set_force
|
||||||
|
|
|
@ -0,0 +1,44 @@
|
||||||
|
/*
|
||||||
|
* (C) Copyright 2005- ECMWF.
|
||||||
|
*
|
||||||
|
* This software is licensed under the terms of the Apache Licence Version 2.0
|
||||||
|
* which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
|
||||||
|
*
|
||||||
|
* In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
|
||||||
|
* virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
||||||
|
*/
|
||||||
|
#include "grib_api.h"
|
||||||
|
#undef NDEBUG
|
||||||
|
#include "assert.h"
|
||||||
|
|
||||||
|
int main(int argc, char* argv[])
|
||||||
|
{
|
||||||
|
int ret = GRIB_SUCCESS;
|
||||||
|
|
||||||
|
if (argc != 2) return 1;
|
||||||
|
|
||||||
|
const char* infile = argv[1];
|
||||||
|
grib_index* index = grib_index_new(0, "shortName,level", &ret);
|
||||||
|
assert(ret == GRIB_SUCCESS);
|
||||||
|
|
||||||
|
ret = grib_index_add_file(index, infile);
|
||||||
|
assert(ret == GRIB_SUCCESS);
|
||||||
|
|
||||||
|
printf("Select nonexistent entries...\n");
|
||||||
|
grib_index_select_string(index, "shortName", "frost");
|
||||||
|
grib_index_select_long(index, "level", 666);
|
||||||
|
|
||||||
|
grib_handle* h = grib_handle_new_from_index(index, &ret);
|
||||||
|
assert(!h);
|
||||||
|
assert(ret == GRIB_END_OF_INDEX);
|
||||||
|
|
||||||
|
// Call it again. Should not crash
|
||||||
|
h = grib_handle_new_from_index(index, &ret);
|
||||||
|
assert(!h);
|
||||||
|
assert(ret == GRIB_END_OF_INDEX);
|
||||||
|
|
||||||
|
grib_index_delete(index);
|
||||||
|
grib_context_delete(grib_context_get_default());
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
#!/bin/sh
|
||||||
|
# (C) Copyright 2005- ECMWF.
|
||||||
|
#
|
||||||
|
# This software is licensed under the terms of the Apache Licence Version 2.0
|
||||||
|
# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
|
||||||
|
#
|
||||||
|
# In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
|
||||||
|
# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
||||||
|
#
|
||||||
|
|
||||||
|
. ./include.ctest.sh
|
||||||
|
|
||||||
|
label="grib_ecc-1764_test"
|
||||||
|
temp=temp.$label.txt
|
||||||
|
|
||||||
|
infile=${data_dir}/tigge_cf_ecmwf.grib2
|
||||||
|
$EXEC ${test_dir}/grib_ecc-1764 $infile # > $temp
|
||||||
|
|
||||||
|
# Clean up
|
||||||
|
rm -f $temp
|
Loading…
Reference in New Issue