add support for Ayatana indicator to Notification plugin
[claws.git] / src / common / tests / unmime_test.c
blob05e628780046e3094b1c37e47de17668427fc6e3
1 #include "config.h"
3 #include <stdio.h>
4 #include <glib.h>
6 #include "unmime.h"
7 #include "quoted-printable.h"
9 #include "mock_prefs_common_get_use_shred.h"
10 #include "mock_prefs_common_get_flush_metadata.h"
12 struct td {
13 gchar *input;
14 gchar *expected_output;
17 struct td td_rfc2047_space1 = {
18 "(=?ISO-8859-1?Q?a?=)",
19 "(a)"
21 struct td td_rfc2047_space2 = {
22 "(=?ISO-8859-1?Q?a?= b)",
23 "(a b)"
25 struct td td_rfc2047_space3 = {
26 "(=?ISO-8859-1?Q?a?= =?ISO-8859-1?Q?b?=)",
27 "(ab)"
29 struct td td_rfc2047_space4 = {
30 "(=?ISO-8859-1?Q?a?= =?ISO-8859-1?Q?b?=)",
31 "(ab)"
33 struct td td_rfc2047_space5 = {
34 "(=?ISO-8859-1?Q?a?=\r\n =?ISO-8859-1?Q?b?=)",
35 "(ab)"
37 struct td td_rfc2047_space6 = {
38 "(=?ISO-8859-1?Q?a_b?=)",
39 "(a b)"
41 struct td td_rfc2047_space7 = {
42 "(=?ISO-8859-1?Q?a?= =?ISO-8859-2?Q?_b?=)",
43 "(a b)"
46 static void
47 test_unmime_header_null()
49 if (!g_test_undefined())
50 return;
52 if (g_test_subprocess()) {
53 gchar *out;
55 out = unmime_header(NULL, FALSE);
56 g_assert_null(out);
57 return;
60 g_test_trap_subprocess(NULL, 0, 0);
61 g_test_trap_assert_stdout("*Condition*failed*");
62 g_test_trap_assert_passed();
65 static void
66 test_unmime_header(gconstpointer user_data)
68 struct td *data = (struct td *)user_data;
69 gchar *out = unmime_header(data->input, FALSE);
71 g_assert_nonnull(out);
72 g_assert_cmpstr(out, ==, data->expected_output);
75 int
76 main(int argc, char *argv[])
78 g_test_init(&argc, &argv, NULL);
80 g_test_add_func("/common/unmime/null",
81 test_unmime_header_null);
83 g_test_add_data_func("/common/unmime/rfc2047_space1",
84 &td_rfc2047_space1,
85 test_unmime_header);
86 g_test_add_data_func("/common/unmime/rfc2047_space2",
87 &td_rfc2047_space2,
88 test_unmime_header);
89 g_test_add_data_func("/common/unmime/rfc2047_space3",
90 &td_rfc2047_space3,
91 test_unmime_header);
92 g_test_add_data_func("/common/unmime/rfc2047_space4",
93 &td_rfc2047_space4,
94 test_unmime_header);
95 g_test_add_data_func("/common/unmime/rfc2047_space5",
96 &td_rfc2047_space5,
97 test_unmime_header);
98 g_test_add_data_func("/common/unmime/rfc2047_space6",
99 &td_rfc2047_space6,
100 test_unmime_header);
101 g_test_add_data_func("/common/unmime/rfc2047_space7",
102 &td_rfc2047_space7,
103 test_unmime_header);
105 return g_test_run();