From 024cf2f59a7ee23f46140932b7b617f1f3fc1508 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Tue, 25 Mar 2025 21:47:16 +0100 Subject: Add tests and some fixes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- test-common.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 test-common.c (limited to 'test-common.c') diff --git a/test-common.c b/test-common.c new file mode 100644 index 0000000..ea56bdb --- /dev/null +++ b/test-common.c @@ -0,0 +1,33 @@ +/* See LICENSE file for copyright and license details. */ +#include "test-common.h" + + +#if LIBGEOME_LAST_DATUM != LIBGEOME_DATUM_ALTITUDE +# warning struct libgeome_data has been updated, test_common_print() is out of date +#endif + + +void +test_common_init(struct libgeome_context *ctx_out, struct libgeome_data *data_out, const char *procname) +{ + libgeome_basic_context(ctx_out, procname); + ctx_out->print_debug = ctx_out->print_error; + data_out->requested_data = (LIBGEOME_LAST_DATUM - 1U) | LIBGEOME_LAST_DATUM; +} + + +void +test_common_print(struct libgeome_data *data) +{ + if (!data->requested_data) + printf("No data retrieved"); + + if (data->requested_data & LIBGEOME_DATUM_LATITUDE) + printf("Latitude: %g\n", data->latitude); + if (data->requested_data & LIBGEOME_DATUM_LONGITUDE) + printf("Longitude: %g\n", data->longitude); + if (data->requested_data & LIBGEOME_DATUM_ALTITUDE) + printf("Altitude: %g\n", data->altitude); + + data->requested_data = (LIBGEOME_LAST_DATUM - 1U) | LIBGEOME_LAST_DATUM; +} -- cgit v1.2.3-70-g09d2