Add tests for markup functions
This commit is contained in:
parent
0c84e53afb
commit
c645ba3106
57
test/markup.c
Normal file
57
test/markup.c
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
#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: */
|
@ -3,6 +3,7 @@
|
|||||||
SUITE_EXTERN(suite_utils);
|
SUITE_EXTERN(suite_utils);
|
||||||
SUITE_EXTERN(suite_option_parser);
|
SUITE_EXTERN(suite_option_parser);
|
||||||
SUITE_EXTERN(suite_notification);
|
SUITE_EXTERN(suite_notification);
|
||||||
|
SUITE_EXTERN(suite_markup);
|
||||||
|
|
||||||
GREATEST_MAIN_DEFS();
|
GREATEST_MAIN_DEFS();
|
||||||
|
|
||||||
@ -11,6 +12,7 @@ int main(int argc, char *argv[]) {
|
|||||||
RUN_SUITE(suite_utils);
|
RUN_SUITE(suite_utils);
|
||||||
RUN_SUITE(suite_option_parser);
|
RUN_SUITE(suite_option_parser);
|
||||||
RUN_SUITE(suite_notification);
|
RUN_SUITE(suite_notification);
|
||||||
|
RUN_SUITE(suite_markup);
|
||||||
GREATEST_MAIN_END();
|
GREATEST_MAIN_END();
|
||||||
}
|
}
|
||||||
/* vim: set tabstop=8 shiftwidth=8 expandtab textwidth=0: */
|
/* vim: set tabstop=8 shiftwidth=8 expandtab textwidth=0: */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user