~ubuntu-branches/ubuntu/saucy/evolution-data-server/saucy

« back to all changes in this revision

Viewing changes to camel/tests/message/test2.c

  • Committer: Package Import Robot
  • Author(s): Chris Coulson
  • Date: 2012-10-08 12:58:16 UTC
  • mfrom: (181.1.7 quantal)
  • Revision ID: package-import@ubuntu.com-20121008125816-i3n76e8c0m64e7xp
Tags: 3.6.0-0ubuntu2
* Fix LP: #1038047 part 1 - Don't abort in e_source_registry_new* when a
  problem occurs connecting to the Dbus service
  - add debian/patches/dont-abort-in-e_source_registry_new.patch
  - update debian/patches/series
* Fix LP: #1038047 part 2 - libedataserver depends on
  evolution-data-server-common to ensure that the GSettings schemas are
  present
  - update debian/control

Show diffs side-by-side

added added

removed removed

Lines of Context:
58
58
                noutp = nout = g_malloc (outlen);
59
59
                if (iconv (ic, &inp, &inlen, &noutp, &outlen) == -1
60
60
                    || iconv (ic, NULL, 0, &noutp, &outlen) == -1) {
61
 
                        g_warning("Cannot convert '%s' \n from %s to %s: %s\n", in, to, from, g_strerror(errno));
 
61
                        g_warning ("Cannot convert '%s' \n from %s to %s: %s\n", in, to, from, g_strerror (errno));
62
62
                }
63
63
                iconv_close (ic);
64
64
        }
65
65
 
66
66
        /* and lets see what camel thinks out optimal charset is */
67
67
        {
68
 
                printf("Camel thinks the best encoding of '%s' is %s, although we converted from %s\n",
69
 
                       in, camel_charset_best (out, strlen (out)), from);
 
68
                printf (
 
69
                        "Camel thinks the best encoding of '%s' is %s, although we converted from %s\n",
 
70
                        in, camel_charset_best (out, strlen (out)), from);
70
71
        }
71
72
fail:
72
73
#endif
109
110
 
110
111
        camel_test_init (argc, argv);
111
112
 
112
 
        camel_test_start("CamelInternetAddress, basics");
 
113
        camel_test_start ("CamelInternetAddress, basics");
113
114
 
114
115
        addr = camel_internet_address_new ();
115
116
 
116
 
        push("Test blank address");
 
117
        push ("Test blank address");
117
118
        check (camel_address_length (CAMEL_ADDRESS (addr)) == 0);
118
119
        check (camel_internet_address_get (addr, 0, &real, &where) == FALSE);
119
120
        pull ();
120
121
 
121
 
        push("Test blank clone");
 
122
        push ("Test blank clone");
122
123
        addr2 = CAMEL_INTERNET_ADDRESS (camel_address_new_clone (CAMEL_ADDRESS (addr)));
123
124
        test_address_compare (addr, addr2);
124
125
        check_unref (addr2, 1);
125
126
        pull ();
126
127
 
127
 
        push("Test add 1");
128
 
        camel_internet_address_add(addr, "Zed", "nowhere@here.com.au");
 
128
        push ("Test add 1");
 
129
        camel_internet_address_add (addr, "Zed", "nowhere@here.com.au");
129
130
        check (camel_address_length (CAMEL_ADDRESS (addr)) == 1);
130
131
        check (camel_internet_address_get (addr, 0, &real, &where) == TRUE);
131
 
        check_msg(string_equal("Zed", real), "real = '%s'", real);
132
 
        check(strcmp(where, "nowhere@here.com.au") == 0);
 
132
        check_msg (string_equal ("Zed", real), "real = '%s'", real);
 
133
        check (strcmp (where, "nowhere@here.com.au") == 0);
133
134
        pull ();
134
135
 
135
 
        push("Test clone 1");
 
136
        push ("Test clone 1");
136
137
        addr2 = CAMEL_INTERNET_ADDRESS (camel_address_new_clone (CAMEL_ADDRESS (addr)));
137
138
        test_address_compare (addr, addr2);
138
139
        check_unref (addr2, 1);
139
140
        pull ();
140
141
 
141
 
        push("Test add many");
 
142
        push ("Test add many");
142
143
        for (i = 1; i < 10; i++) {
143
144
                gchar name[16], a[32];
144
 
                sprintf(name, "Zed %d", i);
145
 
                sprintf(a, "nowhere@here-%d.com.au", i);
 
145
                sprintf (name, "Zed %d", i);
 
146
                sprintf (a, "nowhere@here-%d.com.au", i);
146
147
                camel_internet_address_add (addr, name, a);
147
148
                check (camel_address_length (CAMEL_ADDRESS (addr)) == i + 1);
148
149
                check (camel_internet_address_get (addr, i, &real, &where) == TRUE);
149
 
                check_msg(string_equal(name, real), "name = '%s' real = '%s'", name, real);
 
150
                check_msg (string_equal (name, real), "name = '%s' real = '%s'", name, real);
150
151
                check (strcmp (where, a) == 0);
151
152
        }
152
153
        pull ();
153
154
 
154
155
        /* put a few of these in to make it look like its doing something impressive ... :) */
155
156
        camel_test_end ();
156
 
        camel_test_start("CamelInternetAddress, search");
 
157
        camel_test_start ("CamelInternetAddress, search");
157
158
 
158
 
        push("Test search");
159
 
        camel_test_nonfatal("Address comparisons should ignore whitespace??");
160
 
        check(camel_internet_address_find_name(addr, "Zed 1", &where) == 1);
161
 
        check(camel_internet_address_find_name(addr, "Zed 9", &where) == 9);
162
 
        check(camel_internet_address_find_name(addr, "Zed", &where) == 0);
163
 
        check(camel_internet_address_find_name(addr, " Zed", &where) == 0);
164
 
        check(camel_internet_address_find_name(addr, "Zed ", &where) == 0);
165
 
        check(camel_internet_address_find_name(addr, "  Zed ", &where) == 0);
166
 
        check(camel_internet_address_find_name(addr, "Zed 20", &where) == -1);
167
 
        check(camel_internet_address_find_name(addr, "", &where) == -1);
 
159
        push ("Test search");
 
160
        camel_test_nonfatal ("Address comparisons should ignore whitespace??");
 
161
        check (camel_internet_address_find_name (addr, "Zed 1", &where) == 1);
 
162
        check (camel_internet_address_find_name (addr, "Zed 9", &where) == 9);
 
163
        check (camel_internet_address_find_name (addr, "Zed", &where) == 0);
 
164
        check (camel_internet_address_find_name (addr, " Zed", &where) == 0);
 
165
        check (camel_internet_address_find_name (addr, "Zed ", &where) == 0);
 
166
        check (camel_internet_address_find_name (addr, "  Zed ", &where) == 0);
 
167
        check (camel_internet_address_find_name (addr, "Zed 20", &where) == -1);
 
168
        check (camel_internet_address_find_name (addr, "", &where) == -1);
168
169
        /* interface dont handle nulls :) */
169
170
        /*check(camel_internet_address_find_name(addr, NULL, &where) == -1);*/
170
171
 
171
 
        check(camel_internet_address_find_address(addr, "nowhere@here-1.com.au", &where) == 1);
172
 
        check(camel_internet_address_find_address(addr, "nowhere@here-1 . com.au", &where) == 1);
173
 
        check(camel_internet_address_find_address(addr, "nowhere@here-2 .com.au ", &where) == 2);
174
 
        check(camel_internet_address_find_address(addr, " nowhere @here-3.com.au", &where) == 3);
175
 
        check(camel_internet_address_find_address(addr, "nowhere@here-20.com.au ", &where) == -1);
176
 
        check(camel_internet_address_find_address(addr, "", &where) == -1);
 
172
        check (camel_internet_address_find_address (addr, "nowhere@here-1.com.au", &where) == 1);
 
173
        check (camel_internet_address_find_address (addr, "nowhere@here-1 . com.au", &where) == 1);
 
174
        check (camel_internet_address_find_address (addr, "nowhere@here-2 .com.au ", &where) == 2);
 
175
        check (camel_internet_address_find_address (addr, " nowhere @here-3.com.au", &where) == 3);
 
176
        check (camel_internet_address_find_address (addr, "nowhere@here-20.com.au ", &where) == -1);
 
177
        check (camel_internet_address_find_address (addr, "", &where) == -1);
177
178
        /*check(camel_internet_address_find_address(addr, NULL, &where) == -1);*/
178
179
        camel_test_fatal ();
179
180
        pull ();
180
181
 
181
182
        camel_test_end ();
182
 
        camel_test_start("CamelInternetAddress, copy/cat/clone");
 
183
        camel_test_start ("CamelInternetAddress, copy/cat/clone");
183
184
 
184
 
        push("Test clone many");
 
185
        push ("Test clone many");
185
186
        addr2 = CAMEL_INTERNET_ADDRESS (camel_address_new_clone (CAMEL_ADDRESS (addr)));
186
187
        test_address_compare (addr, addr2);
187
188
        pull ();
188
189
 
189
 
        push("Test remove items");
 
190
        push ("Test remove items");
190
191
        camel_address_remove (CAMEL_ADDRESS (addr2), 0);
191
192
        check (camel_address_length (CAMEL_ADDRESS (addr2)) == 9);
192
193
        camel_address_remove (CAMEL_ADDRESS (addr2), 0);
200
201
        check_unref (addr2, 1);
201
202
        pull ();
202
203
 
203
 
        push("Testing copy/cat");
204
 
        push("clone + cat");
 
204
        push ("Testing copy/cat");
 
205
        push ("clone + cat");
205
206
        addr2 = CAMEL_INTERNET_ADDRESS (camel_address_new_clone (CAMEL_ADDRESS (addr)));
206
207
        camel_address_cat (CAMEL_ADDRESS (addr2), CAMEL_ADDRESS (addr));
207
208
        check (camel_address_length (CAMEL_ADDRESS (addr)) == 10);
209
210
        check_unref (addr2, 1);
210
211
        pull ();
211
212
 
212
 
        push("cat + cat + copy");
 
213
        push ("cat + cat + copy");
213
214
        addr2 = camel_internet_address_new ();
214
215
        camel_address_cat (CAMEL_ADDRESS (addr2), CAMEL_ADDRESS (addr));
215
216
        test_address_compare (addr, addr2);
221
222
        check_unref (addr2, 1);
222
223
        pull ();
223
224
 
224
 
        push("copy");
 
225
        push ("copy");
225
226
        addr2 = camel_internet_address_new ();
226
227
        camel_address_copy (CAMEL_ADDRESS (addr2), CAMEL_ADDRESS (addr));
227
228
        test_address_compare (addr, addr2);
234
235
 
235
236
        camel_test_end ();
236
237
 
237
 
        camel_test_start("CamelInternetAddress, I18N");
 
238
        camel_test_start ("CamelInternetAddress, I18N");
238
239
 
239
240
        for (i = 0; i < G_N_ELEMENTS (test_lines); i++) {
240
 
                push("Testing text line %d (%s) '%s'", i, test_lines[i].type, test_lines[i].line);
 
241
                push ("Testing text line %d (%s) '%s'", i, test_lines[i].type, test_lines[i].line);
241
242
 
242
243
                addr = camel_internet_address_new ();
243
244
 
245
246
                charset = test_lines[i].type;
246
247
                name = to_utf8 (test_lines[i].line, charset);
247
248
 
248
 
                push("Address setup");
249
 
                camel_internet_address_add(addr, name, "nobody@nowhere.com");
 
249
                push ("Address setup");
 
250
                camel_internet_address_add (addr, name, "nobody@nowhere.com");
250
251
                check (camel_internet_address_get (addr, 0, &real, &where) == TRUE);
251
 
                check_msg(string_equal(name, real), "name = '%s' real = '%s'", name, real);
252
 
                check(strcmp(where, "nobody@nowhere.com") == 0);
 
252
                check_msg (string_equal (name, real), "name = '%s' real = '%s'", name, real);
 
253
                check (strcmp (where, "nobody@nowhere.com") == 0);
253
254
                test_free (name);
254
255
 
255
256
                check (camel_internet_address_get (addr, 1, &real, &where) == FALSE);
256
257
                check (camel_address_length (CAMEL_ADDRESS (addr)) == 1);
257
258
                pull ();
258
259
 
259
 
                push("Address encode/decode");
 
260
                push ("Address encode/decode");
260
261
                enc = camel_address_encode (CAMEL_ADDRESS (addr));
261
262
 
262
263
                addr2 = camel_internet_address_new ();
264
265
                check (camel_address_length (CAMEL_ADDRESS (addr2)) == 1);
265
266
 
266
267
                enc2 = camel_address_encode (CAMEL_ADDRESS (addr2));
267
 
                check_msg(string_equal(enc, enc2), "enc = '%s' enc2 = '%s'", enc, enc2);
 
268
                check_msg (string_equal (enc, enc2), "enc = '%s' enc2 = '%s'", enc, enc2);
268
269
                test_free (enc2);
269
270
 
270
 
                push("Compare addresses");
 
271
                push ("Compare addresses");
271
272
                test_address_compare (addr, addr2);
272
273
                pull ();
273
274
                check_unref (addr2, 1);
275
276
                pull ();
276
277
 
277
278
                /* FIXME: format/unformat arne't guaranteed to be reversible, at least at the moment */
278
 
                camel_test_nonfatal("format/unformat not (yet) reversible for all cases");
 
279
                camel_test_nonfatal ("format/unformat not (yet) reversible for all cases");
279
280
 
280
 
                push("Address format/unformat");
 
281
                push ("Address format/unformat");
281
282
                format = camel_address_format (CAMEL_ADDRESS (addr));
282
283
 
283
284
                addr2 = camel_internet_address_new ();
285
286
                check (camel_address_length (CAMEL_ADDRESS (addr2)) == 1);
286
287
 
287
288
                format2 = camel_address_format (CAMEL_ADDRESS (addr2));
288
 
                check_msg(string_equal(format, format2), "format = '%s\n\tformat2 = '%s'", format, format2);
 
289
                check_msg (string_equal (format, format2), "format = '%s\n\tformat2 = '%s'", format, format2);
289
290
                test_free (format2);
290
291
 
291
292
                /* currently format/unformat doesn't handle ,'s and other special chars at all */
292
293
                if (camel_address_length (CAMEL_ADDRESS (addr2)) == 1) {
293
 
                        push("Compare addresses");
 
294
                        push ("Compare addresses");
294
295
                        test_address_compare (addr, addr2);
295
296
                        pull ();
296
297
                }
309
310
 
310
311
        camel_test_end ();
311
312
 
312
 
        camel_test_start("CamelInternetAddress, I18N decode");
 
313
        camel_test_start ("CamelInternetAddress, I18N decode");
313
314
 
314
315
        for (i = 0; i < G_N_ELEMENTS (test_address); i++) {
315
 
                push("Testing address line %d '%s'", i, test_address[i].addr);
 
316
                push ("Testing address line %d '%s'", i, test_address[i].addr);
316
317
 
317
318
                addr = camel_internet_address_new ();
318
 
                push("checking decoded");
 
319
                push ("checking decoded");
319
320
                check (camel_address_decode (CAMEL_ADDRESS (addr), test_address[i].addr) == test_address[i].count);
320
321
                format = camel_address_format (CAMEL_ADDRESS (addr));
321
322
                check (strcmp (format, test_address[i].utf8) == 0);
322
323
                test_free (format);
323
324
                pull ();
324
325
 
325
 
                push("Comparing re-encoded output");
 
326
                push ("Comparing re-encoded output");
326
327
                addr2 = CAMEL_INTERNET_ADDRESS (camel_internet_address_new ());
327
328
                enc = camel_address_encode (CAMEL_ADDRESS (addr));
328
 
                check_msg(camel_address_decode(CAMEL_ADDRESS(addr2), enc) == test_address[i].count, "enc = '%s'", enc);
 
329
                check_msg (camel_address_decode (CAMEL_ADDRESS (addr2), enc) == test_address[i].count, "enc = '%s'", enc);
329
330
                test_free (enc);
330
331
                test_address_compare (addr, addr2);
331
332
                check_unref (addr2, 1);