Mercurial > audlegacy
annotate src/tests/tuple_formatter_functor_test.c @ 4134:3f1f84330007
one less gdk_window_get_pointer call
author | Tomasz Mon <desowin@gmail.com> |
---|---|
date | Sun, 30 Dec 2007 21:36:46 +0100 |
parents | a97fb19a0148 |
children |
rev | line source |
---|---|
3291
02335e399a16
Test functor extension code from outside scope.
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
1 /* |
02335e399a16
Test functor extension code from outside scope.
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
2 * Audacious |
02335e399a16
Test functor extension code from outside scope.
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
3 * Copyright (c) 2007 William Pitcock |
02335e399a16
Test functor extension code from outside scope.
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
4 * |
02335e399a16
Test functor extension code from outside scope.
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
5 * This program is free software; you can redistribute it and/or modify |
02335e399a16
Test functor extension code from outside scope.
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
6 * it under the terms of the GNU General Public License as published by |
02335e399a16
Test functor extension code from outside scope.
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
7 * the Free Software Foundation; under version 3 of the License. |
02335e399a16
Test functor extension code from outside scope.
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
8 * |
02335e399a16
Test functor extension code from outside scope.
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
9 * This program is distributed in the hope that it will be useful, |
02335e399a16
Test functor extension code from outside scope.
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
02335e399a16
Test functor extension code from outside scope.
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
02335e399a16
Test functor extension code from outside scope.
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
12 * GNU General Public License for more details. |
02335e399a16
Test functor extension code from outside scope.
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
13 * |
02335e399a16
Test functor extension code from outside scope.
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
14 * You should have received a copy of the GNU General Public License |
02335e399a16
Test functor extension code from outside scope.
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
15 * along with this program. If not, see <http://www.gnu.org/licenses>. |
02335e399a16
Test functor extension code from outside scope.
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
16 * |
02335e399a16
Test functor extension code from outside scope.
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
17 * The Audacious team does not consider modular code linking to |
02335e399a16
Test functor extension code from outside scope.
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
18 * Audacious or using our public API to be a derived work. |
02335e399a16
Test functor extension code from outside scope.
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
19 */ |
02335e399a16
Test functor extension code from outside scope.
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
20 |
02335e399a16
Test functor extension code from outside scope.
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
21 #include <glib.h> |
02335e399a16
Test functor extension code from outside scope.
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
22 #include <mowgli.h> |
02335e399a16
Test functor extension code from outside scope.
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
23 |
02335e399a16
Test functor extension code from outside scope.
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
24 #include "tuple.h" |
02335e399a16
Test functor extension code from outside scope.
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
25 #include "tuple_formatter.h" |
02335e399a16
Test functor extension code from outside scope.
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
26 |
02335e399a16
Test functor extension code from outside scope.
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
27 static gboolean |
02335e399a16
Test functor extension code from outside scope.
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
28 test_functor(Tuple *tuple, const char *expr) |
02335e399a16
Test functor extension code from outside scope.
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
29 { |
02335e399a16
Test functor extension code from outside scope.
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
30 return TRUE; |
02335e399a16
Test functor extension code from outside scope.
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
31 } |
02335e399a16
Test functor extension code from outside scope.
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
32 |
02335e399a16
Test functor extension code from outside scope.
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
33 int |
02335e399a16
Test functor extension code from outside scope.
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
34 test_run(int argc, const char *argv[]) |
02335e399a16
Test functor extension code from outside scope.
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
35 { |
02335e399a16
Test functor extension code from outside scope.
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
36 Tuple *tuple; |
02335e399a16
Test functor extension code from outside scope.
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
37 gchar *tstr; |
02335e399a16
Test functor extension code from outside scope.
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
38 |
02335e399a16
Test functor extension code from outside scope.
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
39 tuple_formatter_register_expression("(true)", test_functor); |
02335e399a16
Test functor extension code from outside scope.
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
40 |
02335e399a16
Test functor extension code from outside scope.
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
41 tuple = tuple_new(); |
02335e399a16
Test functor extension code from outside scope.
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
42 tuple_associate_string(tuple, "splork", "moo"); |
02335e399a16
Test functor extension code from outside scope.
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
43 |
02335e399a16
Test functor extension code from outside scope.
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
44 tstr = tuple_formatter_process_string(tuple, "${(true):${splork}}"); |
02335e399a16
Test functor extension code from outside scope.
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
45 if (g_ascii_strcasecmp(tstr, "moo")) |
02335e399a16
Test functor extension code from outside scope.
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
46 { |
02335e399a16
Test functor extension code from outside scope.
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
47 g_print("fail 1: '%s'\n", tstr); |
02335e399a16
Test functor extension code from outside scope.
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
48 return EXIT_FAILURE; |
02335e399a16
Test functor extension code from outside scope.
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
49 } |
02335e399a16
Test functor extension code from outside scope.
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
50 g_free(tstr); |
02335e399a16
Test functor extension code from outside scope.
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
51 |
3292
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3291
diff
changeset
|
52 tstr = tuple_formatter_process_string(tuple, "%{audacious-version}"); |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3291
diff
changeset
|
53 if (g_str_has_prefix(tstr, "audacious") == FALSE) |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3291
diff
changeset
|
54 { |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3291
diff
changeset
|
55 g_print("fail 2: '%s'\n", tstr); |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3291
diff
changeset
|
56 return EXIT_FAILURE; |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3291
diff
changeset
|
57 } |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3291
diff
changeset
|
58 g_free(tstr); |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3291
diff
changeset
|
59 |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3291
diff
changeset
|
60 tstr = tuple_formatter_process_string(tuple, "${(true):%{audacious-version}}"); |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3291
diff
changeset
|
61 if (g_str_has_prefix(tstr, "audacious") == FALSE) |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3291
diff
changeset
|
62 { |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3291
diff
changeset
|
63 g_print("fail 3: '%s'\n", tstr); |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3291
diff
changeset
|
64 return EXIT_FAILURE; |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3291
diff
changeset
|
65 } |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3291
diff
changeset
|
66 g_free(tstr); |
a97fb19a0148
Add support for functions.
William Pitcock <nenolod@atheme-project.org>
parents:
3291
diff
changeset
|
67 |
3291
02335e399a16
Test functor extension code from outside scope.
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
68 mowgli_object_unref(tuple); |
02335e399a16
Test functor extension code from outside scope.
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
69 |
02335e399a16
Test functor extension code from outside scope.
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
70 return EXIT_SUCCESS; |
02335e399a16
Test functor extension code from outside scope.
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
71 } |