summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVictor Kareh <[email protected]>2026-03-12 15:05:54 -0400
committerVictor Kareh <[email protected]>2026-03-12 15:29:36 -0400
commit6ea270f97646da42455c662abda4432c94e288cb (patch)
tree843f92f5940906cb4a8e93a6a3049eede56d8d22
parentc8432a5a135ee5a8a187384eaf81d6fdf9aa2adb (diff)
downloadlibmateweather-6ea270f97646da42455c662abda4432c94e288cb.tar.bz2
libmateweather-6ea270f97646da42455c662abda4432c94e288cb.tar.xz
tests: Add test for libmateweather
This is the first automated test for libmateweather, so it is named generically to be extended. The upstream test_named_timezones test is omitted since libmateweather does not have the NAMED_TIMEZONE location level. Adapted from libgweather: https://gitlab.gnome.org/GNOME/libgweather/-/commit/2373f56f
-rw-r--r--libmateweather/Makefile.am7
-rw-r--r--libmateweather/test_libmateweather.c48
2 files changed, 54 insertions, 1 deletions
diff --git a/libmateweather/Makefile.am b/libmateweather/Makefile.am
index a04eeea..c5e48bb 100644
--- a/libmateweather/Makefile.am
+++ b/libmateweather/Makefile.am
@@ -1,6 +1,8 @@
lib_LTLIBRARIES = libmateweather.la
-noinst_PROGRAMS = test_metar test_locations test_sun_moon
+noinst_PROGRAMS = test_metar test_locations test_sun_moon test_libmateweather
+
+TESTS = test_libmateweather
AM_CPPFLAGS = \
$(GTK_CFLAGS) \
@@ -67,6 +69,9 @@ test_sun_moon_SOURCES = test_sun_moon.c
test_sun_moon_CPPFLAGS = $(AM_CPPFLAGS) $(LIBSOUP_CFLAGS)
test_sun_moon_LDADD = libmateweather.la $(GTK_LIBS) $(LIBM)
+test_libmateweather_SOURCES = test_libmateweather.c
+test_libmateweather_LDADD = libmateweather.la $(GTK_LIBS)
+
mateweather-enum-types.h: $(mateweather_new_headers)
$(AM_V_GEN)( cd $(srcdir) && $(GLIB_MKENUMS) --template mateweather-enum-types.h.tmpl \
$(mateweather_new_headers) ) > mateweather-enum-types.h.tmp \
diff --git a/libmateweather/test_libmateweather.c b/libmateweather/test_libmateweather.c
new file mode 100644
index 0000000..c168c90
--- /dev/null
+++ b/libmateweather/test_libmateweather.c
@@ -0,0 +1,48 @@
+/*
+ * (c) 2017 Bastien Nocera <[email protected]>
+ * (c) 2026 Victor Kareh <[email protected]>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <locale.h>
+
+#define MATEWEATHER_I_KNOW_THIS_IS_UNSTABLE
+#include "mateweather-location.h"
+
+static void
+log_handler (const char *log_domain, GLogLevelFlags log_level, const char *message, gpointer user_data)
+{
+ g_test_message ("%s", message);
+}
+
+int
+main (int argc, char *argv[])
+{
+ setlocale (LC_ALL, "");
+
+ g_test_init (&argc, &argv, NULL);
+ g_test_bug_base ("https://github.com/mate-desktop/libmateweather/issues/");
+
+ /* We need to handle log messages produced by g_message so they're interpreted correctly by the GTester framework */
+ g_log_set_handler (NULL, G_LOG_LEVEL_MESSAGE | G_LOG_LEVEL_INFO | G_LOG_LEVEL_DEBUG, log_handler, NULL);
+
+ return g_test_run ();
+}