diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index bbaa944af..98a13d72e 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -36,6 +36,7 @@ list(APPEND test_bins bufr_extract_headers extract_offsets bufr_check_descriptors + codes_new_from_samples grib_sh_ieee64 grib_ieee grib_set_bytes @@ -245,6 +246,7 @@ if( HAVE_BUILD_TOOLS ) grib_statistics grib_tigge_check read_any + codes_new_from_samples grib_dump grib_dump_debug grib_dump_json diff --git a/tests/codes_new_from_samples.c b/tests/codes_new_from_samples.c new file mode 100644 index 000000000..634c9837a --- /dev/null +++ b/tests/codes_new_from_samples.c @@ -0,0 +1,66 @@ +/* + * (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 +#include "eccodes.h" + +typedef struct sample_t { + const char* sample_name; + ProductKind expected_kind; +} sample_t; + +static sample_t samples[] = { + {"GRIB1", PRODUCT_GRIB}, + {"GRIB2", PRODUCT_GRIB}, + {"reduced_gg_pl_256_grib1", PRODUCT_GRIB}, + {"reduced_gg_pl_256_grib2", PRODUCT_GRIB}, + {"sh_ml_grib1.tmpl", PRODUCT_GRIB}, + {"sh_ml_grib2.tmpl", PRODUCT_GRIB}, + + {"diag", PRODUCT_GRIB}, /* pseudo GRIBs */ + {"budg", PRODUCT_GRIB}, + + {"BUFR4_local_satellite", PRODUCT_BUFR}, + {"BUFR4_local", PRODUCT_BUFR}, + {"BUFR4", PRODUCT_BUFR}, + {"BUFR3", PRODUCT_BUFR} +}; + +#define NUMBER(a) sizeof(a)/sizeof(a[0]) + +int main(int argc, char** argv) +{ + codes_handle* h = NULL; + size_t i = 0; + + for (i=0; i