changeset 3291:02335e399a16 trunk

Test functor extension code from outside scope.
author William Pitcock <nenolod@atheme-project.org>
date Thu, 09 Aug 2007 09:38:21 -0500
parents 4e7cc6d9b525
children a97fb19a0148
files src/tests/Makefile src/tests/tuple_formatter_functor_test.c
diffstat 2 files changed, 64 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/tests/Makefile	Thu Aug 09 09:22:08 2007 -0500
+++ b/src/tests/Makefile	Thu Aug 09 09:38:21 2007 -0500
@@ -2,7 +2,8 @@
 include ../../mk/init.mk
 include ../../mk/objective.mk
 
-OBJECTIVE_LIBS_NOINST = tuple_formatter_test
+OBJECTIVE_LIBS_NOINST = tuple_formatter_test \
+	tuple_formatter_functor_test
 
 LDFLAGS += $(AUDLDFLAGS)
 LDADD = \
@@ -28,3 +29,10 @@
 	@printf "%10s     %-20s\n" LINK $@
 	./$@
 	@printf "%10s     %-20s\n" TEST-PASS $@
+
+TFFT_OBJS = $(COMMON_OBJS) tuple_formatter_functor_test.o ../audacious/tuple.o ../audacious/tuple_formatter.o
+tuple_formatter_functor_test: $(TFFT_OBJS)
+	$(CC) $(LDFLAGS) $(TFFT_OBJS) $(LDADD) -o $@
+	@printf "%10s     %-20s\n" LINK $@
+	./$@
+	@printf "%10s     %-20s\n" TEST-PASS $@
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/tests/tuple_formatter_functor_test.c	Thu Aug 09 09:38:21 2007 -0500
@@ -0,0 +1,55 @@
+/*
+ * Audacious
+ * Copyright (c) 2007 William Pitcock
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; under version 3 of the License.
+ *
+ * This program 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>.
+ *
+ * The Audacious team does not consider modular code linking to
+ * Audacious or using our public API to be a derived work.
+ */
+
+#include <glib.h>
+#include <mowgli.h>
+
+#include "tuple.h"
+#include "tuple_formatter.h"
+
+static gboolean
+test_functor(Tuple *tuple, const char *expr)
+{
+    return TRUE;
+}
+
+int
+test_run(int argc, const char *argv[])
+{
+    Tuple *tuple;
+    gchar *tstr;
+
+    tuple_formatter_register_expression("(true)", test_functor);
+
+    tuple = tuple_new();
+    tuple_associate_string(tuple, "splork", "moo");
+
+    tstr = tuple_formatter_process_string(tuple, "${(true):${splork}}");
+    if (g_ascii_strcasecmp(tstr, "moo"))
+    {
+        g_print("fail 1: '%s'\n", tstr);
+        return EXIT_FAILURE;
+    }
+    g_free(tstr);
+
+    mowgli_object_unref(tuple);
+
+    return EXIT_SUCCESS;
+}