summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAkira TAGOH <akira@tagoh.org>2011-12-28 14:16:32 +0900
committerAkira TAGOH <akira@tagoh.org>2011-12-28 14:16:32 +0900
commitfa2c708c3596ad8fe1b72b39d92126a8083a97b9 (patch)
tree87de191b3143d8020de48470aea3ae5e9f1cf7c1 /tests
parent2c43f4ec493416718c82a7a5824e85d0a330ab66 (diff)
Add script database handler
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.am5
-rw-r--r--tests/script.c56
2 files changed, 61 insertions, 0 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 23d394c..a9be25c 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -38,8 +38,13 @@ noinst_HEADERS = \
$(NULL)
noinst_PROGRAMS = \
test-lang \
+ test-script \
$(NULL)
#
test_lang_SOURCES = \
lang.c \
$(NULL)
+#
+test_script_SOURCES = \
+ script.c \
+ $(NULL)
diff --git a/tests/script.c b/tests/script.c
new file mode 100644
index 0000000..920059a
--- /dev/null
+++ b/tests/script.c
@@ -0,0 +1,56 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * script.c
+ * Copyright (C) 2011 Akira TAGOH
+ *
+ * Authors:
+ * Akira TAGOH <akira@tagoh.org>
+ *
+ * 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 3 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <locale.h>
+#include "lt-script.h"
+
+int
+main(int argc,
+ char **argv)
+{
+ lt_script_t *script;
+
+ setlocale(LC_ALL, "");
+
+ script = lt_script_new();
+
+ if (g_strcmp0(argv[1], "list") == 0) {
+ GList *l = lt_script_get_scripts(script), *ll;
+
+ for (ll = l; ll != NULL; ll = g_list_next(ll)) {
+ g_print("%s\n", (gchar *)ll->data);
+ }
+ g_list_free(l);
+ } else if (g_strcmp0(argv[1], "code") == 0) {
+ g_print("%s\n", lt_script_lookup_alpha_code(script, argv[2]));
+ g_print("%s\n", lt_script_lookup_numeric_code(script, argv[2]));
+ } else if (g_strcmp0(argv[1], "script") == 0) {
+ g_print("%s\n", lt_script_lookup_script(script, argv[2]));
+ }
+
+ lt_script_unref(script);
+
+ return 0;
+}