Testing: add test for 'suppressed' accessor

This commit is contained in:
Shahram Najm 2021-12-16 12:21:53 +00:00
parent 19d695e531
commit e178c99874
3 changed files with 58 additions and 13 deletions

View File

@ -147,15 +147,15 @@ static void log_message(grib_accessor* a)
{
grib_accessor_suppressed* self = (grib_accessor_suppressed*)a;
int i = 0;
grib_handle* hand = grib_handle_of_accessor(a);
grib_context_log(a->context, GRIB_LOG_ERROR,
"key %s is unavailable in this version.", a->name);
"key '%s' is unavailable in this version.", a->name);
grib_context_log(a->context, GRIB_LOG_ERROR,
"Please use the following keys:");
while (grib_arguments_get_name(grib_handle_of_accessor(a), self->args, i)) {
grib_context_log(a->context, GRIB_LOG_ERROR,
"\t- %s",
grib_arguments_get_name(grib_handle_of_accessor(a), self->args, i));
"Please use the following key(s):");
while (grib_arguments_get_name(hand, self->args, i)) {
grib_context_log(a->context, GRIB_LOG_ERROR, "\t- %s",
grib_arguments_get_name(hand, self->args, i));
i++;
}
}
@ -163,37 +163,37 @@ static void log_message(grib_accessor* a)
static int pack_string(grib_accessor* a, const char* val, size_t* len)
{
log_message(a);
return GRIB_NOT_IMPLEMENTED;
return GRIB_NOT_FOUND;
}
static int pack_long(grib_accessor* a, const long* val, size_t* len)
{
log_message(a);
return GRIB_NOT_IMPLEMENTED;
return GRIB_NOT_FOUND;
}
static int pack_double(grib_accessor* a, const double* val, size_t* len)
{
log_message(a);
return GRIB_NOT_IMPLEMENTED;
return GRIB_NOT_FOUND;
}
static int unpack_string(grib_accessor* a, char* val, size_t* len)
{
/*log_message(a);*/
return GRIB_NOT_IMPLEMENTED;
log_message(a);
return GRIB_NOT_FOUND;
}
static int unpack_long(grib_accessor* a, long* val, size_t* len)
{
log_message(a);
return GRIB_NOT_IMPLEMENTED;
return GRIB_NOT_FOUND;
}
static int unpack_double(grib_accessor* a, double* val, size_t* len)
{
log_message(a);
return GRIB_NOT_IMPLEMENTED;
return GRIB_NOT_FOUND;
}
static int value_count(grib_accessor* a, long* count)

View File

@ -73,6 +73,7 @@ if( HAVE_BUILD_TOOLS )
filter_substr
grib_uerra
grib_element
grib_suppressed
grib_2nd_order_numValues
grib_ecc-136
grib_ecc-922

44
tests/grib_suppressed.sh Executable file
View File

@ -0,0 +1,44 @@
#!/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.sh
set -u
label="grib_suppressed-test"
tempErr=temp.${label}.err
tempFilt=temp.${label}.filt
tempRef=temp.${label}.ref
sample2=$ECCODES_SAMPLES_PATH/GRIB2.tmpl
cat > $tempFilt <<EOF
meta a_deprecated_key suppressed(typeOfOriginalFieldValues);
print "[a_deprecated_key]";
EOF
set +e
${tools_dir}/grib_filter $tempFilt $sample2 2>$tempErr
status=$?
set -e
[ $status -ne 0 ]
cat $tempErr
cat > $tempRef <<EOF
ECCODES ERROR : key 'a_deprecated_key' is unavailable in this version.
ECCODES ERROR : Please use the following key(s):
ECCODES ERROR : - typeOfOriginalFieldValues
EOF
diff $tempRef $tempErr
# Clean up
rm -f $tempFilt $tempErr $tempRef