From 0eb43c66f5c4931f43a5fca9b8acb7d76911e258 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Fri, 29 Jul 2022 13:21:04 +0100 Subject: [PATCH] Testing: Use own Assert macro (which is not disabled with NDEBUG) --- tests/bufr_threads_ecc-604.c | 11 +++--- tests/grib_check_param_concepts.c | 3 +- tests/grib_encode_pthreads.c | 10 ++--- tests/grib_keys_iter.c | 27 +++++++------- tests/grib_local_MeteoFrance.c | 6 +-- tests/grib_multi_from_message.c | 3 +- tests/grib_packing_order.c | 23 ++++++------ tests/grib_set_bytes.c | 30 +++++++-------- tests/grib_set_force.c | 34 ++++++++--------- tests/grib_sh_imag.c | 5 +-- tests/grib_sh_spectral_complex.c | 9 ++--- tests/grib_threads_ecc-604.c | 9 ++--- tests/julian.c | 33 ++++++++--------- tests/unit_tests.c | 61 +++++++++++++++---------------- 14 files changed, 126 insertions(+), 138 deletions(-) diff --git a/tests/bufr_threads_ecc-604.c b/tests/bufr_threads_ecc-604.c index 311fa967c..c23b076f7 100644 --- a/tests/bufr_threads_ecc-604.c +++ b/tests/bufr_threads_ecc-604.c @@ -3,7 +3,6 @@ */ #include #include -#include #include #include "eccodes.h" @@ -26,13 +25,13 @@ static int encode_file(char* template_file, char* output_file) int err = 0; long numSubsets = 0; - assert(template_file); + Assert(template_file); in = fopen(template_file, "rb"); - assert(in); + Assert(in); if (opt_write) { - assert(output_file); + Assert(output_file); out = fopen(output_file, "wb"); - assert(out); + Assert(out); } /* loop over the messages in the source BUFR and clone them */ @@ -41,7 +40,7 @@ static int encode_file(char* template_file, char* output_file) if (opt_clone) { h = codes_handle_clone(source_handle); - assert(h); + Assert(h); } CODES_CHECK(codes_get_long(h, "numberOfSubsets", &numSubsets), 0); diff --git a/tests/grib_check_param_concepts.c b/tests/grib_check_param_concepts.c index 4be3c1b9b..f04cd4779 100644 --- a/tests/grib_check_param_concepts.c +++ b/tests/grib_check_param_concepts.c @@ -12,7 +12,6 @@ * Check GRIB2 parameter concept file e.g. shortName.def, paramId.def */ -#include #include "grib_api_internal.h" typedef struct grib_expression_long { @@ -154,7 +153,7 @@ int main(int argc, char** argv) const char* concepts_key = argv[1]; const char* concepts_filename = argv[2]; - assert(argc == 3); + Assert(argc == 3); err = grib_check_param_concepts(concepts_key, concepts_filename); if (err) return err; diff --git a/tests/grib_encode_pthreads.c b/tests/grib_encode_pthreads.c index d6e056e62..ab752ba21 100644 --- a/tests/grib_encode_pthreads.c +++ b/tests/grib_encode_pthreads.c @@ -10,8 +10,8 @@ #include #include #include -#include -#include "grib_api.h" + +#include "grib_api_internal.h" #define NUM_THREADS 8 #define FILES_PER_ITERATION 10 @@ -57,8 +57,8 @@ static int encode_file(char* input_file, char* output_file) FILE* in = fopen(input_file, "rb"); FILE* out = fopen(output_file, "wb"); - assert(in); - assert(out); + Assert(in); + Assert(out); while ((source_handle = grib_handle_new_from_file(0, in, &err)) != NULL) { size_t size = 0, values_len = 0; @@ -68,7 +68,7 @@ static int encode_file(char* input_file, char* output_file) double d, e; grib_handle* clone_handle = grib_handle_clone(source_handle); - assert(clone_handle); + Assert(clone_handle); GRIB_CHECK(grib_get_size(clone_handle, "values", &values_len), 0); values = (double*)malloc(values_len * sizeof(double)); diff --git a/tests/grib_keys_iter.c b/tests/grib_keys_iter.c index 6a19535ef..efdba87fa 100644 --- a/tests/grib_keys_iter.c +++ b/tests/grib_keys_iter.c @@ -1,36 +1,35 @@ #include #include #include -#include -#include "eccodes.h" +#include "grib_api_internal.h" int main(int argc, char* argv[]) { FILE* f = NULL; - codes_handle* h = NULL; + grib_handle* h = NULL; int err = 0; - assert(argc == 2); + Assert(argc == 2); f = fopen(argv[1], "rb"); - assert(f); + Assert(f); - while ((h = codes_handle_new_from_file(0, f, PRODUCT_GRIB, &err)) != NULL) { - codes_keys_iterator* kiter = NULL; + while ((h = grib_handle_new_from_file(0, f, &err)) != NULL) { + grib_keys_iterator* kiter = NULL; /* Use namespace of NULL to get ALL keys */ /* Set flags to 0 to not filter any keys */ - kiter = codes_keys_iterator_new(h, /*flags=*/0, /*namespace=*/NULL); - assert(kiter); + kiter = grib_keys_iterator_new(h, /*flags=*/0, /*namespace=*/NULL); + Assert(kiter); - while (codes_keys_iterator_next(kiter)) { - const char* name = codes_keys_iterator_get_name(kiter); - assert(name); + while (grib_keys_iterator_next(kiter)) { + const char* name = grib_keys_iterator_get_name(kiter); + Assert(name); printf("%s\n", name); } - codes_keys_iterator_delete(kiter); - codes_handle_delete(h); + grib_keys_iterator_delete(kiter); + grib_handle_delete(h); } fclose(f); return 0; diff --git a/tests/grib_local_MeteoFrance.c b/tests/grib_local_MeteoFrance.c index 5acacb426..9052308a7 100644 --- a/tests/grib_local_MeteoFrance.c +++ b/tests/grib_local_MeteoFrance.c @@ -8,8 +8,8 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api.h" -#include +#include "grib_api_internal.h" + /* * Test FA conversion to grib_api * philippe.marguinaud@meteo.fr 02/2016 @@ -849,7 +849,7 @@ int main(int argc, char* argv[]) size_t len = 0; const char* outfile; - assert(argc == 2); + Assert(argc == 2); outfile = argv[1]; GRIB_CHECK(((h = grib_handle_new_from_samples(NULL, "regular_ll_pl_grib2")) == NULL), 0); diff --git a/tests/grib_multi_from_message.c b/tests/grib_multi_from_message.c index 9613c67d8..798230db5 100644 --- a/tests/grib_multi_from_message.c +++ b/tests/grib_multi_from_message.c @@ -13,7 +13,6 @@ */ #include "grib_api_internal.h" -#include static void usage(const char* prog) @@ -52,7 +51,7 @@ int main(int argc, char* argv[]) else usage(argv[0]); - assert(filename); + Assert(filename); f = fopen(filename, "rb"); if (!f) { perror(filename); diff --git a/tests/grib_packing_order.c b/tests/grib_packing_order.c index cd9161120..e8cb2830a 100644 --- a/tests/grib_packing_order.c +++ b/tests/grib_packing_order.c @@ -8,8 +8,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include -#include "eccodes.h" +#include "grib_api_internal.h" /* Values taken from an actual IFS forecast run for paramId=133 (Specific humidity) */ const double values[] = { @@ -24797,7 +24796,7 @@ int main(int argc, char** argv) { size_t values_len = sizeof(values)/sizeof(values[0]); const char* sample_filename = "gg_sfc_grib2"; - codes_handle* h = NULL; + grib_handle* h = NULL; size_t str_len = 0; PackingStage packing_stage; char* packing_type; @@ -24817,28 +24816,28 @@ int main(int argc, char** argv) outfile_name = argv[3]; fprintf(stderr,"Using sample_filename = %s\n", sample_filename); - h = codes_grib_handle_new_from_samples(0, sample_filename); - assert(h); + h = grib_handle_new_from_samples(0, sample_filename); + Assert(h); if (strcmp(packing_type, "grid_second_order")==0 && packing_stage == VALUES_BEFORE_PACKING_TYPE) { check = 0; /* TDOD */ } - CODES_CHECK(codes_set_long(h, "bitsPerValue", 16), 0); + GRIB_CHECK(grib_set_long(h, "bitsPerValue", 16), 0); if (packing_stage == PACKING_TYPE_BEFORE_VALUES) { fprintf(stderr,"Set packingType to %s\n", packing_type); - CODES_CHECK(codes_set_string(h, "packingType", packing_type, &str_len), 0); + GRIB_CHECK(grib_set_string(h, "packingType", packing_type, &str_len), 0); } fprintf(stderr,"Set values. values_len=%lu\n", (unsigned long)values_len); - CODES_CHECK(codes_set_double_array(h, "values", values, values_len), 0); + GRIB_CHECK(grib_set_double_array(h, "values", values, values_len), 0); if (packing_stage == VALUES_BEFORE_PACKING_TYPE) { fprintf(stderr, "Set packingType to %s\n", packing_type); - CODES_CHECK(codes_set_string(h, "packingType", packing_type, &str_len), 0); + GRIB_CHECK(grib_set_string(h, "packingType", packing_type, &str_len), 0); } - CODES_CHECK(codes_write_message(h, outfile_name, "w"), 0); + GRIB_CHECK(grib_write_message(h, outfile_name, "w"), 0); fprintf(stderr, "%s checks on decoded values '%s' (%s) ...\n", (check?"Doing":"Skipping"), packing_type, argv[2]); @@ -24861,12 +24860,12 @@ int main(int argc, char** argv) GRIB_CHECK(grib_get_long(h, "offsetBeforeData", &offsetBeforeData), 0); calc = (offsetAfterData - offsetBeforeData) * 8.0 / values_len; printf("bitsPerValue calculated as = (offsetAfterData - offsetBeforeData)*8/numValues = %g\n", calc); - assert( calc == 16 || calc == 32 || calc == 64 ); + Assert( calc == 16 || calc == 32 || calc == 64 ); } free(vals); } - codes_handle_delete(h); + grib_handle_delete(h); fprintf(stderr,"All done\n"); return 0; } diff --git a/tests/grib_set_bytes.c b/tests/grib_set_bytes.c index b2c487af9..8dfc651d1 100644 --- a/tests/grib_set_bytes.c +++ b/tests/grib_set_bytes.c @@ -10,8 +10,8 @@ #include #include -#include -#include "eccodes.h" + +#include "grib_api_internal.h" int main(int argc, char** argv) { @@ -21,7 +21,7 @@ int main(int argc, char** argv) const char* infile = "../data/test_uuid.grib2"; FILE* out = NULL; const char* outfile = "temp.grib_set_bytes.grib"; - codes_handle* h = NULL; + grib_handle* h = NULL; const void* buffer = NULL; unsigned char uuid_short[] = { /* not enough bytes */ @@ -48,30 +48,30 @@ int main(int argc, char** argv) size_t uuid_long_len = sizeof (uuid_long); in = fopen(infile, "rb"); - assert(in); + Assert(in); out = fopen(outfile, "wb"); - assert(out); + Assert(out); - h = codes_handle_new_from_file(0, in, PRODUCT_GRIB, &err); - assert(h); + h = grib_handle_new_from_file(0, in, &err); + Assert(h); /* The uuidOfVGrid key is 16 bytes long */ - err = codes_set_bytes(h, "uuidOfVGrid", uuid_short, &uuid_short_len); - assert(err == CODES_BUFFER_TOO_SMALL); - err = codes_set_bytes(h, "uuidOfVGrid", uuid_long, &uuid_long_len); - assert(err == CODES_BUFFER_TOO_SMALL); + err = grib_set_bytes(h, "uuidOfVGrid", uuid_short, &uuid_short_len); + Assert(err == GRIB_BUFFER_TOO_SMALL); + err = grib_set_bytes(h, "uuidOfVGrid", uuid_long, &uuid_long_len); + Assert(err == GRIB_BUFFER_TOO_SMALL); /* This one should work */ - err = codes_set_bytes(h, "uuidOfVGrid", uuid_good, &uuid_good_len); - assert(err == 0); + err = grib_set_bytes(h, "uuidOfVGrid", uuid_good, &uuid_good_len); + Assert(err == 0); - CODES_CHECK(codes_get_message(h, &buffer, &size), 0); + GRIB_CHECK(grib_get_message(h, &buffer, &size), 0); if (fwrite(buffer, 1, size, out) != size) { perror(argv[1]); exit(1); } - codes_handle_delete(h); + grib_handle_delete(h); fclose(in); fclose(out); return 0; diff --git a/tests/grib_set_force.c b/tests/grib_set_force.c index 41c8e716f..93bcd771b 100644 --- a/tests/grib_set_force.c +++ b/tests/grib_set_force.c @@ -8,11 +8,9 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include #include -#include -#include "eccodes.h" +#include "grib_api_internal.h" /* * Start off with an input GRIB which already has a bitmap (which we do not change) @@ -151,50 +149,50 @@ int main(int argc, char** argv) const char* outfile = NULL; FILE* in = NULL; FILE* out = NULL; - codes_handle* h = NULL; + grib_handle* h = NULL; const void* buffer = NULL; const char* mode = NULL; - assert(argc == 4); + Assert(argc == 4); mode = argv[1]; /*all_values or coded_values*/ infile = argv[2]; outfile = argv[3]; in = fopen(infile, "rb"); - assert(in); + Assert(in); out = fopen(outfile, "wb"); - assert(out); + Assert(out); - while ((h = codes_handle_new_from_file(NULL, in, PRODUCT_GRIB, &err)) != NULL || err != CODES_SUCCESS) { + while ((h = grib_handle_new_from_file(NULL, in, &err)) != NULL || err != GRIB_SUCCESS) { long numberOfDataPoints = 0; - CODES_CHECK(codes_get_long(h, "numberOfDataPoints", &numberOfDataPoints), 0); + GRIB_CHECK(grib_get_long(h, "numberOfDataPoints", &numberOfDataPoints), 0); if (strcmp(mode, "all_values") == 0) { double missing = 9999; const size_t num_all_vals = sizeof(values) / sizeof(values[0]); - assert(num_all_vals == numberOfDataPoints); /*Sanity check*/ - CODES_CHECK(codes_set_long(h, "bitmapPresent", 1), 0); - CODES_CHECK(codes_set_double(h, "missingValue", missing), 0); + Assert(num_all_vals == numberOfDataPoints); /*Sanity check*/ + GRIB_CHECK(grib_set_long(h, "bitmapPresent", 1), 0); + GRIB_CHECK(grib_set_double(h, "missingValue", missing), 0); printf("Fully specified: %ld values\n", num_all_vals); - CODES_CHECK(codes_set_double_array(h, "values", values, num_all_vals), 0); + GRIB_CHECK(grib_set_double_array(h, "values", values, num_all_vals), 0); } else { const size_t num_coded_vals = sizeof(codedValues) / sizeof(codedValues[0]); - assert(strcmp(mode, "coded_values") == 0); - assert(num_coded_vals < numberOfDataPoints); /*Sanity check*/ + Assert(strcmp(mode, "coded_values") == 0); + Assert(num_coded_vals < numberOfDataPoints); /*Sanity check*/ printf("Partially specified: %ld values\n", num_coded_vals); - CODES_CHECK(codes_set_force_double_array(h, "codedValues", codedValues, num_coded_vals), 0); + GRIB_CHECK(grib_set_force_double_array(h, "codedValues", codedValues, num_coded_vals), 0); } /* Write out the new GRIB */ - CODES_CHECK(codes_get_message(h, &buffer, &size), 0); + GRIB_CHECK(grib_get_message(h, &buffer, &size), 0); if (fwrite(buffer, 1, size, out) != size) { perror(outfile); exit(1); } - codes_handle_delete(h); + grib_handle_delete(h); } printf("Wrote %s\n", outfile); fclose(in); diff --git a/tests/grib_sh_imag.c b/tests/grib_sh_imag.c index 6091bb256..4d6b7540b 100644 --- a/tests/grib_sh_imag.c +++ b/tests/grib_sh_imag.c @@ -8,8 +8,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api.h" -#include +#include "grib_api_internal.h" /* * Check that first coefficient have an imaginary part equal to zero. @@ -30,7 +29,7 @@ int main(int argc, char* argv[]) int m, n, k; const char* outfile; - assert(argc == 2); + Assert(argc == 2); outfile = argv[1]; GRIB_CHECK(((h = grib_handle_new_from_samples(NULL, "sh_ml_grib2")) == NULL), 0); diff --git a/tests/grib_sh_spectral_complex.c b/tests/grib_sh_spectral_complex.c index 085d684d7..d9340f713 100644 --- a/tests/grib_sh_spectral_complex.c +++ b/tests/grib_sh_spectral_complex.c @@ -8,8 +8,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api.h" -#include +#include "grib_api_internal.h" #include "grib_sh_values.h" /* array 'values' defined here*/ @@ -49,7 +48,7 @@ int main(int argc, char* argv[]) fout = fopen(TEMPFILE, "wb"); GRIB_CHECK(grib_get_message(h, &buffer, &size), 0); if (fwrite(buffer, 1, size, fout) != size) { - assert(!"Failed to write data"); + Assert(!"Failed to write data"); } fclose(fout); @@ -80,8 +79,8 @@ int main(int argc, char* argv[]) /* Read in the saved GRIB file */ printf("Load values from saved file and compare....\n"); - fin = fopen(TEMPFILE, "rb"); assert(fin); - h = grib_handle_new_from_file(0, fin, &err); assert(h); + fin = fopen(TEMPFILE, "rb"); Assert(fin); + h = grib_handle_new_from_file(0, fin, &err); Assert(h); GRIB_CHECK(grib_get_double_array(h, "values", zval, &len), 0); for (i = 0; i < ILCHAM; ++i) { const double diff = fabs(zval[i] - values[i]); diff --git a/tests/grib_threads_ecc-604.c b/tests/grib_threads_ecc-604.c index 8bdcec124..e553b65c1 100644 --- a/tests/grib_threads_ecc-604.c +++ b/tests/grib_threads_ecc-604.c @@ -3,10 +3,9 @@ */ #include #include -#include #include -#include "grib_api.h" +#include "grib_api_internal.h" /* These are passed in via argv */ static size_t NUM_THREADS = 0; @@ -26,10 +25,10 @@ static int encode_file(char* template_file, char* output_file) double* values; in = fopen(template_file, "rb"); - assert(in); + Assert(in); if (opt_write && output_file) { out = fopen(output_file, "wb"); - assert(out); + Assert(out); } /* loop over the messages in the source GRIB and clone them */ @@ -41,7 +40,7 @@ static int encode_file(char* template_file, char* output_file) if (opt_clone) { h = grib_handle_clone(source_handle); - assert(h); + Assert(h); } GRIB_CHECK(grib_get_size(h, "values", &values_len), 0); diff --git a/tests/julian.c b/tests/julian.c index 3910bc5cd..a40c3673e 100644 --- a/tests/julian.c +++ b/tests/julian.c @@ -8,8 +8,7 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include "grib_api.h" -#include +#include "grib_api_internal.h" #define EPSILON 1e-12 #define DBL_EQUAL(a, b) (fabs((a) - (b)) <= (EPSILON)*fabs((a))) @@ -75,16 +74,16 @@ static void Test0() sec = 24; grib_datetime_to_julian(year, month, day, hour, min, sec, &jd); - assert(DBL_EQUAL(jd, 2378891.268333)); + Assert(DBL_EQUAL(jd, 2378891.268333)); printf("%ld %ld %ld %ld:%ld:%ld -> %f\n", year, month, day, hour, min, sec, jd); grib_julian_to_datetime(jd, &year, &month, &day, &hour, &min, &sec); - assert(year == 1801); - assert(month == 1); - assert(day == 30); - assert(hour == 18); - assert(min == 26); - assert(sec == 24); + Assert(year == 1801); + Assert(month == 1); + Assert(day == 30); + Assert(hour == 18); + Assert(min == 26); + Assert(sec == 24); printf("%ld %ld %ld %ld:%ld:%ld -> %f\n", year, month, day, hour, min, sec, jd); } @@ -103,16 +102,16 @@ static void Test1() sec = 24; grib_datetime_to_julian(year, month, day, hour, min, sec, &jd); - assert(DBL_EQUAL(jd, 2436116.31)); + Assert(DBL_EQUAL(jd, 2436116.31)); printf("%ld %ld %ld %ld:%ld:%ld -> %f\n", year, month, day, hour, min, sec, jd); grib_julian_to_datetime(jd, &year, &month, &day, &hour, &min, &sec); - assert(year == 1957); - assert(month == 10); - assert(day == 4); - assert(hour == 19); - assert(min == 26); - assert(sec == 24); + Assert(year == 1957); + Assert(month == 10); + Assert(day == 4); + Assert(hour == 19); + Assert(min == 26); + Assert(sec == 24); printf("%ld %ld %ld %ld:%ld:%ld -> %f\n", year, month, day, hour, min, sec, jd); } @@ -150,7 +149,7 @@ static void Test2() if (!DBL_EQUAL(jd, jds[i])) { fprintf(stderr, "i=%d: Got: %f, expected: %f\n", i, jd, jds[i]); - assert(0); + Assert(0); } jdl = (long)(jd + 0.5); diff --git a/tests/unit_tests.c b/tests/unit_tests.c index 7d15a9437..080a0a68f 100644 --- a/tests/unit_tests.c +++ b/tests/unit_tests.c @@ -8,7 +8,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -#include #include "grib_api_internal.h" #define STR_EQUAL(s1, s2) (strcmp((s1), (s2)) == 0) @@ -23,7 +22,7 @@ typedef enum static void compare_doubles(const double d1, const double d2, const double epsilon) { - assert(fabs(d1 - d2) < epsilon); + Assert(fabs(d1 - d2) < epsilon); } static void check_float_representation(const double val, const double expected, const FloatRep rep) @@ -31,9 +30,9 @@ static void check_float_representation(const double val, const double expected, double out = 0; const double tolerance = 1e-9; if (rep == IBM_FLOAT) - assert(grib_nearest_smaller_ibm_float(val, &out) == GRIB_SUCCESS); + Assert(grib_nearest_smaller_ibm_float(val, &out) == GRIB_SUCCESS); else - assert(grib_nearest_smaller_ieee_float(val, &out) == GRIB_SUCCESS); + Assert(grib_nearest_smaller_ieee_float(val, &out) == GRIB_SUCCESS); /*printf("%s: d1=%10.20f, out=%10.20f\n", (rep==IBM_FLOAT)?"ibm":"ieee", val, out);*/ @@ -1400,9 +1399,9 @@ static void test_string_splitting() printf("Testing: test_string_splitting...\n"); list = string_split(input, "|"); - if (!list) { assert(!"List is NULL"); return; } + if (!list) { Assert(!"List is NULL"); return; } for (i = 0; list[i] != NULL; ++i) {} /* count how many tokens */ - assert(i == 4); + Assert(i == 4); if (!list[0] || !STR_EQ(list[0], "Born")) Assert(0); if (!list[1] || !STR_EQ(list[1], "To")) Assert(0); if (!list[2] || !STR_EQ(list[2], "Be")) Assert(0); @@ -1413,22 +1412,22 @@ static void test_string_splitting() strcpy(input, "12345|a gap|"); list = string_split(input, "|"); - if (!list) { assert(0); return; } + if (!list) { Assert(0); return; } for (i = 0; list[i] != NULL; ++i) {} /* count how many tokens */ - assert(i == 2); + Assert(i == 2); if (!list[0] || !STR_EQ(list[0], "12345")) Assert(0); if (!list[1] || !STR_EQ(list[1], "a gap")) Assert(0); - assert(list[2] == NULL); + Assert(list[2] == NULL); for (i = 0; list[i] != NULL; ++i) free(list[i]); free(list); strcpy(input, "Steppenwolf"); list = string_split(input, ","); - if (!list) { assert(0); return; } + if (!list) { Assert(0); return; } for (i = 0; list[i] != NULL; ++i) {} /* count how many tokens */ - assert(i == 1); + Assert(i == 1); if (!list[0] || !STR_EQ(list[0], "Steppenwolf")) Assert(0); - assert(list[1] == NULL); + Assert(list[1] == NULL); for (i = 0; list[i] != NULL; ++i) free(list[i]); free(list); @@ -1449,7 +1448,7 @@ static void test_assertion_catching() char empty[] = ""; char** list = 0; int i = 0; - assert(assertion_caught == 0); + Assert(assertion_caught == 0); codes_set_codes_assertion_failed_proc(&my_assertion_proc); printf("Testing: test_assertion_catching...\n"); @@ -1457,7 +1456,7 @@ static void test_assertion_catching() /* Do something illegal */ list = string_split(empty, " "); - assert(assertion_caught == 1); + Assert(assertion_caught == 1); /* Restore everything */ codes_set_codes_assertion_failed_proc(NULL); @@ -1512,34 +1511,34 @@ static void test_trimming() printf("Testing: test_trimming...\n"); string_lrtrim(&pA, 0, 1); /*right only*/ - assert( strcmp(pA, " Standing")==0 ); + Assert( strcmp(pA, " Standing")==0 ); string_lrtrim(&pB, 1, 0); /*left only*/ - assert( strcmp(pB, "Weeping ")==0 ); + Assert( strcmp(pB, "Weeping ")==0 ); string_lrtrim(&pC, 1, 1); /*both ends*/ - assert( strcmp(pC, "Silhouette")==0 ); + Assert( strcmp(pC, "Silhouette")==0 ); string_lrtrim(&pD, 1, 1); /*make sure other spaces are not removed*/ - assert( strcmp(pD, "The Forest Of October")==0 ); + Assert( strcmp(pD, "The Forest Of October")==0 ); string_lrtrim(&pE, 1, 1); /* Other chars */ - assert( strcmp(pE, "Apostle In Triumph")==0 ); + Assert( strcmp(pE, "Apostle In Triumph")==0 ); } static void test_string_ends_with() { printf("Testing: test_string_ends_with...\n"); - assert( string_ends_with("GRIB2.tmpl", "tmpl") == 1 ); - assert( string_ends_with("GRIB2.tmpl", ".tmpl") == 1 ); - assert( string_ends_with("", "") == 1 ); - assert( string_ends_with(".", ".") == 1 ); - assert( string_ends_with("Bam", "") == 1 ); + Assert( string_ends_with("GRIB2.tmpl", "tmpl") == 1 ); + Assert( string_ends_with("GRIB2.tmpl", ".tmpl") == 1 ); + Assert( string_ends_with("", "") == 1 ); + Assert( string_ends_with(".", ".") == 1 ); + Assert( string_ends_with("Bam", "") == 1 ); - assert( string_ends_with("GRIB2.tmpl", "tmp") == 0 ); - assert( string_ends_with("GRIB2.tmpl", "tmpl0") == 0 ); - assert( string_ends_with("GRIB2.tmpl", "1.tmpl") == 0 ); - assert( string_ends_with("GRIB2.tmpl", " ") == 0 ); + Assert( string_ends_with("GRIB2.tmpl", "tmp") == 0 ); + Assert( string_ends_with("GRIB2.tmpl", "tmpl0") == 0 ); + Assert( string_ends_with("GRIB2.tmpl", "1.tmpl") == 0 ); + Assert( string_ends_with("GRIB2.tmpl", " ") == 0 ); } static void test_gribex_mode() @@ -1547,11 +1546,11 @@ static void test_gribex_mode() grib_context* c = grib_context_get_default(); printf("Testing: test_gribex_mode...\n"); - assert( grib_get_gribex_mode(c) == 0 ); /* default is OFF */ + Assert( grib_get_gribex_mode(c) == 0 ); /* default is OFF */ grib_gribex_mode_on(c); - assert( grib_get_gribex_mode(c) == 1 ); + Assert( grib_get_gribex_mode(c) == 1 ); grib_gribex_mode_off(c); - assert( grib_get_gribex_mode(c) == 0 ); + Assert( grib_get_gribex_mode(c) == 0 ); } int main(int argc, char** argv)