~dbarth/notify-osd/close-notification-api

« back to all changes in this revision

Viewing changes to tests/test-text-filtering.c

  • Committer: Mirco Müller
  • Date: 2010-02-05 17:33:33 UTC
  • mfrom: (397.1.12 notify-osd_karmic)
  • Revision ID: mirco.mueller@ubuntu.com-20100205173333-bqw2gwmhzvyr8dj8
Merge changes and fixes from the karmic branch back into trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
        const gchar *expected;
35
35
} TextComparisons;
36
36
 
 
37
typedef struct {
 
38
        const gchar* before;
 
39
        guint        expected;
 
40
} IntegerExtraction;
 
41
 
37
42
static void
38
43
test_text_filter ()
39
44
{
69
74
                { "<tt>Testing tag</tt>",                          "Testing tag"                             },
70
75
                { "<html>Surrounded by html</html>",               "Surrounded by html"                      },
71
76
                { "<qt>Surrounded by qt</qt>",                     "Surrounded by qt"                        },
72
 
                { "First line  <br dumb> \r \n Second line",       "First line Second line"                  },
73
 
                { "First line\n<br /> <br>\n2nd line\r\n3rd line", "First line 2nd line 3rd line"            },
 
77
                { "First line  <br dumb> \r \n Second line",       "First line\nSecond line"                  },
 
78
                { "First line\n<br /> <br>\n2nd line\r\n3rd line", "First line\n2nd line\n3rd line"            },
74
79
                { NULL, NULL }
75
80
        };
76
81
 
97
102
        }
98
103
}
99
104
 
 
105
static void
 
106
test_extract_point_size ()
 
107
{
 
108
        static const IntegerExtraction tests[] = {
 
109
                { "", 0 },
 
110
                { "foobar", 0 },
 
111
                { "Bla Fasel -12.0", 0 },
 
112
                { "Sans 10", 10 },
 
113
                { "Candara 9", 9 },
 
114
                { "Bitstream Vera Serif Italic 1", 1 },
 
115
                { "Calibri Italic 100", 100 },
 
116
                { "Century Schoolbook L Italic 42", 42 },
 
117
                { NULL, 0 }
 
118
        };
 
119
 
 
120
        for (int i = 0; tests[i].before != NULL; i++)
 
121
        {
 
122
                guint extracted = extract_point_size (tests[i].before);
 
123
                g_assert_cmpuint (extracted, ==, tests[i].expected);
 
124
        }
 
125
}
 
126
 
 
127
static void
 
128
test_extract_font_face ()
 
129
{
 
130
        static const TextComparisons tests[] = {
 
131
                { "", "" },
 
132
                { "Sans 10", "Sans " },
 
133
                { "Candara 9", "Candara " },
 
134
                { "Bitstream Vera Serif Italic 1", "Bitstream Vera Serif Italic " },
 
135
                { "Calibri Italic 100", "Calibri Italic " },
 
136
                { "Century Schoolbook L Italic 10", "Century Schoolbook L Italic " },
 
137
                { NULL, NULL }
 
138
        };
 
139
 
 
140
        for (int i = 0; tests[i].before != NULL; i++)
 
141
        {
 
142
                GString* filtered = extract_font_face (tests[i].before);
 
143
                g_assert_cmpstr (filtered->str, ==, tests[i].expected);
 
144
                g_string_free (filtered, TRUE);
 
145
        }
 
146
}
 
147
 
100
148
GTestSuite *
101
149
test_filtering_create_test_suite (void)
102
150
{
108
156
 
109
157
        g_test_suite_add(ts, TC(test_text_filter));
110
158
        g_test_suite_add(ts, TC(test_newline_to_space));
 
159
        g_test_suite_add(ts, TC(test_extract_point_size));
 
160
        g_test_suite_add(ts, TC(test_extract_font_face));
111
161
 
112
162
        return ts;
113
163
}