mirror of https://github.com/ecmwf/eccodes.git
Comparison of accessors: Add test
This commit is contained in:
parent
bd62688189
commit
f0cbdfd3b3
|
@ -282,6 +282,7 @@ if( HAVE_BUILD_TOOLS )
|
||||||
read_any
|
read_any
|
||||||
codes_new_from_samples
|
codes_new_from_samples
|
||||||
codes_set_samples_path
|
codes_set_samples_path
|
||||||
|
codes_compare_keys
|
||||||
grib_dump
|
grib_dump
|
||||||
grib_dump_debug
|
grib_dump_debug
|
||||||
grib_dump_json
|
grib_dump_json
|
||||||
|
|
|
@ -27,8 +27,8 @@ int main(int argc, char* argv[])
|
||||||
while ((h1 = grib_handle_new_from_file(0, f1, &err)) != NULL && (h2 = grib_handle_new_from_file(0, f2, &err)) != NULL) {
|
while ((h1 = grib_handle_new_from_file(0, f1, &err)) != NULL && (h2 = grib_handle_new_from_file(0, f2, &err)) != NULL) {
|
||||||
grib_keys_iterator* kiter = NULL;
|
grib_keys_iterator* kiter = NULL;
|
||||||
|
|
||||||
/* Use namespace of NULL to get ALL keys */
|
// Use namespace of NULL to get ALL keys
|
||||||
/* Set flags to 0 to not filter any keys */
|
// Set flags to 0 to not filter any keys
|
||||||
//kiter = grib_keys_iterator_new(h1, /*flags=*/0, /*namespace=*/NULL);
|
//kiter = grib_keys_iterator_new(h1, /*flags=*/0, /*namespace=*/NULL);
|
||||||
kiter = grib_keys_iterator_new(h1, /*flags=*/GRIB_KEYS_ITERATOR_SKIP_COMPUTED, /*namespace=*/NULL);
|
kiter = grib_keys_iterator_new(h1, /*flags=*/GRIB_KEYS_ITERATOR_SKIP_COMPUTED, /*namespace=*/NULL);
|
||||||
Assert(kiter);
|
Assert(kiter);
|
||||||
|
@ -36,10 +36,9 @@ int main(int argc, char* argv[])
|
||||||
while (grib_keys_iterator_next(kiter)) {
|
while (grib_keys_iterator_next(kiter)) {
|
||||||
const char* name = grib_keys_iterator_get_name(kiter);
|
const char* name = grib_keys_iterator_get_name(kiter);
|
||||||
Assert(name);
|
Assert(name);
|
||||||
//printf("Comparing key '%s' ...\n", name);
|
|
||||||
err = codes_compare_key(h1, h2, name, 0);
|
err = codes_compare_key(h1, h2, name, 0);
|
||||||
if (err) {
|
if (err) {
|
||||||
printf("key: %s (%s)\n", name, grib_get_error_message(err));
|
fprintf(stderr, "key: %s (%s)\n", name, grib_get_error_message(err));
|
||||||
failed = 1;
|
failed = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -51,7 +50,7 @@ int main(int argc, char* argv[])
|
||||||
fclose(f1);
|
fclose(f1);
|
||||||
fclose(f2);
|
fclose(f2);
|
||||||
if (failed) {
|
if (failed) {
|
||||||
fprintf(stderr, "\nComparison failed: One or more keys different\n");
|
fprintf(stderr, "\nComparison failed: One or more keys are different\n");
|
||||||
}
|
}
|
||||||
return err;
|
return failed;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,45 @@
|
||||||
|
#!/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.ctest.sh
|
||||||
|
|
||||||
|
label="codes_compare_keys_test"
|
||||||
|
tempRef=temp.${label}.ref
|
||||||
|
tempLog=temp.$label.log
|
||||||
|
|
||||||
|
file1=$ECCODES_SAMPLES_PATH/reduced_gg_pl_32_grib2.tmpl
|
||||||
|
file2=$ECCODES_SAMPLES_PATH/reduced_gg_pl_48_grib2.tmpl
|
||||||
|
set +e
|
||||||
|
$EXEC ${test_dir}/codes_compare_keys $file1 $file2 > $tempLog 2>&1
|
||||||
|
status=$?
|
||||||
|
set -e
|
||||||
|
[ $status -ne 0 ]
|
||||||
|
|
||||||
|
cat > $tempRef <<EOF
|
||||||
|
key: totalLength (Long values are different)
|
||||||
|
key: section3Length (Long values are different)
|
||||||
|
key: numberOfDataPoints (Long values are different)
|
||||||
|
key: Nj (Long values are different)
|
||||||
|
key: latitudeOfFirstGridPoint (Long values are different)
|
||||||
|
key: latitudeOfLastGridPoint (Long values are different)
|
||||||
|
key: longitudeOfLastGridPoint (Long values are different)
|
||||||
|
key: N (Long values are different)
|
||||||
|
key: pl (Count mismatch)
|
||||||
|
key: hoursAfterDataCutoff (Long values are different)
|
||||||
|
key: minutesAfterDataCutoff (Long values are different)
|
||||||
|
key: numberOfValues (Long values are different)
|
||||||
|
key: referenceValue (Double values are different)
|
||||||
|
|
||||||
|
Comparison failed: One or more keys are different
|
||||||
|
EOF
|
||||||
|
|
||||||
|
diff $tempRef $tempLog
|
||||||
|
|
||||||
|
rm -f $tempLog $tempRef
|
Loading…
Reference in New Issue