1
#include <glib.h>
2
#include <libipuz/libipuz.h>
3
#include <locale.h>
4

            
5

            
6
static void
7
4
test_html_to_markup (const gchar *src,
8
                     const gchar *target)
9
{
10
4
  g_autofree gchar *dest = NULL;
11

            
12
4
  dest = ipuz_html_to_markup (src);
13
4
  g_print ("Testing (%s): ", src);
14
4
  if (g_strcmp0 (target, dest) == 0)
15
4
    g_print ("Result: \"%s\"\n", target);
16
  else
17
    g_print ("Failed. Expected \"%s\" and got \"%s\"\n", target, dest);
18
4
  g_assert (g_strcmp0 (target, dest) == 0);
19
4
}
20

            
21
static void
22
1
test_convert (void)
23
{
24
1
  setlocale(LC_ALL, "en_US.utf8");
25

            
26
1
  test_html_to_markup ("cats", "cats");
27
1
  test_html_to_markup ("cats & dogs", "cats &amp; dogs");
28
1
  test_html_to_markup ("cats &amp; dogs", "cats &amp; dogs");
29
1
  test_html_to_markup ("<i>cats</i> &lt; <strong>dogs</strong>", "<i>cats</i> &lt; <b><i>dogs</i></b>");
30
1
}
31

            
32
int
33
1
main (int   argc,
34
      char *argv[])
35
{
36
1
  g_test_init (&argc, &argv, NULL);
37

            
38
1
  g_test_add_func ("/html-to-markup/convert", test_convert);
39

            
40
1
  return g_test_run ();
41
}
42