Mercurial > audlegacy
annotate src/tests/tuple_formatter_test.c @ 3317:d18d66f1b1d0 trunk
whoops...
author | William Pitcock <nenolod@atheme-project.org> |
---|---|
date | Fri, 10 Aug 2007 12:29:56 -0500 |
parents | 6ce62683e8c4 |
children | 6e3ae4fd65f1 |
rev | line source |
---|---|
3285
740c6f845554
revise tuple formatting engine logic
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
1 /* |
740c6f845554
revise tuple formatting engine logic
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
2 * Audacious |
740c6f845554
revise tuple formatting engine logic
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
3 * Copyright (c) 2007 William Pitcock |
740c6f845554
revise tuple formatting engine logic
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
4 * |
740c6f845554
revise tuple formatting engine logic
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
5 * This program is free software; you can redistribute it and/or modify |
740c6f845554
revise tuple formatting engine logic
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
6 * it under the terms of the GNU General Public License as published by |
740c6f845554
revise tuple formatting engine logic
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
7 * the Free Software Foundation; under version 3 of the License. |
740c6f845554
revise tuple formatting engine logic
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
8 * |
740c6f845554
revise tuple formatting engine logic
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
9 * This program is distributed in the hope that it will be useful, |
740c6f845554
revise tuple formatting engine logic
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
740c6f845554
revise tuple formatting engine logic
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
740c6f845554
revise tuple formatting engine logic
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
12 * GNU General Public License for more details. |
740c6f845554
revise tuple formatting engine logic
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
13 * |
740c6f845554
revise tuple formatting engine logic
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
14 * You should have received a copy of the GNU General Public License |
740c6f845554
revise tuple formatting engine logic
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
15 * along with this program. If not, see <http://www.gnu.org/licenses>. |
740c6f845554
revise tuple formatting engine logic
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
16 * |
740c6f845554
revise tuple formatting engine logic
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
17 * The Audacious team does not consider modular code linking to |
740c6f845554
revise tuple formatting engine logic
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
18 * Audacious or using our public API to be a derived work. |
740c6f845554
revise tuple formatting engine logic
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
19 */ |
740c6f845554
revise tuple formatting engine logic
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
20 |
740c6f845554
revise tuple formatting engine logic
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
21 #include <glib.h> |
740c6f845554
revise tuple formatting engine logic
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
22 #include <mowgli.h> |
740c6f845554
revise tuple formatting engine logic
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
23 |
740c6f845554
revise tuple formatting engine logic
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
24 #include "tuple.h" |
740c6f845554
revise tuple formatting engine logic
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
25 #include "tuple_formatter.h" |
740c6f845554
revise tuple formatting engine logic
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
26 |
740c6f845554
revise tuple formatting engine logic
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
27 int |
740c6f845554
revise tuple formatting engine logic
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
28 test_run(int argc, const char *argv[]) |
740c6f845554
revise tuple formatting engine logic
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
29 { |
740c6f845554
revise tuple formatting engine logic
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
30 Tuple *tuple; |
740c6f845554
revise tuple formatting engine logic
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
31 gchar *tstr; |
740c6f845554
revise tuple formatting engine logic
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
32 |
740c6f845554
revise tuple formatting engine logic
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
33 tuple = tuple_new(); |
740c6f845554
revise tuple formatting engine logic
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
34 tuple_associate_string(tuple, "splork", "moo"); |
740c6f845554
revise tuple formatting engine logic
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
35 tuple_associate_int(tuple, "splorkerz", 42); |
740c6f845554
revise tuple formatting engine logic
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
36 |
740c6f845554
revise tuple formatting engine logic
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
37 tstr = tuple_formatter_process_string(tuple, "${splork} ${splorkerz}"); |
740c6f845554
revise tuple formatting engine logic
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
38 if (g_ascii_strcasecmp(tstr, "moo 42")) |
740c6f845554
revise tuple formatting engine logic
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
39 { |
740c6f845554
revise tuple formatting engine logic
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
40 g_print("fail 1: '%s'\n", tstr); |
740c6f845554
revise tuple formatting engine logic
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
41 return EXIT_FAILURE; |
740c6f845554
revise tuple formatting engine logic
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
42 } |
740c6f845554
revise tuple formatting engine logic
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
43 g_free(tstr); |
740c6f845554
revise tuple formatting engine logic
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
44 |
740c6f845554
revise tuple formatting engine logic
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
45 tstr = tuple_formatter_process_string(tuple, "${?fizz:${splork}} ${splorkerz}"); |
740c6f845554
revise tuple formatting engine logic
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
46 if (g_ascii_strcasecmp(tstr, " 42")) |
740c6f845554
revise tuple formatting engine logic
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
47 { |
740c6f845554
revise tuple formatting engine logic
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
48 g_print("fail 2: '%s'\n", tstr); |
740c6f845554
revise tuple formatting engine logic
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
49 return EXIT_FAILURE; |
740c6f845554
revise tuple formatting engine logic
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
50 } |
740c6f845554
revise tuple formatting engine logic
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
51 g_free(tstr); |
740c6f845554
revise tuple formatting engine logic
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
52 |
740c6f845554
revise tuple formatting engine logic
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
53 tstr = tuple_formatter_process_string(tuple, "${?splork:${splork}} ${splorkerz}"); |
740c6f845554
revise tuple formatting engine logic
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
54 if (g_ascii_strcasecmp(tstr, "moo 42")) |
740c6f845554
revise tuple formatting engine logic
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
55 { |
740c6f845554
revise tuple formatting engine logic
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
56 g_print("fail 3: '%s'\n", tstr); |
740c6f845554
revise tuple formatting engine logic
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
57 return EXIT_FAILURE; |
740c6f845554
revise tuple formatting engine logic
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
58 } |
740c6f845554
revise tuple formatting engine logic
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
59 g_free(tstr); |
740c6f845554
revise tuple formatting engine logic
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
60 |
3286
8576de468e23
Add != operator.
William Pitcock <nenolod@atheme-project.org>
parents:
3285
diff
changeset
|
61 tstr = tuple_formatter_process_string(tuple, "${==splork,splork:fields given matched}"); |
8576de468e23
Add != operator.
William Pitcock <nenolod@atheme-project.org>
parents:
3285
diff
changeset
|
62 if (g_ascii_strcasecmp(tstr, "fields given matched")) |
8576de468e23
Add != operator.
William Pitcock <nenolod@atheme-project.org>
parents:
3285
diff
changeset
|
63 { |
8576de468e23
Add != operator.
William Pitcock <nenolod@atheme-project.org>
parents:
3285
diff
changeset
|
64 g_print("fail 4: '%s'\n", tstr); |
8576de468e23
Add != operator.
William Pitcock <nenolod@atheme-project.org>
parents:
3285
diff
changeset
|
65 return EXIT_FAILURE; |
8576de468e23
Add != operator.
William Pitcock <nenolod@atheme-project.org>
parents:
3285
diff
changeset
|
66 } |
8576de468e23
Add != operator.
William Pitcock <nenolod@atheme-project.org>
parents:
3285
diff
changeset
|
67 g_free(tstr); |
8576de468e23
Add != operator.
William Pitcock <nenolod@atheme-project.org>
parents:
3285
diff
changeset
|
68 |
8576de468e23
Add != operator.
William Pitcock <nenolod@atheme-project.org>
parents:
3285
diff
changeset
|
69 tstr = tuple_formatter_process_string(tuple, "${==splork,splork:${splork}}"); |
8576de468e23
Add != operator.
William Pitcock <nenolod@atheme-project.org>
parents:
3285
diff
changeset
|
70 if (g_ascii_strcasecmp(tstr, "moo")) |
8576de468e23
Add != operator.
William Pitcock <nenolod@atheme-project.org>
parents:
3285
diff
changeset
|
71 { |
8576de468e23
Add != operator.
William Pitcock <nenolod@atheme-project.org>
parents:
3285
diff
changeset
|
72 g_print("fail 5: '%s'\n", tstr); |
8576de468e23
Add != operator.
William Pitcock <nenolod@atheme-project.org>
parents:
3285
diff
changeset
|
73 return EXIT_FAILURE; |
8576de468e23
Add != operator.
William Pitcock <nenolod@atheme-project.org>
parents:
3285
diff
changeset
|
74 } |
8576de468e23
Add != operator.
William Pitcock <nenolod@atheme-project.org>
parents:
3285
diff
changeset
|
75 g_free(tstr); |
8576de468e23
Add != operator.
William Pitcock <nenolod@atheme-project.org>
parents:
3285
diff
changeset
|
76 |
8576de468e23
Add != operator.
William Pitcock <nenolod@atheme-project.org>
parents:
3285
diff
changeset
|
77 tstr = tuple_formatter_process_string(tuple, "${!=splork,splorkerz:fields did not match}"); |
8576de468e23
Add != operator.
William Pitcock <nenolod@atheme-project.org>
parents:
3285
diff
changeset
|
78 if (g_ascii_strcasecmp(tstr, "fields did not match")) |
8576de468e23
Add != operator.
William Pitcock <nenolod@atheme-project.org>
parents:
3285
diff
changeset
|
79 { |
8576de468e23
Add != operator.
William Pitcock <nenolod@atheme-project.org>
parents:
3285
diff
changeset
|
80 g_print("fail 6: '%s'\n", tstr); |
8576de468e23
Add != operator.
William Pitcock <nenolod@atheme-project.org>
parents:
3285
diff
changeset
|
81 return EXIT_FAILURE; |
8576de468e23
Add != operator.
William Pitcock <nenolod@atheme-project.org>
parents:
3285
diff
changeset
|
82 } |
8576de468e23
Add != operator.
William Pitcock <nenolod@atheme-project.org>
parents:
3285
diff
changeset
|
83 g_free(tstr); |
8576de468e23
Add != operator.
William Pitcock <nenolod@atheme-project.org>
parents:
3285
diff
changeset
|
84 |
8576de468e23
Add != operator.
William Pitcock <nenolod@atheme-project.org>
parents:
3285
diff
changeset
|
85 tstr = tuple_formatter_process_string(tuple, "${!=splork,splorkerz:${splorkerz}}"); |
8576de468e23
Add != operator.
William Pitcock <nenolod@atheme-project.org>
parents:
3285
diff
changeset
|
86 if (g_ascii_strcasecmp(tstr, "42")) |
8576de468e23
Add != operator.
William Pitcock <nenolod@atheme-project.org>
parents:
3285
diff
changeset
|
87 { |
8576de468e23
Add != operator.
William Pitcock <nenolod@atheme-project.org>
parents:
3285
diff
changeset
|
88 g_print("fail 7: '%s'\n", tstr); |
8576de468e23
Add != operator.
William Pitcock <nenolod@atheme-project.org>
parents:
3285
diff
changeset
|
89 return EXIT_FAILURE; |
8576de468e23
Add != operator.
William Pitcock <nenolod@atheme-project.org>
parents:
3285
diff
changeset
|
90 } |
8576de468e23
Add != operator.
William Pitcock <nenolod@atheme-project.org>
parents:
3285
diff
changeset
|
91 g_free(tstr); |
8576de468e23
Add != operator.
William Pitcock <nenolod@atheme-project.org>
parents:
3285
diff
changeset
|
92 |
3288 | 93 tstr = tuple_formatter_process_string(tuple, "${!=splork,splork:${splorkerz}}"); |
94 if (g_ascii_strcasecmp(tstr, "")) | |
95 { | |
96 g_print("fail 8: '%s'\n", tstr); | |
97 return EXIT_FAILURE; | |
98 } | |
99 g_free(tstr); | |
100 | |
3290
4e7cc6d9b525
add (empty)? function to formatter
William Pitcock <nenolod@atheme-project.org>
parents:
3288
diff
changeset
|
101 tstr = tuple_formatter_process_string(tuple, "${(empty)?splorky:${splorkerz}}"); |
4e7cc6d9b525
add (empty)? function to formatter
William Pitcock <nenolod@atheme-project.org>
parents:
3288
diff
changeset
|
102 if (g_ascii_strcasecmp(tstr, "42")) |
4e7cc6d9b525
add (empty)? function to formatter
William Pitcock <nenolod@atheme-project.org>
parents:
3288
diff
changeset
|
103 { |
4e7cc6d9b525
add (empty)? function to formatter
William Pitcock <nenolod@atheme-project.org>
parents:
3288
diff
changeset
|
104 g_print("fail 9: '%s'\n", tstr); |
4e7cc6d9b525
add (empty)? function to formatter
William Pitcock <nenolod@atheme-project.org>
parents:
3288
diff
changeset
|
105 return EXIT_FAILURE; |
4e7cc6d9b525
add (empty)? function to formatter
William Pitcock <nenolod@atheme-project.org>
parents:
3288
diff
changeset
|
106 } |
4e7cc6d9b525
add (empty)? function to formatter
William Pitcock <nenolod@atheme-project.org>
parents:
3288
diff
changeset
|
107 g_free(tstr); |
4e7cc6d9b525
add (empty)? function to formatter
William Pitcock <nenolod@atheme-project.org>
parents:
3288
diff
changeset
|
108 |
3310 | 109 tstr = tuple_formatter_process_string(tuple, "${?splork:${splork} - }${splork}"); |
3308
2aed30eaca87
Add a test which displays the backtracking bug.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
110 if (g_ascii_strcasecmp(tstr, "moo - moo")) |
2aed30eaca87
Add a test which displays the backtracking bug.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
111 { |
2aed30eaca87
Add a test which displays the backtracking bug.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
112 g_print("fail 10: '%s'\n", tstr); |
2aed30eaca87
Add a test which displays the backtracking bug.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
113 return EXIT_FAILURE; |
2aed30eaca87
Add a test which displays the backtracking bug.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
114 } |
2aed30eaca87
Add a test which displays the backtracking bug.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
115 g_free(tstr); |
2aed30eaca87
Add a test which displays the backtracking bug.
William Pitcock <nenolod@atheme-project.org>
parents:
3290
diff
changeset
|
116 |
3316 | 117 tstr = tuple_formatter_process_string(tuple, "${?splork:${?splork:${splork}} - }${splork}"); |
118 if (g_ascii_strcasecmp(tstr, "moo - moo")) | |
119 { | |
120 g_print("fail 11: '%s'\n", tstr); | |
121 return EXIT_FAILURE; | |
122 } | |
123 g_free(tstr); | |
124 | |
3287
d003b429bd03
unref our tuple
William Pitcock <nenolod@atheme-project.org>
parents:
3286
diff
changeset
|
125 mowgli_object_unref(tuple); |
d003b429bd03
unref our tuple
William Pitcock <nenolod@atheme-project.org>
parents:
3286
diff
changeset
|
126 |
3285
740c6f845554
revise tuple formatting engine logic
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
127 return EXIT_SUCCESS; |
740c6f845554
revise tuple formatting engine logic
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
128 } |