Testing: add test for 'element' accessor

This commit is contained in:
Shahram Najm 2021-03-11 16:02:20 +00:00
parent 944a7838ee
commit 519409b94a
3 changed files with 32 additions and 0 deletions

View File

@ -70,6 +70,7 @@ if( HAVE_BUILD_TOOLS )
grib_packing_order
filter_substr
grib_uerra
grib_element
grib_2nd_order_numValues
grib_ecc-136
grib_ecc-966

View File

@ -53,6 +53,7 @@ TESTS = definitions.sh \
grib_level.sh \
grib_indexing.sh \
grib_list.sh \
grib_element.sh \
grib_second_order.sh \
grib_change_scanning.sh \
julian.sh \

30
tests/grib_element.sh Executable file
View File

@ -0,0 +1,30 @@
#!/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
label="grib_element_test"
tempRef=temp.${label}.ref
tempText=temp.${label}.txt
tempFilt=temp.${label}.filt
# Print the last three entries from the "pl" array
cat > $tempFilt <<EOF
meta elemA element(pl, Nj - 3);
meta elemB element(pl, Nj - 2);
meta elemC element(pl, Nj - 1);
print "elemA=[elemA], elemB=[elemB], elemC=[elemC]";
EOF
input=$ECCODES_SAMPLES_PATH/reduced_gg_pl_48_grib2.tmpl
${tools_dir}/grib_filter $tempFilt $input > $tempText
echo "elemA=36, elemB=25, elemC=20" > $tempRef
diff $tempRef $tempText
rm -f $tempRef $tempText $tempFilt