summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorHans Ulrich Niedermann <hun@n-dimensional.de>2022-05-18 13:26:55 +0200
committerHans Ulrich Niedermann <hun@n-dimensional.de>2022-05-19 17:11:24 +0200
commit6f5bd93820fa835c744aede2a5f4635693ac424e (patch)
tree83d4d3a487031dd964882b2f7ebb2fe1055c66e7 /tests
parentab3af6f5003221289bc39693a5e482396ad591dd (diff)
downloadlibgphoto2-6f5bd93820fa835c744aede2a5f4635693ac424e.tar.gz
Add test-init-localedir test program
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.am10
-rw-r--r--tests/test-init-localedir.c66
2 files changed, 76 insertions, 0 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 5eef508a8..d87bc3d61 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -99,6 +99,16 @@ test_camera_list_LDADD = \
$(INTLLIBS)
+TESTS += test-init-localedir
+check_PROGRAMS += test-init-localedir
+test_init_localedir_LDADD =
+test_init_localedir_LDADD += $(top_builddir)/libgphoto2/libgphoto2.la
+test_init_localedir_LDADD += $(top_builddir)/libgphoto2_port/libgphoto2_port/libgphoto2_port.la
+test_init_localedir_LDADD += $(LIBLTDL)
+test_init_localedir_LDADD += $(LIBEXIF_LIBS)
+test_init_localedir_LDADD += $(INTLLIBS)
+
+
########################################################################
# Test pedantic compilation for multiple language standard
########################################################################
diff --git a/tests/test-init-localedir.c b/tests/test-init-localedir.c
new file mode 100644
index 000000000..ba559f6e3
--- /dev/null
+++ b/tests/test-init-localedir.c
@@ -0,0 +1,66 @@
+/** \file tests/test-init-localedir.c
+ * \brief Exercise the *_init_localedir() functions
+ *
+ * Copyright 2022 Hans Ulrich Niedermann <hun@n-dimensional.de>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser 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
+ *
+ *
+ * Usage:
+ * ./test-init-localedir /foo/share/locale
+ * ./test-init-localedir /foo/share/locale NULL
+ * ./test-init-localedir NULL /foo/share/locale /usr/share/locale
+ *
+ * Calls the gp_init_localedir() for each and every command line
+ * argument in sequence. Command line arguments are interpreted as
+ * directory paths (absolute or relative to the current working
+ * directory), but "NULL" is interpreted as a C NULL value.
+ */
+
+#include <stdio.h>
+#include <string.h>
+
+#include <gphoto2/gphoto2-port-log.h>
+#include <gphoto2/gphoto2-abilities-list.h>
+
+
+void log_func(GPLogLevel level, const char *domain,
+ const char *str, void *data)
+{
+ printf("%d:%s:%s\n", level, domain, str);
+}
+
+
+int main(const int argc, const char *const argv[])
+{
+ gp_log_add_func(GP_LOG_ALL, log_func, NULL);
+ for (int i=1; i<argc; ++i) {
+ const char *const arg = argv[i];
+ const char *const localedir =
+ (strcmp(arg, "NULL") == 0) ? NULL : argv[1];
+ printf("main: calling gp_init_localedir(%s)\n",
+ localedir?localedir:"(null)");
+ gp_init_localedir(localedir);
+ }
+}
+
+
+/*
+ * Local Variables:
+ * c-file-style:"linux"
+ * indent-tabs-mode:t
+ * End:
+ */