[libgweather] metar test: Don't use "known" duplicates
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgweather] metar test: Don't use "known" duplicates
- Date: Tue, 26 Apr 2022 16:00:53 +0000 (UTC)
commit 8b4fe0ad32bac4da47188207541b0aec3f786498
Author: Pierre Labastie <pierre labastie neuf fr>
Date: Sun Apr 10 22:24:47 2022 +0200
metar test: Don't use "known" duplicates
The metar list provided by NOAA contains duplicate ICAO codes.
Those duplicates may change over time, so it does not make sense
to use an array of known duplicates. Presently a duplicate is rejected
when it is known, and inserted if it is not, leading to a difference
in the number of insertions and the number of keys, so that the test
fails. If any duplicate is rejected, the number of insertions is
always equal to the number of keys (unless something goes wrong
in g_hash_table_insert). And this is the default behavior for known
duplicates anyway.
Closes: https://gitlab.gnome.org/GNOME/libgweather/-/issues/168
libgweather/tests/metar.c | 15 +++------------
1 file changed, 3 insertions(+), 12 deletions(-)
---
diff --git a/libgweather/tests/metar.c b/libgweather/tests/metar.c
index 7d6c7c04..a6fa7e79 100644
--- a/libgweather/tests/metar.c
+++ b/libgweather/tests/metar.c
@@ -41,20 +41,11 @@ parse_metar_stations (const char *contents)
continue;
}
+ /* If it is a duplicate discard it */
if (g_hash_table_lookup (stations_ht, station)) {
- const char * const known_duplicates[] = {
- "VOGO",
- "KHQG",
- "KOEL",
- "KTQK",
- "KX26",
- NULL
- };
- if (g_strv_contains (known_duplicates, station)) {
- g_free (station);
- continue;
- }
g_test_message ("Weather station '%s' already defined\n", station);
+ g_free (station);
+ continue;
}
g_hash_table_insert (stations_ht, station, g_strdup (line));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]