From 8dc64c35c6b13b168bfc2855fa3e2b05922f7981 Mon Sep 17 00:00:00 2001 From: shahramn Date: Fri, 8 Mar 2024 15:13:17 +0000 Subject: [PATCH] Testing: BUFR headers and key comparisons --- tests/bufr_extract_headers.sh | 34 ++++++++++++++++++++++++++++++++++ tests/codes_compare_keys.cc | 2 ++ tests/codes_compare_keys.sh | 2 ++ 3 files changed, 38 insertions(+) diff --git a/tests/bufr_extract_headers.sh b/tests/bufr_extract_headers.sh index a20602391..0d518d732 100755 --- a/tests/bufr_extract_headers.sh +++ b/tests/bufr_extract_headers.sh @@ -199,4 +199,38 @@ status=$? set -e [ $status -ne 0 ] + +echo "Test with nonexistent file..." +# --------------------------------- +set +e +$EXEC ${test_dir}/bufr_extract_headers centre nosuchfile > $temp1 2>&1 +status=$? +set -e +[ $status -ne 0 ] +grep -q "Unable to read file" $temp1 + + +echo "Test with bad BUFR file..." +# --------------------------------- +echo BUFR > $temp1 +set +e +$EXEC ${test_dir}/bufr_extract_headers centre $temp1 > $temp2 2>&1 +status=$? +set -e +[ $status -ne 0 ] +grep -q "Unable to count BUFR messages" $temp2 + + +echo "Test with GRIB file..." +# --------------------------------- +input=${data_dir}/sample.grib2 +set +e +$EXEC ${test_dir}/bufr_extract_headers centre $input > $temp2 2>&1 +status=$? +set -e +[ $status -ne 0 ] +grep -q "No BUFR messages in file" $temp2 + + +# Clean up rm -f $temp1 $temp2 diff --git a/tests/codes_compare_keys.cc b/tests/codes_compare_keys.cc index 116998de7..2b930ea11 100644 --- a/tests/codes_compare_keys.cc +++ b/tests/codes_compare_keys.cc @@ -54,6 +54,8 @@ int main(int argc, char* argv[]) codes_compare_key(h1, h2, "computeStatistics", 0); // statistics codes_compare_key(h1, h2, "paramId", 0); // concept codes_compare_key(h1, h2, "identifier", 0); // ascii + err = codes_compare_key(h1, h2, "abcdefghij", 0); // no such key + Assert(err == GRIB_NOT_FOUND); if (list_provided_keys) { for (i = 0; list_provided_keys[i] != NULL; ++i) { diff --git a/tests/codes_compare_keys.sh b/tests/codes_compare_keys.sh index 1a678ede8..b07e6edc0 100755 --- a/tests/codes_compare_keys.sh +++ b/tests/codes_compare_keys.sh @@ -37,6 +37,7 @@ key: hoursAfterDataCutoff (Long values are different) key: minutesAfterDataCutoff (Long values are different) key: numberOfValues (Long values are different) key: referenceValue (Double values are different) +ECCODES ERROR : Key abcdefghij not found in first message Comparison failed: 13 differences EOF @@ -57,6 +58,7 @@ cat $tempLog cat > $tempRef <