diff --git a/tests/grib_util_set_spec.c b/tests/grib_util_set_spec.c index fc28a9d64..d4884f72f 100644 --- a/tests/grib_util_set_spec.c +++ b/tests/grib_util_set_spec.c @@ -11,6 +11,7 @@ #include "grib_api_internal.h" #include "eccodes.h" #include +#include #define STR_EQUAL(s1, s2) (strcmp((s1), (s2)) == 0) @@ -102,6 +103,21 @@ static void test_reduced_gg(int remove_local_def, int edition, const char* packi assert(finalh); assert(err == 0); + /* Try some invalid inputs and check it is handled */ + { + codes_handle *h2 = 0; + packing_spec.accuracy=999; + h2 = grib_util_set_spec(handle, &spec, &packing_spec, set_spec_flags, values, outlen, &err); + assert(err == GRIB_INTERNAL_ERROR); + assert(!h2); + + packing_spec.accuracy=GRIB_UTIL_ACCURACY_USE_PROVIDED_BITS_PER_VALUES; + values[0] = INFINITY; + h2 = grib_util_set_spec(handle, &spec, &packing_spec, set_spec_flags, values, outlen, &err); + assert(err == GRIB_ENCODING_ERROR); + assert(!h2); + } + /* Write out the message to the output file */ CODES_CHECK(grib_get_message(finalh, &buffer, &size),0); if(fwrite(buffer,1,size,out) != size) {