annotate libpurple/tests/test_yahoo_util.c @ 29795:c138390bada8

It broke a bit during merge. And the _reserved in the ui ops struct ran out...
author Marcus Lundblad <ml@update.uu.se>
date Thu, 13 Aug 2009 17:40:00 +0000
parents 1e02e65ce301
children c69c79921f93
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27749
1b5b24dc0310 Whoops, I forgot to add the test!
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1 #include <string.h>
1b5b24dc0310 Whoops, I forgot to add the test!
Mark Doliner <mark@kingant.net>
parents:
diff changeset
2
1b5b24dc0310 Whoops, I forgot to add the test!
Mark Doliner <mark@kingant.net>
parents:
diff changeset
3 #include "tests.h"
1b5b24dc0310 Whoops, I forgot to add the test!
Mark Doliner <mark@kingant.net>
parents:
diff changeset
4 #include "../protocols/yahoo/libymsg.h"
1b5b24dc0310 Whoops, I forgot to add the test!
Mark Doliner <mark@kingant.net>
parents:
diff changeset
5
1b5b24dc0310 Whoops, I forgot to add the test!
Mark Doliner <mark@kingant.net>
parents:
diff changeset
6 static void setup_codes_to_html(void)
1b5b24dc0310 Whoops, I forgot to add the test!
Mark Doliner <mark@kingant.net>
parents:
diff changeset
7 {
1b5b24dc0310 Whoops, I forgot to add the test!
Mark Doliner <mark@kingant.net>
parents:
diff changeset
8 yahoo_init_colorht();
1b5b24dc0310 Whoops, I forgot to add the test!
Mark Doliner <mark@kingant.net>
parents:
diff changeset
9 }
1b5b24dc0310 Whoops, I forgot to add the test!
Mark Doliner <mark@kingant.net>
parents:
diff changeset
10
1b5b24dc0310 Whoops, I forgot to add the test!
Mark Doliner <mark@kingant.net>
parents:
diff changeset
11 static void teardown_codes_to_html(void)
1b5b24dc0310 Whoops, I forgot to add the test!
Mark Doliner <mark@kingant.net>
parents:
diff changeset
12 {
1b5b24dc0310 Whoops, I forgot to add the test!
Mark Doliner <mark@kingant.net>
parents:
diff changeset
13 yahoo_dest_colorht();
1b5b24dc0310 Whoops, I forgot to add the test!
Mark Doliner <mark@kingant.net>
parents:
diff changeset
14 }
1b5b24dc0310 Whoops, I forgot to add the test!
Mark Doliner <mark@kingant.net>
parents:
diff changeset
15
1b5b24dc0310 Whoops, I forgot to add the test!
Mark Doliner <mark@kingant.net>
parents:
diff changeset
16 START_TEST(test_codes_to_html)
1b5b24dc0310 Whoops, I forgot to add the test!
Mark Doliner <mark@kingant.net>
parents:
diff changeset
17 {
27779
07de864fc024 Change yahoo_codes_to_html() to use the same USE_CSS_FORMATTING #define
Mark Doliner <mark@kingant.net>
parents: 27773
diff changeset
18 assert_string_equal_free("plain",
07de864fc024 Change yahoo_codes_to_html() to use the same USE_CSS_FORMATTING #define
Mark Doliner <mark@kingant.net>
parents: 27773
diff changeset
19 yahoo_codes_to_html("plain"));
27815
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27779
diff changeset
20 assert_string_equal_free("unknown ansi code",
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27779
diff changeset
21 yahoo_codes_to_html("unknown \x1B[12345m ansi code"));
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27779
diff changeset
22 assert_string_equal_free("plain &lt;peanut&gt;",
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27779
diff changeset
23 yahoo_codes_to_html("plain <peanut>"));
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27779
diff changeset
24 assert_string_equal_free("plain &lt;peanut",
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27779
diff changeset
25 yahoo_codes_to_html("plain <peanut"));
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27779
diff changeset
26 assert_string_equal_free("plain&gt; peanut",
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27779
diff changeset
27 yahoo_codes_to_html("plain> peanut"));
27769
301c966fa7af Add testing for font size
Mark Doliner <mark@kingant.net>
parents: 27750
diff changeset
28
301c966fa7af Add testing for font size
Mark Doliner <mark@kingant.net>
parents: 27750
diff changeset
29 /* bold/italic/underline */
27815
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27779
diff changeset
30 assert_string_equal_free("<b>bold</b>",
27773
59d45eb5f9c9 Add a test with a custom color
Mark Doliner <mark@kingant.net>
parents: 27769
diff changeset
31 yahoo_codes_to_html("\x1B[1mbold"));
27815
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27779
diff changeset
32 assert_string_equal_free("<i>italic</i>",
27773
59d45eb5f9c9 Add a test with a custom color
Mark Doliner <mark@kingant.net>
parents: 27769
diff changeset
33 yahoo_codes_to_html("\x1B[2mitalic"));
27815
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27779
diff changeset
34 assert_string_equal_free("<u>underline</u>",
27773
59d45eb5f9c9 Add a test with a custom color
Mark Doliner <mark@kingant.net>
parents: 27769
diff changeset
35 yahoo_codes_to_html("\x1B[4munderline"));
27815
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27779
diff changeset
36 assert_string_equal_free("no markup",
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27779
diff changeset
37 yahoo_codes_to_html("no\x1B[x4m markup"));
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27779
diff changeset
38 assert_string_equal_free("<b>bold</b> <i>italic</i> <u>underline</u>",
27773
59d45eb5f9c9 Add a test with a custom color
Mark Doliner <mark@kingant.net>
parents: 27769
diff changeset
39 yahoo_codes_to_html("\x1B[1mbold\x1B[x1m \x1B[2mitalic\x1B[x2m \x1B[4munderline"));
27815
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27779
diff changeset
40 assert_string_equal_free("<b>bold <i>bolditalic</i></b><i> italic</i>",
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27779
diff changeset
41 yahoo_codes_to_html("\x1B[1mbold \x1B[2mbolditalic\x1B[x1m italic"));
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27779
diff changeset
42 assert_string_equal_free("<b>bold <i>bolditalic</i></b><i> <u>italicunderline</u></i>",
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27779
diff changeset
43 yahoo_codes_to_html("\x1B[1mbold \x1B[2mbolditalic\x1B[x1m \x1B[4mitalicunderline"));
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27779
diff changeset
44 assert_string_equal_free("<b>bold <i>bolditalic <u>bolditalicunderline</u></i><u> boldunderline</u></b>",
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27779
diff changeset
45 yahoo_codes_to_html("\x1B[1mbold \x1B[2mbolditalic \x1B[4mbolditalicunderline\x1B[x2m boldunderline"));
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27779
diff changeset
46 assert_string_equal_free("<b>bold <i>bolditalic <u>bolditalicunderline</u></i></b><i><u> italicunderline</u></i>",
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27779
diff changeset
47 yahoo_codes_to_html("\x1B[1mbold \x1B[2mbolditalic \x1B[4mbolditalicunderline\x1B[x1m italicunderline"));
27769
301c966fa7af Add testing for font size
Mark Doliner <mark@kingant.net>
parents: 27750
diff changeset
48
27779
07de864fc024 Change yahoo_codes_to_html() to use the same USE_CSS_FORMATTING #define
Mark Doliner <mark@kingant.net>
parents: 27773
diff changeset
49 #ifdef USE_CSS_FORMATTING
07de864fc024 Change yahoo_codes_to_html() to use the same USE_CSS_FORMATTING #define
Mark Doliner <mark@kingant.net>
parents: 27773
diff changeset
50 /* font color */
27815
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27779
diff changeset
51 assert_string_equal_free("<span style='color: #0000FF'>blue</span>",
27773
59d45eb5f9c9 Add a test with a custom color
Mark Doliner <mark@kingant.net>
parents: 27769
diff changeset
52 yahoo_codes_to_html("\x1B[31mblue"));
27815
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27779
diff changeset
53 assert_string_equal_free("<span style='color: #70ea15'>custom color</span>",
27779
07de864fc024 Change yahoo_codes_to_html() to use the same USE_CSS_FORMATTING #define
Mark Doliner <mark@kingant.net>
parents: 27773
diff changeset
54 yahoo_codes_to_html("\x1B[#70ea15mcustom color"));
07de864fc024 Change yahoo_codes_to_html() to use the same USE_CSS_FORMATTING #define
Mark Doliner <mark@kingant.net>
parents: 27773
diff changeset
55
27815
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27779
diff changeset
56 /* font face */
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27779
diff changeset
57 assert_string_equal_free("<font face='Georgia'>test</font>",
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27779
diff changeset
58 yahoo_codes_to_html("<font face='Georgia'>test</font>"));
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27779
diff changeset
59
27779
07de864fc024 Change yahoo_codes_to_html() to use the same USE_CSS_FORMATTING #define
Mark Doliner <mark@kingant.net>
parents: 27773
diff changeset
60 /* font size */
27815
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27779
diff changeset
61 assert_string_equal_free("<font><span style='font-size: 15pt'>test</span></font>",
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27779
diff changeset
62 yahoo_codes_to_html("<font size='15'>test"));
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27779
diff changeset
63 assert_string_equal_free("<font><span style='font-size: 32pt'>size 32</span></font>",
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27779
diff changeset
64 yahoo_codes_to_html("<font size='32'>size 32"));
27779
07de864fc024 Change yahoo_codes_to_html() to use the same USE_CSS_FORMATTING #define
Mark Doliner <mark@kingant.net>
parents: 27773
diff changeset
65
07de864fc024 Change yahoo_codes_to_html() to use the same USE_CSS_FORMATTING #define
Mark Doliner <mark@kingant.net>
parents: 27773
diff changeset
66 /* combinations */
27815
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27779
diff changeset
67 assert_string_equal_free("<font face='Georgia'><span style='font-size: 32pt'>test</span></font>",
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27779
diff changeset
68 yahoo_codes_to_html("<font face='Georgia' size='32'>test"));
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27779
diff changeset
69 assert_string_equal_free("<span style='color: #FF0080'><font><span style='font-size: 15pt'>test</span></font></span>",
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27779
diff changeset
70 yahoo_codes_to_html("\x1B[35m<font size='15'>test"));
27779
07de864fc024 Change yahoo_codes_to_html() to use the same USE_CSS_FORMATTING #define
Mark Doliner <mark@kingant.net>
parents: 27773
diff changeset
71 #else
07de864fc024 Change yahoo_codes_to_html() to use the same USE_CSS_FORMATTING #define
Mark Doliner <mark@kingant.net>
parents: 27773
diff changeset
72 /* font color */
27815
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27779
diff changeset
73 assert_string_equal_free("<font color='#0000FF'>blue</font>",
27779
07de864fc024 Change yahoo_codes_to_html() to use the same USE_CSS_FORMATTING #define
Mark Doliner <mark@kingant.net>
parents: 27773
diff changeset
74 yahoo_codes_to_html("\x1B[31mblue"));
27815
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27779
diff changeset
75 assert_string_equal_free("<font color='#70ea15'>custom color</font>",
27779
07de864fc024 Change yahoo_codes_to_html() to use the same USE_CSS_FORMATTING #define
Mark Doliner <mark@kingant.net>
parents: 27773
diff changeset
76 yahoo_codes_to_html("\x1B[#70ea15mcustom color"));
27815
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27779
diff changeset
77 assert_string_equal_free("test",
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27779
diff changeset
78 yahoo_codes_to_html("<ALT #ff0000,#00ff00,#0000ff>test</ALT>"));
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27779
diff changeset
79
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27779
diff changeset
80 /* font face */
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27779
diff changeset
81 assert_string_equal_free("<font face='Georgia'>test</font>",
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27779
diff changeset
82 yahoo_codes_to_html("<font face='Georgia'>test"));
27779
07de864fc024 Change yahoo_codes_to_html() to use the same USE_CSS_FORMATTING #define
Mark Doliner <mark@kingant.net>
parents: 27773
diff changeset
83
07de864fc024 Change yahoo_codes_to_html() to use the same USE_CSS_FORMATTING #define
Mark Doliner <mark@kingant.net>
parents: 27773
diff changeset
84 /* font size */
27815
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27779
diff changeset
85 assert_string_equal_free("<font size='4' absz='15'>test</font>",
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27779
diff changeset
86 yahoo_codes_to_html("<font size='15'>test"));
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27779
diff changeset
87 assert_string_equal_free("<font size='6' absz='32'>size 32</font>",
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27779
diff changeset
88 yahoo_codes_to_html("<font size='32'>size 32"));
27779
07de864fc024 Change yahoo_codes_to_html() to use the same USE_CSS_FORMATTING #define
Mark Doliner <mark@kingant.net>
parents: 27773
diff changeset
89
07de864fc024 Change yahoo_codes_to_html() to use the same USE_CSS_FORMATTING #define
Mark Doliner <mark@kingant.net>
parents: 27773
diff changeset
90 /* combinations */
27815
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27779
diff changeset
91 assert_string_equal_free("<font face='Georgia' size='6' absz='32'>test</font>",
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27779
diff changeset
92 yahoo_codes_to_html("<font face='Georgia' size='32'>test"));
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27779
diff changeset
93 assert_string_equal_free("<font color='#FF0080'><font size='4' absz='15'>test</font></font>",
1e02e65ce301 Changes to the way we translate raw yahoo messages to HTML. The HTML
Mark Doliner <mark@kingant.net>
parents: 27779
diff changeset
94 yahoo_codes_to_html("\x1B[35m<font size='15'>test"));
27779
07de864fc024 Change yahoo_codes_to_html() to use the same USE_CSS_FORMATTING #define
Mark Doliner <mark@kingant.net>
parents: 27773
diff changeset
95 #endif /* !USE_CSS_FORMATTING */
27749
1b5b24dc0310 Whoops, I forgot to add the test!
Mark Doliner <mark@kingant.net>
parents:
diff changeset
96 }
1b5b24dc0310 Whoops, I forgot to add the test!
Mark Doliner <mark@kingant.net>
parents:
diff changeset
97 END_TEST
1b5b24dc0310 Whoops, I forgot to add the test!
Mark Doliner <mark@kingant.net>
parents:
diff changeset
98
1b5b24dc0310 Whoops, I forgot to add the test!
Mark Doliner <mark@kingant.net>
parents:
diff changeset
99 Suite *
1b5b24dc0310 Whoops, I forgot to add the test!
Mark Doliner <mark@kingant.net>
parents:
diff changeset
100 yahoo_util_suite(void)
1b5b24dc0310 Whoops, I forgot to add the test!
Mark Doliner <mark@kingant.net>
parents:
diff changeset
101 {
1b5b24dc0310 Whoops, I forgot to add the test!
Mark Doliner <mark@kingant.net>
parents:
diff changeset
102 Suite *s = suite_create("Yahoo Utility Functions");
1b5b24dc0310 Whoops, I forgot to add the test!
Mark Doliner <mark@kingant.net>
parents:
diff changeset
103
1b5b24dc0310 Whoops, I forgot to add the test!
Mark Doliner <mark@kingant.net>
parents:
diff changeset
104 TCase *tc = tcase_create("Convert to Numeric");
1b5b24dc0310 Whoops, I forgot to add the test!
Mark Doliner <mark@kingant.net>
parents:
diff changeset
105 tcase_add_unchecked_fixture(tc, setup_codes_to_html, teardown_codes_to_html);
1b5b24dc0310 Whoops, I forgot to add the test!
Mark Doliner <mark@kingant.net>
parents:
diff changeset
106 tcase_add_test(tc, test_codes_to_html);
1b5b24dc0310 Whoops, I forgot to add the test!
Mark Doliner <mark@kingant.net>
parents:
diff changeset
107 suite_add_tcase(s, tc);
1b5b24dc0310 Whoops, I forgot to add the test!
Mark Doliner <mark@kingant.net>
parents:
diff changeset
108
1b5b24dc0310 Whoops, I forgot to add the test!
Mark Doliner <mark@kingant.net>
parents:
diff changeset
109 return s;
1b5b24dc0310 Whoops, I forgot to add the test!
Mark Doliner <mark@kingant.net>
parents:
diff changeset
110 }