Update contrib.
1 /* Portion Copyright © 2008-09 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.*/
2 #undef G_DISABLE_ASSERT
9 #include "mrt2_glib2_test.h"
22 start_element_handler (GMarkupParseContext *context,
23 const gchar *element_name,
24 const gchar **attribute_names,
25 const gchar **attribute_values,
33 end_element_handler (GMarkupParseContext *context,
34 const gchar *element_name,
43 text_handler (GMarkupParseContext *context,
54 passthrough_handler (GMarkupParseContext *context,
55 const gchar *passthrough_text,
64 error_handler (GMarkupParseContext *context,
68 g_print(" %s\n", error->message);
69 g_assert(FALSE && "markup-test failed");
72 static GMarkupParser parser = {
73 start_element_handler,
81 test_in_chunks (const gchar *contents,
85 GMarkupParseContext *context;
88 context = g_markup_parse_context_new (&parser, 0, NULL, NULL);
91 g_print("markup-test.c : g_markup_parse_context_new failed @ line : %d",__LINE__);
92 g_assert(FALSE && "markup-test failed");
98 int this_chunk = MIN (length - i, chunk_size);
100 if (!g_markup_parse_context_parse (context,
105 g_print("markup-test.c : g_markup_parse_context_parse failed ");
106 g_markup_parse_context_free (context);
107 g_assert(FALSE && "markup-test failed");
114 if (!g_markup_parse_context_end_parse (context, NULL))
116 g_print("markup-test.c : g_markup_parse_context_end_parse failed ");
117 g_assert(FALSE && "markup-test failed");
118 g_markup_parse_context_free (context);
122 g_markup_parse_context_free (context);
128 test_file (const gchar *filename)
133 GMarkupParseContext *context;
136 if (!g_file_get_contents (filename,
141 g_assert(FALSE && "c:\\1.gmarkup not found");
142 g_print("%s\n", error->message);
143 g_error_free (error);
147 context = g_markup_parse_context_new (&parser, 0, NULL, NULL);
150 g_print("markup-test.c : g_markup_parse_context_new failed @ line : %d",__LINE__);
151 g_assert(FALSE && "markup-test failed");
155 if (!g_markup_parse_context_parse (context, contents, length, NULL))
157 g_print("markup-test.c : g_markup_parse_context_parse failed ");
158 g_assert(FALSE && "markup-test failed");
159 g_markup_parse_context_free (context);
163 if (!g_markup_parse_context_end_parse (context, NULL))
165 g_print("markup-test.c : g_markup_parse_context_end_parse failed ");
166 g_assert(FALSE && "markup-test failed");
167 g_markup_parse_context_free (context);
171 g_markup_parse_context_free (context);
173 /* A byte at a time */
174 if (test_in_chunks (contents, length, 1) != 0)
178 if (test_in_chunks (contents, length, 2) != 0)
182 if (test_in_chunks (contents, length, 5) != 0)
186 if (test_in_chunks (contents, length, 12) != 0)
190 if (test_in_chunks (contents, length, 1024) != 0)
203 g_log_set_handler (NULL, G_LOG_FLAG_FATAL| G_LOG_FLAG_RECURSION | G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING | G_LOG_LEVEL_MESSAGE | G_LOG_LEVEL_INFO | G_LOG_LEVEL_DEBUG, &mrtLogHandler, NULL);
204 g_set_print_handler(mrtPrintHandler);
208 retval = test_file ("c:\\1.gmarkup");
211 testResultXml("markup-test");
212 #endif /* EMULATOR */