Testing: Use Assert because if NDEBUG was defined the assert macro is disabled

This commit is contained in:
Shahram Najm 2022-06-27 11:23:34 +01:00
parent 9271a60777
commit b50ced1b45
1 changed files with 8 additions and 9 deletions

View File

@ -10,9 +10,8 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <assert.h>
#include "grib_api.h" #include "grib_api_internal.h"
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
@ -25,23 +24,23 @@ int main(int argc, char** argv)
grib_iterator* iter = NULL; grib_iterator* iter = NULL;
h = grib_handle_new_from_samples(0, sample_filename); h = grib_handle_new_from_samples(0, sample_filename);
assert(h); Assert(h);
iter = grib_iterator_new(h, 0, &err); iter = grib_iterator_new(h, 0, &err);
assert(!err); Assert(!err);
assert(iter); Assert(iter);
assert(grib_iterator_has_next(iter)); Assert(grib_iterator_has_next(iter));
n = 0; n = 0;
while (grib_iterator_next(iter, &lat, &lon, &value)) { while (grib_iterator_next(iter, &lat, &lon, &value)) {
if (n < numberOfDataPoints - 1) if (n < numberOfDataPoints - 1)
assert(grib_iterator_has_next(iter)); Assert(grib_iterator_has_next(iter));
n++; n++;
} }
assert(n == numberOfDataPoints); Assert(n == numberOfDataPoints);
assert(grib_iterator_has_next(iter) == 0); Assert(grib_iterator_has_next(iter) == 0);
grib_iterator_delete(iter); grib_iterator_delete(iter);