PageRenderTime 133ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/dbmail-3.0.2/test/check_dbmail_misc.c

#
C | 612 lines | 486 code | 80 blank | 46 comment | 26 complexity | e7b9dcca493d7b9c9d92b8e1d601a304 MD5 | raw file
Possible License(s): GPL-2.0
  1. /*
  2. * Copyright (C) 2006 Aaron Stone <aaron@serendipity.cx>
  3. * Copyright (c) 2005-2011 NFG Net Facilities Group BV support@nfg.nl
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License
  7. * as published by the Free Software Foundation; either
  8. * version 2 of the License, or (at your option) any later
  9. * version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  19. *
  20. *
  21. *
  22. *
  23. *
  24. *
  25. *
  26. * Basic unit-test framework for dbmail (www.dbmail.org)
  27. *
  28. * See http://check.sf.net for details and docs.
  29. *
  30. *
  31. * Run 'make check' to see some action.
  32. *
  33. */
  34. #include <check.h>
  35. #include "check_dbmail.h"
  36. extern char *configFile;
  37. extern int quiet;
  38. extern int reallyquiet;
  39. /*
  40. *
  41. * the test fixtures
  42. *
  43. */
  44. void setup(void)
  45. {
  46. reallyquiet = 1;
  47. configure_debug(255,0);
  48. config_read(configFile);
  49. GetDBParams();
  50. db_connect();
  51. auth_connect();
  52. g_mime_init(0);
  53. }
  54. void teardown(void)
  55. {
  56. db_disconnect();
  57. auth_disconnect();
  58. g_mime_shutdown();
  59. }
  60. START_TEST(test_g_strcasestr)
  61. {
  62. char *s = "asdfqwer";
  63. fail_unless(g_strcasestr(s,"SD")!=NULL,"g_strcasestr failed 1");
  64. fail_unless(g_strcasestr(s,"er")!=NULL,"g_strcasestr failed 2");
  65. fail_unless(g_strcasestr(s,"As")!=NULL,"g_strcasestr failed 3");
  66. }
  67. END_TEST
  68. char * g_strchomp_c(char *string, char c)
  69. {
  70. size_t len;
  71. if (! string) return NULL;
  72. len = strlen(string);
  73. while(len--) {
  74. if (string[len] && string[len] == c)
  75. string[len] = '\0';
  76. else
  77. break;
  78. }
  79. return string;
  80. }
  81. START_TEST(test_g_strchomp_c)
  82. {
  83. int i;
  84. const char *expect = "#Users";
  85. char *u, *t, *s[] = {
  86. "#Users",
  87. "#Users/",
  88. "#Users//",
  89. "#Users///",
  90. "#Users////",
  91. NULL
  92. };
  93. for (i=0; s[i]; i++) {
  94. u = g_strdup(s[i]);
  95. t = g_strchomp_c(u,'/');
  96. fail_unless(strcmp(t,expect)==0,"g_strchomp_c failed [%s] != [%s]", t, expect);
  97. g_free(u);
  98. }
  99. }
  100. END_TEST
  101. START_TEST(test_mailbox_remove_namespace)
  102. {
  103. char *t, *simple, *username, *namespace;
  104. char *patterns[] = {
  105. "#Users/foo/mailbox",
  106. "#Users/foo/*",
  107. "#Users/foo*",
  108. "#Users/",
  109. "#Users//",
  110. "#Users///",
  111. "#Users/%",
  112. "#Users*",
  113. "#Users",
  114. "#Public/foo/mailbox",
  115. "#Public/foo/*",
  116. "#Public/foo*",
  117. "#Public/",
  118. "#Public//",
  119. "#Public///",
  120. "#Public/%",
  121. "#Public*",
  122. "#Public", NULL
  123. };
  124. char *expected[18][3] = {
  125. { NAMESPACE_USER, "foo", "mailbox" },
  126. { NAMESPACE_USER, "foo", "*" },
  127. { NAMESPACE_USER, "foo", "*" },
  128. { NAMESPACE_USER, NULL, NULL },
  129. { NAMESPACE_USER, NULL, NULL },
  130. { NAMESPACE_USER, NULL, NULL },
  131. { NAMESPACE_USER, NULL, "%" },
  132. { NAMESPACE_USER, NULL, "*" },
  133. { NAMESPACE_USER, NULL, NULL },
  134. { NAMESPACE_PUBLIC, PUBLIC_FOLDER_USER, "foo/mailbox" },
  135. { NAMESPACE_PUBLIC, PUBLIC_FOLDER_USER, "foo/*" },
  136. { NAMESPACE_PUBLIC, PUBLIC_FOLDER_USER, "foo*" },
  137. { NAMESPACE_PUBLIC, PUBLIC_FOLDER_USER, "" },
  138. { NAMESPACE_PUBLIC, PUBLIC_FOLDER_USER, "" },
  139. { NAMESPACE_PUBLIC, PUBLIC_FOLDER_USER, "" },
  140. { NAMESPACE_PUBLIC, PUBLIC_FOLDER_USER, "%" },
  141. { NAMESPACE_PUBLIC, PUBLIC_FOLDER_USER, "*" },
  142. { NAMESPACE_PUBLIC, PUBLIC_FOLDER_USER, "" }
  143. };
  144. int i;
  145. for (i = 0; patterns[i]; i++) {
  146. t = g_strdup(patterns[i]);
  147. simple = mailbox_remove_namespace(t, &namespace, &username);
  148. fail_unless(((simple == NULL && expected[i][2] == NULL) || strcmp(simple, expected[i][2])==0),
  149. "\nmailbox_remove_namespace failed on [%s] [%s] != [%s]\n", patterns[i], simple, expected[i][2] );
  150. fail_unless( ((username== NULL && expected[i][1] == NULL) || strcmp(username, expected[i][1])==0),
  151. "\nmailbox_remove_namespace failed on [%s] [%s] != [%s]\n" , patterns[i], username, expected[i][1]);
  152. fail_unless( ((namespace == NULL && expected[i][0] == NULL) || strcmp(namespace, expected[i][0])==0),
  153. "\nmailbox_remove_namespace failed on [%s] [%s] != [%s]\n" , patterns[i], namespace, expected[i][0]);
  154. g_free(t);
  155. }
  156. }
  157. END_TEST
  158. START_TEST(test_dbmail_iconv_str_to_db)
  159. {
  160. const char *val = "=?windows-1251?B?0+/w4OLr5e335fHq6Okg8/fl8iDiIPHu4vDl7OXt7e7pIOru7O/g7ejo?=";
  161. const char *u71 = "Neue =?ISO-8859-1?Q?L=F6sung?= =?ISO-8859-1?Q?f=FCr?= unsere Kunden";
  162. const char *u72 = "=?ISO-8859-1?Q?L=F6sung?=";
  163. const char *u73 = "=?ISO-8859-1?Q?f=FCr?=";
  164. const char *u74 = "... =?ISO-8859-1?Q?=DCbergabe?= ...";
  165. const char *u75 = "=?iso-8859-1?q?a?=";
  166. const char *u76 = "=?utf-8?b?w6nDqcOp?=";
  167. const char *u77 = "=?iso-8859-1?Q?ver_isto_=3D=3E_FW:_Envio_de_erro_da_aplica=E7=E3o_Decimal?=\n\t=?iso-8859-1?Q?Fire-Direc=E7=E3o?=";
  168. const char *exp1 = "Neue Lösungfür unsere Kunden";
  169. const char *exp2 = "Lösung";
  170. const char *exp3 = "für";
  171. const char *exp4 = "... Übergabe ...";
  172. const char *exp5 = "a";
  173. const char *exp6 = "ééé";
  174. const char *exp7 = "ver isto => FW: Envio de erro da aplicação DecimalFire-Direcção";
  175. char *u8, *val2, *u82, *u83, *val3;
  176. u8 = g_mime_utils_header_decode_text(val);
  177. val2 = g_mime_utils_header_encode_text(u8);
  178. u82 = g_mime_utils_header_decode_text(val2);
  179. fail_unless(strcmp(u8,u82)==0,"decode/encode failed in test_dbmail_iconv_str_to_db");
  180. val3 = dbmail_iconv_db_to_utf7(u8);
  181. u83 = g_mime_utils_header_decode_text(val3);
  182. fail_unless(strcmp(u8,u83)==0,"decode/encode failed in test_dbmail_iconv_str_to_db\n[%s]\n[%s]\n", u8, u83);
  183. g_free(u8);
  184. g_free(u82);
  185. g_free(u83);
  186. g_free(val2);
  187. g_free(val3);
  188. //
  189. //
  190. u8 = dbmail_iconv_decode_text(u71);
  191. fail_unless(strcmp(u8,exp1)==0, "decode failed [%s] != [%s]", u8, exp1);
  192. g_free(u8);
  193. u8 = dbmail_iconv_decode_text(u72);
  194. fail_unless(strcmp(u8,exp2)==0,"decode failed [%s] != [%s]", u8, exp2);
  195. g_free(u8);
  196. u8 = dbmail_iconv_decode_text(u73);
  197. fail_unless(strcmp(u8,exp3)==0,"decode failed [%s] != [%s]", u8, exp3);
  198. g_free(u8);
  199. u8 = dbmail_iconv_decode_text(u74);
  200. fail_unless(strcmp(u8,exp4)==0, "decode failed [%s] != [%s]", u8, exp4);
  201. g_free(u8);
  202. u8 = dbmail_iconv_decode_text(u75);
  203. fail_unless(strcmp(u8,exp5)==0, "decode failed [%s] != [%s]", u8, exp5);
  204. g_free(u8);
  205. u8 = dbmail_iconv_decode_text(u76);
  206. fail_unless(strcmp(u8,exp6)==0, "decode failed [%s] != [%s]", u8, exp6);
  207. g_free(u8);
  208. u8 = dbmail_iconv_decode_text(u77);
  209. fail_unless(strcmp(u8,exp7)==0,"decode failed [%s] != [%s]", u8, exp7);
  210. g_free(u8);
  211. }
  212. END_TEST
  213. START_TEST(test_dbmail_iconv_decode_address)
  214. {
  215. char *u71 = "=?iso-8859-1?Q?::_=5B_Arrty_=5D_::_=5B_Roy_=28L=29_St=E8phanie_=5D?= <over.there@hotmail.com>";
  216. //const char *ex1 = "\":: [ Arrty ] :: [ Roy (L) Stèphanie ]\" <over.there@hotmail.com>";
  217. char *u72 = "=?utf-8?Q?Jos=E9_M=2E_Mart=EDn?= <jmartin@onsager.ugr.es>"; // latin-1 masking as utf8
  218. const char *ex2 = "Jos? M. Mart?n <jmartin@onsager.ugr.es>";
  219. char *u73 = "=?utf-8?B?Ik9ubGluZSBSZXplcnZhxI1uw60gU3lzdMOpbSBTTU9TSyI=?= <e@mail>";
  220. char *ex3;
  221. char *u8;
  222. u8 = dbmail_iconv_decode_address(u71);
  223. // fail_unless(strcmp(u8,ex1)==0,"decode failed\n[%s] != \n[%s]\n", u8, ex1);
  224. g_free(u8);
  225. u8 = dbmail_iconv_decode_address(u72);
  226. fail_unless(strcmp(u8,ex2)==0,"decode failed\n[%s] != \n[%s]\n", u8, ex2);
  227. g_free(u8);
  228. u8 = dbmail_iconv_decode_address(u73);
  229. ex3 = g_mime_utils_header_decode_text(u73);
  230. fail_unless(strcmp(u8,ex3)==0,"decode failed\n[%s] != \n[%s]\n", u8, ex3);
  231. g_free(u8);
  232. g_free(ex3);
  233. }
  234. END_TEST
  235. START_TEST(test_create_unique_id)
  236. {
  237. char *a = g_new0(char, 64);
  238. char *b = g_new0(char, 64);
  239. create_unique_id(a,0);
  240. create_unique_id(b,0);
  241. fail_unless(strlen(a)==32, "create_unique_id produced incorrect string length [%s][%d]", a, strlen(a));
  242. fail_unless(strlen(b)==32, "create_unique_id produced incorrect string length [%s][%d]", b, strlen(b));
  243. fail_unless(!MATCH(a,b),"create_unique_id shouldn't produce identical output");
  244. g_free(a);
  245. g_free(b);
  246. }
  247. END_TEST
  248. START_TEST(test_g_list_merge)
  249. {
  250. char *s;
  251. GList *a = NULL, *b = NULL;
  252. a = g_list_append(a, g_strdup("A"));
  253. a = g_list_append(a, g_strdup("B"));
  254. a = g_list_append(a, g_strdup("C"));
  255. b = g_list_append(b, g_strdup("D"));
  256. g_list_merge(&a, b, IMAPFA_ADD, (GCompareFunc)g_ascii_strcasecmp);
  257. s = dbmail_imap_plist_as_string(a);
  258. fail_unless(MATCH(s,"(A B C D)"), "g_list_merge ADD failed 1");
  259. b = g_list_append(b, g_strdup("A"));
  260. g_list_merge(&a, b, IMAPFA_ADD, (GCompareFunc)g_ascii_strcasecmp);
  261. s = dbmail_imap_plist_as_string(a);
  262. fail_unless(MATCH(s,"(A B C D)"), "g_list_merge ADD failed 2");
  263. g_list_merge(&a, b, IMAPFA_REMOVE, (GCompareFunc)g_ascii_strcasecmp);
  264. s = dbmail_imap_plist_as_string(a);
  265. fail_unless(MATCH(s,"(B C)"), "g_list_merge REMOVE failed");
  266. g_list_merge(&a, b, IMAPFA_REPLACE, (GCompareFunc)g_ascii_strcasecmp);
  267. s = dbmail_imap_plist_as_string(a);
  268. fail_unless(MATCH(s,"(D A)"), "g_list_merge REPLACE failed");
  269. }
  270. END_TEST
  271. START_TEST(test_dm_strtoull)
  272. {
  273. fail_unless(dm_strtoull("10",NULL,10)==10);
  274. fail_unless(dm_strtoull(" 10",NULL,10)==10);
  275. fail_unless(dm_strtoull("-10",NULL,10)==0);
  276. fail_unless(dm_strtoull("10",NULL,16)==16);
  277. fail_unless(dm_strtoull("10",NULL,2)==2);
  278. }
  279. END_TEST
  280. START_TEST(test_base64_decode)
  281. {
  282. int i;
  283. size_t l;
  284. char *result;
  285. const char *in = "123456123456";
  286. gchar *out = g_base64_encode((const guchar *)in,16);
  287. for (i=0; i<100; i++) {
  288. result = dm_base64_decode(out, &l);
  289. fail_unless(strncmp(in, result, l)==0);
  290. g_free(result);
  291. }
  292. g_free(out);
  293. }
  294. END_TEST
  295. START_TEST(test_base64_decodev)
  296. {
  297. int i;
  298. char **result;
  299. const char *in = "proxy\0user\0pass";
  300. gchar *out = g_base64_encode((const guchar *)in,16);
  301. result = base64_decodev(out);
  302. for (i=0; result[i] != NULL; i++)
  303. ;
  304. fail_unless(i==4,"base64_decodev failed");
  305. fail_unless(MATCH(result[0],"proxy"), "base64_decodev failed");
  306. fail_unless(MATCH(result[1],"user"), "base64_decodev failed");
  307. fail_unless(MATCH(result[2],"pass"), "base64_decodev failed");
  308. }
  309. END_TEST
  310. #define S1(a,b) fail_unless(MATCH(dm_sha1((a)),(b)), "sha1 failed [%s] != [%s]", dm_sha1(a), b)
  311. START_TEST(test_sha1)
  312. {
  313. // test vectors from https://www.cosic.esat.kuleuven.be/nessie/testvectors/hash/sha/index.html
  314. S1("", "da39a3ee5e6b4b0d3255bfef95601890afd80709");
  315. S1("a", "86f7e437faa5a7fce15d1ddcb9eaeaea377667b8");
  316. S1("abc", "a9993e364706816aba3e25717850c26c9cd0d89d");
  317. }
  318. END_TEST
  319. #define S2(a,b) fail_unless(MATCH(dm_sha256((a)),(b)), "sha256 failed [%s] != [%s]", dm_sha256(a), b)
  320. START_TEST(test_sha256)
  321. {
  322. // test vectors from https://www.cosic.esat.kuleuven.be/nessie/testvectors/hash/sha/index.html
  323. S2("", "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855");
  324. S2("a", "ca978112ca1bbdcafac231b39a23dc4da786eff8147c4e72b9807785afee48bb");
  325. S2("abc", "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad");
  326. }
  327. END_TEST
  328. #define S3(a,b) fail_unless(MATCH(dm_sha512((a)),(b)), "sha512 failed [%s] != [%s]", dm_sha512(a), b)
  329. START_TEST(test_sha512)
  330. {
  331. // test vectors from https://www.cosic.esat.kuleuven.be/nessie/testvectors/hash/sha/index.html
  332. S3("", "cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e");
  333. S3("a", "1f40fc92da241694750979ee6cf582f2d5d7d28e18335de05abc54d0560e0f5302860c652bf08d560252aa5e74210546f369fbbbce8c12cfc7957b2652fe9a75");
  334. S3("abc", "ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f");
  335. }
  336. END_TEST
  337. #define M(a,b) fail_unless(MATCH(dm_md5((a)),(b)), "md5 failed [%s] != [%s]", dm_md5(a), b)
  338. START_TEST(test_md5)
  339. {
  340. M("","d41d8cd98f00b204e9800998ecf8427e");
  341. M("a","0cc175b9c0f1b6a831c399e269772661");
  342. M("abc", "900150983cd24fb0d6963f7d28e17f72");
  343. }
  344. END_TEST
  345. #define T(a,b) fail_unless(MATCH(dm_tiger((a)),(b)), "tiger failed [%s] != [%s]", dm_tiger(a), b)
  346. START_TEST(test_tiger)
  347. {
  348. T("","3293ac630c13f0245f92bbb1766e16167a4e58492dde73f3");
  349. T("a","77befbef2e7ef8ab2ec8f93bf587a7fc613e247f5f247809");
  350. T("abc","2aab1484e8c158f2bfb8c5ff41b57a525129131c957b5f93");
  351. }
  352. END_TEST
  353. #define W(a,b) fail_unless(MATCH(dm_whirlpool((a)),(b)), "whirlpool failed\n[%s] !=\n[%s]", dm_whirlpool(a), b)
  354. START_TEST(test_whirlpool)
  355. {
  356. // the whirlpool test vectors are taken from the reference implementation (iso-test-vectors.txt)
  357. W("","19fa61d75522a4669b44e39c1d2e1726c530232130d407f89afee0964997f7a73e83be698b288febcf88e3e03c4f0757ea8964e59b63d93708b138cc42a66eb3");
  358. W("a","8aca2602792aec6f11a67206531fb7d7f0dff59413145e6973c45001d0087b42d11bc645413aeff63a42391a39145a591a92200d560195e53b478584fdae231a");
  359. W("abc","4e2448a4c6f486bb16b6562c73b4020bf3043e3a731bce721ae1b303d97e6d4c7181eebdb6c57e277d0e34957114cbd6c797fc9d95d8b582d225292076d4eef5");
  360. }
  361. END_TEST
  362. START_TEST(test_get_crlf_encoded_opt1)
  363. {
  364. char *in[] = {
  365. "a\n",
  366. "a\nb\nc\n",
  367. "a\nb\r\nc\n",
  368. "a\nb\rc\n",
  369. "a\nb\r\r\nc\n",
  370. NULL
  371. };
  372. char *out[] = {
  373. "a\r\n",
  374. "a\r\nb\r\nc\r\n",
  375. "a\r\nb\r\nc\r\n",
  376. "a\r\nb\rc\r\n",
  377. "a\r\nb\r\r\nc\r\n",
  378. NULL
  379. };
  380. int i=0;
  381. while (in[i]) {
  382. char *r = get_crlf_encoded_opt(in[i],0);
  383. fail_unless(MATCH(r,out[i]), "get_crlf_encoded failed [%s]!=[%s]", r, out[i]);
  384. g_free(r);
  385. i++;
  386. }
  387. }
  388. END_TEST
  389. START_TEST(test_get_crlf_encoded_opt2)
  390. {
  391. char *in[] = {
  392. "a\nb\nc.\n",
  393. "a\n.b\r\nc.\n",
  394. "a\nb\r.c.\n",
  395. "a\nb\r\r\n.\nc\n",
  396. NULL
  397. };
  398. char *out[] = {
  399. "a\r\nb\r\nc.\r\n",
  400. "a\r\n..b\r\nc.\r\n",
  401. "a\r\nb\r.c.\r\n",
  402. "a\r\nb\r\r\n..\r\nc\r\n",
  403. NULL
  404. };
  405. int i=0;
  406. while (in[i]) {
  407. char *r = get_crlf_encoded_opt(in[i],1);
  408. fail_unless(MATCH(r,out[i]), "get_crlf_encoded failed [%s]!=[%s]", r, out[i]);
  409. g_free(r);
  410. i++;
  411. }
  412. }
  413. END_TEST
  414. START_TEST(test_imap_unescape)
  415. {
  416. char *r;
  417. char *in[] = {
  418. "",
  419. "test",
  420. "test'",
  421. "test '",
  422. "test \\",
  423. "test \\\"",
  424. "test \\\\",
  425. "test \\s \\\"",
  426. NULL
  427. };
  428. char *out[] = {
  429. "",
  430. "test",
  431. "test'",
  432. "test '",
  433. "test \\",
  434. "test \"",
  435. "test \\",
  436. "test \\s \"",
  437. NULL
  438. };
  439. int i=0;
  440. while (in[i]) {
  441. r = imap_unescape(g_strdup(in[i]));
  442. fail_unless(MATCH(out[i], r), "[%s] != [%s]", r, out[i]);
  443. g_free(r);
  444. i++;
  445. }
  446. }
  447. END_TEST
  448. START_TEST(test_date_imap2sql)
  449. {
  450. char *r;
  451. int i = 0;
  452. char *in[] = {
  453. "01-Jan-2001",
  454. "1-Jan-2001",
  455. "blah",
  456. NULL
  457. };
  458. char *out[] = {
  459. "2001-01-01 00:00:00",
  460. "2001-01-01 00:00:00",
  461. "",
  462. NULL
  463. };
  464. while (in[i]) {
  465. r = date_imap2sql(in[i]);
  466. fail_unless(MATCH(out[i], r), "[%s] != [%s]", r, out[i]);
  467. g_free(r);
  468. i++;
  469. }
  470. }
  471. END_TEST
  472. START_TEST(test_date_sql2imap)
  473. {
  474. char *r;
  475. int i = 0;
  476. char *in[] = {
  477. "2001-02-03 04:05:06",
  478. "blah",
  479. NULL
  480. };
  481. char *out[] = {
  482. "03-Feb-2001 04:05:06 +0000",
  483. "03-Nov-1979 00:00:00 +0000",
  484. NULL
  485. };
  486. while (in[i]) {
  487. r = date_sql2imap(in[i]);
  488. fail_unless(MATCH(out[i], r), "[%s] != [%s]", r, out[i]);
  489. g_free(r);
  490. i++;
  491. }
  492. }
  493. END_TEST
  494. Suite *dbmail_misc_suite(void)
  495. {
  496. Suite *s = suite_create("Dbmail Misc");
  497. TCase *tc_misc = tcase_create("Misc");
  498. suite_add_tcase(s, tc_misc);
  499. tcase_add_checked_fixture(tc_misc, setup, teardown);
  500. tcase_add_test(tc_misc, test_g_strcasestr);
  501. tcase_add_test(tc_misc, test_g_strchomp_c);
  502. tcase_add_test(tc_misc, test_mailbox_remove_namespace);
  503. tcase_add_test(tc_misc, test_dbmail_iconv_str_to_db);
  504. tcase_add_test(tc_misc, test_dbmail_iconv_decode_address);
  505. tcase_add_test(tc_misc, test_create_unique_id);
  506. tcase_add_test(tc_misc, test_g_list_merge);
  507. tcase_add_test(tc_misc, test_dm_strtoull);
  508. tcase_add_test(tc_misc, test_base64_decode);
  509. tcase_add_test(tc_misc, test_base64_decodev);
  510. tcase_add_test(tc_misc, test_sha1);
  511. tcase_add_test(tc_misc, test_sha256);
  512. tcase_add_test(tc_misc, test_sha512);
  513. tcase_add_test(tc_misc, test_whirlpool);
  514. tcase_add_test(tc_misc, test_md5);
  515. tcase_add_test(tc_misc, test_tiger);
  516. tcase_add_test(tc_misc, test_get_crlf_encoded_opt1);
  517. tcase_add_test(tc_misc, test_get_crlf_encoded_opt2);
  518. tcase_add_test(tc_misc, test_imap_unescape);
  519. tcase_add_test(tc_misc, test_date_imap2sql);
  520. tcase_add_test(tc_misc, test_date_sql2imap);
  521. return s;
  522. }
  523. int main(void)
  524. {
  525. int nf;
  526. Suite *s = dbmail_misc_suite();
  527. SRunner *sr = srunner_create(s);
  528. srunner_run_all(sr, CK_NORMAL);
  529. nf = srunner_ntests_failed(sr);
  530. srunner_free(sr);
  531. return (nf == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
  532. }