From 3fc47dcf77d405c0e9677b8dadcc680da904733d Mon Sep 17 00:00:00 2001 From: shahramn Date: Mon, 4 Mar 2024 20:45:39 +0000 Subject: [PATCH] Testing: Coverage --- tests/bufr_keys_iter.cc | 9 +-------- tests/gauss_sub.cc | 8 +------- tests/grib_clone_headers_only.cc | 9 ++------- tests/grib_ecc-1467.cc | 6 ++++-- tests/grib_ecc-1467.sh | 2 ++ tests/grib_fieldset.cc | 8 +------- tests/index_orderby.cc | 8 +------- tests/largefile.cc | 8 +------- 8 files changed, 13 insertions(+), 45 deletions(-) diff --git a/tests/bufr_keys_iter.cc b/tests/bufr_keys_iter.cc index f2ab295b7..9938fcdd5 100644 --- a/tests/bufr_keys_iter.cc +++ b/tests/bufr_keys_iter.cc @@ -12,12 +12,6 @@ #undef NDEBUG #include -static void usage(const char* prog) -{ - printf("usage: %s [-a|-d] infile\n", prog); - exit(1); -} - #define ITER_ALL_KEYS 1 #define ITER_DATA_KEYS 2 @@ -28,12 +22,11 @@ int main(int argc, char* argv[]) codes_handle* h = NULL; codes_bufr_keys_iterator* kiter = NULL; char* input_filename = NULL; - const char* prog = argv[0]; FILE* f = NULL; int iterator_mode = ITER_ALL_KEYS; if (argc == 1 || argc > 3) - usage(prog); + return 1; // usage: prog [-a|-d] infile for (i = 1; i < argc; i++) { if (strcmp(argv[i], "-a") == 0) { diff --git a/tests/gauss_sub.cc b/tests/gauss_sub.cc index b1114e964..b743b5d3c 100644 --- a/tests/gauss_sub.cc +++ b/tests/gauss_sub.cc @@ -10,12 +10,6 @@ #include "grib_api.h" -static void usage(char* prog) -{ - printf("usage: %s file1.grib file2.grib\n", prog); - exit(1); -} - int main(int argc, char* argv[]) { grib_handle *h1, *h2; @@ -34,7 +28,7 @@ int main(int argc, char* argv[]) c = grib_context_get_default(); - if (argc < 3) usage(argv[0]); + if (argc < 3) return 1;//usage: %s file1.grib file2.grib infile1 = argv[1]; infile2 = argv[2]; diff --git a/tests/grib_clone_headers_only.cc b/tests/grib_clone_headers_only.cc index f59b204ed..6a029b1ca 100644 --- a/tests/grib_clone_headers_only.cc +++ b/tests/grib_clone_headers_only.cc @@ -12,11 +12,6 @@ #undef NDEBUG #include -static void usage(const char* app) -{ - fprintf(stderr, "Usage is: %s input_file ouput_file\n", app); -} - int main(int argc, char* argv[]) { FILE* in = NULL; @@ -32,7 +27,7 @@ int main(int argc, char* argv[]) size_t messageLength_src = 0, messageLength_dst = 0; if (argc != 3) { - usage(argv[0]); + // Usage: prog input_file ouput_file return 1; } @@ -73,7 +68,7 @@ int main(int argc, char* argv[]) assert(isConstant_dst == 1); } - /* write out the cloned buffer */ + // write out the cloned buffer if (fwrite(buffer, 1, messageLength_dst, out) != messageLength_dst) { perror(argv[1]); return 1; diff --git a/tests/grib_ecc-1467.cc b/tests/grib_ecc-1467.cc index 3e20bdb08..5c5e8e53b 100644 --- a/tests/grib_ecc-1467.cc +++ b/tests/grib_ecc-1467.cc @@ -8,6 +8,9 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ +// +// ECC-1467: Support data values array decoded as "floats" (single-precision) +// #include #include "eccodes.h" #include "grib_api_internal.h" @@ -60,8 +63,7 @@ int main(int argc, char** argv) fval = fvalues[i]; if (!((dmin <= fval) && (fval <= dmax))) { - fprintf(stderr, "Error:\n"); - fprintf(stderr, "dvalue: %f, fvalue: %f\n", dvalues[i], fvalues[i]); + fprintf(stderr, "Error: dvalue: %f, fvalue: %f\n", dvalues[i], fvalues[i]); fprintf(stderr, "\tmin < fvalue < max = %.20e < %.20e < %.20e FAILED\n", dmin, fvalues[i], dmax); fprintf(stderr, "\tfvalue - min = %.20e (%s)\n", diff --git a/tests/grib_ecc-1467.sh b/tests/grib_ecc-1467.sh index fb5d0bd1c..abb9aa5f3 100755 --- a/tests/grib_ecc-1467.sh +++ b/tests/grib_ecc-1467.sh @@ -8,6 +8,8 @@ # virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. # +# ECC-1467: Support data values array decoded as "floats" (single-precision) + . ./include.ctest.sh # Constant fields diff --git a/tests/grib_fieldset.cc b/tests/grib_fieldset.cc index a6eb38ce7..d1431b021 100644 --- a/tests/grib_fieldset.cc +++ b/tests/grib_fieldset.cc @@ -13,12 +13,6 @@ #include "grib_api.h" -static void usage(const char* prog) -{ - fprintf(stderr, "Usage: %s order_by grib_file grib_file ...\n", prog); - exit(1); -} - int main(int argc, char** argv) { int err = 0; @@ -34,7 +28,7 @@ int main(int argc, char** argv) size_t lenDate = 10, lenParam = 20, lenLevel = 50; char* order_by = NULL; - if (argc != 3) usage(argv[0]); + if (argc != 3) return 1; //Usage: prog order_by grib_file grib_file ... nkeys = sizeof(keys) / sizeof(*keys); order_by = argv[1]; diff --git a/tests/index_orderby.cc b/tests/index_orderby.cc index f2346fc82..55ff9c2f5 100644 --- a/tests/index_orderby.cc +++ b/tests/index_orderby.cc @@ -10,12 +10,6 @@ #include "grib_api.h" -void usage(char* prog) -{ - printf("usage: %s infile\n", prog); - exit(1); -} - int main(int argc, char* argv[]) { grib_index* index = NULL; @@ -27,7 +21,7 @@ int main(int argc, char* argv[]) size_t lenshortName = 200; int ret = 0, count = 0; - if (argc != 2) usage(argv[0]); + if (argc != 2) return 1; infile = argv[1]; outfile = argv[2]; diff --git a/tests/largefile.cc b/tests/largefile.cc index a09d84be4..51e77949b 100644 --- a/tests/largefile.cc +++ b/tests/largefile.cc @@ -14,12 +14,6 @@ #include #endif -void usage(const char* prog) -{ - printf("usage: %s filename\n", prog); - exit(1); -} - int main(int argc, char* argv[]) { off_t offsetin = 0, offsetout = 0; @@ -30,7 +24,7 @@ int main(int argc, char* argv[]) char str[10]; int i; - if (argc != 2) usage(argv[0]); + if (argc != 2) return 1; printf("sizeof(off_t)=%zu sizeof(long)=%zu\n", sizeof(off_t), sizeof(long));