From db60bd75205acfb62ea7449166c8bb497275fc0b Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Mon, 21 Aug 2023 13:44:49 +0100 Subject: [PATCH] Testing: Geoiterator previous --- tests/grib_geo_iter.cc | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/grib_geo_iter.cc b/tests/grib_geo_iter.cc index 28b7603fe..b9d23830f 100644 --- a/tests/grib_geo_iter.cc +++ b/tests/grib_geo_iter.cc @@ -73,6 +73,22 @@ int main(int argc, char** argv) Assert(grib_iterator_has_next(iter) == 0); + { + // Test getting the previous value from a geoiterator. + // Note: Only implemented for regular grids + char gridType[128] = {0,}; + size_t len = sizeof(gridType); + GRIB_CHECK(grib_get_string(h, "gridType", gridType, &len), 0); + if (strstr(gridType, "regular_")) { + double last_lat = 0, last_lon = 0, last_value = 0; + int result = grib_iterator_previous(iter, &last_lat, &last_lon, &last_value); + Assert(result == 1); + Assert(lat == last_lat); + Assert(lon == last_lon); + Assert(value == last_value); + } + } + grib_iterator_delete(iter); grib_handle_delete(h);