You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
58 lines
1.9 KiB
58 lines
1.9 KiB
#include "greatest.h"
|
|
|
|
#include <stdbool.h>
|
|
#include <glib.h>
|
|
|
|
#include "src/markup.h"
|
|
|
|
TEST test_markup_strip(void)
|
|
{
|
|
char *ptr;
|
|
|
|
ASSERT_STR_EQ(""", (ptr=markup_strip(g_strdup("&quot;"))));
|
|
g_free(ptr);
|
|
ASSERT_STR_EQ("'", (ptr=markup_strip(g_strdup("&apos;"))));
|
|
g_free(ptr);
|
|
ASSERT_STR_EQ("<", (ptr=markup_strip(g_strdup("&lt;"))));
|
|
g_free(ptr);
|
|
ASSERT_STR_EQ(">", (ptr=markup_strip(g_strdup("&gt;"))));
|
|
g_free(ptr);
|
|
ASSERT_STR_EQ("&", (ptr=markup_strip(g_strdup("&amp;"))));
|
|
g_free(ptr);
|
|
ASSERT_STR_EQ(">A ", (ptr=markup_strip(g_strdup(">A <img> <string"))));
|
|
g_free(ptr);
|
|
|
|
PASS();
|
|
}
|
|
|
|
TEST test_markup_transform(void)
|
|
{
|
|
char *ptr;
|
|
|
|
settings.ignore_newline = false;
|
|
ASSERT_STR_EQ("<i>foo</i><br>bar\nbaz", (ptr=markup_transform(g_strdup("<i>foo</i><br>bar\nbaz"), MARKUP_NO)));
|
|
g_free(ptr);
|
|
ASSERT_STR_EQ("foo\nbar\nbaz", (ptr=markup_transform(g_strdup("<i>foo</i><br>bar\nbaz"), MARKUP_STRIP)));
|
|
g_free(ptr);
|
|
ASSERT_STR_EQ("<i>foo</i>\nbar\nbaz", (ptr=markup_transform(g_strdup("<i>foo</i><br>bar\nbaz"), MARKUP_FULL)));
|
|
g_free(ptr);
|
|
|
|
settings.ignore_newline = true;
|
|
ASSERT_STR_EQ("<i>foo</i><br>bar baz", (ptr=markup_transform(g_strdup("<i>foo</i><br>bar\nbaz"), MARKUP_NO)));
|
|
g_free(ptr);
|
|
ASSERT_STR_EQ("foo bar baz", (ptr=markup_transform(g_strdup("<i>foo</i><br>bar\nbaz"), MARKUP_STRIP)));
|
|
g_free(ptr);
|
|
ASSERT_STR_EQ("<i>foo</i> bar baz", (ptr=markup_transform(g_strdup("<i>foo</i><br>bar\nbaz"), MARKUP_FULL)));
|
|
g_free(ptr);
|
|
|
|
PASS();
|
|
}
|
|
|
|
SUITE(suite_markup)
|
|
{
|
|
RUN_TEST(test_markup_strip);
|
|
RUN_TEST(test_markup_transform);
|
|
}
|
|
|
|
/* vim: set tabstop=8 shiftwidth=8 expandtab textwidth=0: */
|