talkatu/talkatu

meson: Replace join_paths by /.

2020-09-15, Elliott Sales de Andrade
0f10848ece7a
meson: Replace join_paths by /.

It was added in 0.49.0, and we require 0.50.0.

Reviewed at https://reviews.imfreedom.org/r/118/
/*
* talkatu
* Copyright (C) 2017-2020 Gary Kramlich <grim@reaperworld.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
#include <talkatu.h>
/******************************************************************************
* TestTalkatuHtmlParser
*****************************************************************************/
#define TEST_TALKATU_TYPE_HTML_PARSER (test_talkatu_html_parser_get_type())
G_DECLARE_FINAL_TYPE(TestTalkatuHtmlParser, test_talkatu_html_parser,
TEST_TALKATU, HTML_PARSER, TalkatuHtmlParser)
struct _TestTalkatuHtmlParser {
TalkatuHtmlParser parent;
};
static void
test_talkatu_html_parser_element_start(TalkatuHtmlParser *parser,
const gchar *name,
const gchar **attr_names,
const gchar **attr_values,
gpointer data)
{
GString *str = (GString *)data;
g_string_append_printf(str, "<%s", name);
if(attr_names != NULL) {
gint i = 0;
for(i = 0; attr_names[i] != NULL; i++) {
g_string_append_printf(str, " %s=\"", attr_names[i]);
if(attr_values[i] != NULL) {
g_string_append_printf(str, "%s", attr_values[i]);
}
g_string_append_printf(str, "\"");
}
}
g_string_append_printf(str, ">");
}
static void
test_talkatu_html_parser_element_finish(TalkatuHtmlParser *parser,
const gchar *name,
gpointer data)
{
g_string_append_printf((GString *)data, "</%s>", name);
}
static void
test_talkatu_html_parser_text(TalkatuHtmlParser *parser, const gchar *text,
gpointer data)
{
g_string_append_printf((GString *)data, "%s", text);
}
static void
test_talkatu_html_parser_comment(TalkatuHtmlParser *parser,
const gchar *comment, gpointer data)
{
g_string_append_printf((GString *)data, "<!--%s-->", comment);
}
G_DEFINE_TYPE(TestTalkatuHtmlParser, test_talkatu_html_parser, TALKATU_TYPE_HTML_PARSER);
static void
test_talkatu_html_parser_init(TestTalkatuHtmlParser *parser) {
}
static void
test_talkatu_html_parser_class_init(TestTalkatuHtmlParserClass *klass) {
TalkatuHtmlParserClass *parser_class = TALKATU_HTML_PARSER_CLASS(klass);
parser_class->element_start = test_talkatu_html_parser_element_start;
parser_class->element_finish = test_talkatu_html_parser_element_finish;
parser_class->text = test_talkatu_html_parser_text;
parser_class->comment = test_talkatu_html_parser_comment;
}
TalkatuHtmlParser *
test_talkatu_html_parser_new(void) {
return TALKATU_HTML_PARSER(g_object_new(TEST_TALKATU_TYPE_HTML_PARSER,
NULL));
}
/******************************************************************************
* Tests
*****************************************************************************/
static void
test_talkatu_html_parser_simple(void) {
TalkatuHtmlParser *parser = test_talkatu_html_parser_new();
GString *str = g_string_new("");
const gchar *exp = "<html><head></head><body>plain text</body></html>";
talkatu_html_parser_parse(parser, "plain text", str);
g_assert_cmpstr(str->str, ==, exp);
g_string_free(str, TRUE);
g_object_unref(G_OBJECT(parser));
}
static void
test_talkatu_html_parser_mixed(void) {
TalkatuHtmlParser *parser = test_talkatu_html_parser_new();
GString *str = g_string_new("");
const gchar *exp = \
"<html><head></head><body>" \
"<i><b>emphasis <u>underline</u></b> <strike>strike</strike> italic</i>" \
"</body></html>";
talkatu_html_parser_parse(parser, exp, str);
g_assert_cmpstr(str->str, ==, exp);
g_string_free(str, TRUE);
g_object_unref(G_OBJECT(parser));
}
static void
test_talkatu_html_parser_with_comment(void) {
TalkatuHtmlParser *parser = test_talkatu_html_parser_new();
GString *str = g_string_new("");
const gchar *exp = \
"<html><head></head><body>" \
"Hello, <!--Darkness, my old friend, here to conquer the--> World!" \
"</body></html>";
talkatu_html_parser_parse(parser, exp, str);
g_assert_cmpstr(str->str, ==, exp);
g_string_free(str, TRUE);
g_object_unref(G_OBJECT(parser));
}
static void
test_talkatu_html_parser_with_attributes(void) {
TalkatuHtmlParser *parser = test_talkatu_html_parser_new();
GString *str = g_string_new("");
const gchar *exp = \
"<html><head></head><body>" \
"<font size=\"2\" color=\"#007f00\">talkatu</font>" \
"</body></html>";
talkatu_html_parser_parse(parser, exp, str);
g_assert_cmpstr(str->str, ==, exp);
g_string_free(str, TRUE);
g_object_unref(G_OBJECT(parser));
}
static void
test_talkatu_html_parser_with_nested_attributes(void) {
TalkatuHtmlParser *parser = test_talkatu_html_parser_new();
GString *str = g_string_new("");
const gchar *exp = \
"<html><head></head><body>" \
"<font size=\"2\" color=\"#007f00\">" \
"<a href=\"https://keep.imfreedom.org/talkatu/talkatu/\">talkatu</a>" \
"</font>" \
"</body></html>";
talkatu_html_parser_parse(parser, exp, str);
g_assert_cmpstr(str->str, ==, exp);
g_string_free(str, TRUE);
g_object_unref(G_OBJECT(parser));
}
/******************************************************************************
* Main
*****************************************************************************/
gint
main(gint argc, gchar **argv) {
gint ret = 0;
g_test_init(&argc, &argv, NULL);
gtk_init(&argc, &argv);
talkatu_init();
g_test_add_func(
"/html-parser/simple",
test_talkatu_html_parser_simple);
g_test_add_func(
"/html-parser/mixed-children",
test_talkatu_html_parser_mixed);
g_test_add_func(
"/html-parser/with-comment",
test_talkatu_html_parser_with_comment);
g_test_add_func(
"/html-parser/with-attributes",
test_talkatu_html_parser_with_attributes);
g_test_add_func(
"/html-parser/with-nested-attributes",
test_talkatu_html_parser_with_nested_attributes);
ret = g_test_run();
talkatu_uninit();
return ret;
}