/*
 * Ibis - IRCv3 Library
 * Copyright (C) Ibis Developers
 *
 * Ibis is the legal property of its developers, whose names are too numerous
 * to list here. Please refer to the COPYRIGHT file distributed with this
 * source distribution.
 *
 * This program 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.1 of the License, or (at your
 * option) any later version.
 *
 * This program 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 program; if not, see <https://www.gnu.org/licenses/>.
 */

#include <glib.h>

#include <ibis.h>

/******************************************************************************
 * Strip Tests
 *****************************************************************************/
#define test_ibis_formatting_strip(input, expected) G_STMT_START { \
	char *actual = NULL; \
	actual = ibis_formatting_strip(input); \
	g_assert_cmpstr(actual, ==, expected); \
	g_clear_pointer(&actual, g_free); \
} G_STMT_END

static void
test_ibis_formatting_strip_null(void) {
	test_ibis_formatting_strip(NULL, NULL);
}

static void
test_ibis_formatting_strip_empty(void) {
	test_ibis_formatting_strip("", "");
}

static void
test_ibis_formatting_strip_color_comma(void) {
	test_ibis_formatting_strip("\003,", ",");
}

static void
test_ibis_formatting_strip_color_foreground_comma(void) {
	test_ibis_formatting_strip("\0033,", ",");
}

static void
test_ibis_formatting_strip_color_full(void) {
	test_ibis_formatting_strip("\0033,9whee", "whee");
}

static void
test_ibis_formatting_strip_color_foreground_3_digit(void) {
	test_ibis_formatting_strip("\003314", "4");
}

static void
test_ibis_formatting_strip_color_background_3_digit(void) {
	test_ibis_formatting_strip("\0031,234", "4");
}

static void
test_ibis_formatting_strip_hex_color(void) {
	test_ibis_formatting_strip("\004FF00FFwoo!", "woo!");
}

static void
test_ibis_formatting_strip_hex_color_full(void) {
	test_ibis_formatting_strip("\004FF00FF,00FF00woo!", "woo!");
}

static void
test_ibis_formatting_strip_hex_color_comma(void) {
	test_ibis_formatting_strip("\004,", ",");
}

static void
test_ibis_formatting_strip_hex_color_foreground_comma(void) {
	test_ibis_formatting_strip("\004FEFEFE,", ",");
}

static void
test_ibis_formatting_strip_hex_color_foreground_7_characters(void) {
	test_ibis_formatting_strip("\004FEFEFEF", "F");
}

static void
test_ibis_formatting_strip_hex_color_background_7_characters(void) {
	test_ibis_formatting_strip("\004FEFEFE,2222223", "3");
}

static void
test_ibis_formatting_strip_bold(void) {
	test_ibis_formatting_strip("this is \002bold\002!", "this is bold!");
}

static void
test_ibis_formatting_strip_italic(void) {
	test_ibis_formatting_strip("what do you \035mean\035?!",
	                           "what do you mean?!");
}

static void
test_ibis_formatting_strip_monospace(void) {
	test_ibis_formatting_strip("\021i++;\021", "i++;");
}

static void
test_ibis_formatting_strip_reset(void) {
	test_ibis_formatting_strip("end of formatting\017", "end of formatting");
}

static void
test_ibis_formatting_strip_reverse(void) {
	test_ibis_formatting_strip("re\026ver\026se", "reverse");
}

static void
test_ibis_formatting_strip_strikethrough(void) {
	test_ibis_formatting_strip("\036I could be wrong\036",
	                           "I could be wrong");
}

static void
test_ibis_formatting_strip_underline(void) {
	test_ibis_formatting_strip("You can't handle the \037truth\037!",
	                           "You can't handle the truth!");
}

static void
test_ibis_formatting_strip_spec_example1(void) {
	test_ibis_formatting_strip(
		"I love \0033IRC! \003It is the \0037best protocol ever!",
		"I love IRC! It is the best protocol ever!");
}

static void
test_ibis_formatting_strip_spec_example2(void) {
	test_ibis_formatting_strip(
		"This is a \035\00313,9cool \003message",
		"This is a cool message");
}

static void
test_ibis_formatting_strip_spec_example3(void) {
	test_ibis_formatting_strip(
		"IRC \002is \0034,12so \003great\017!",
		"IRC is so great!");
}

static void
test_ibis_formatting_strip_spec_example4(void) {
	test_ibis_formatting_strip(
		"Rules: Don't spam 5\00313,8,6\003,7,8, and especially not \0029\002\035!",
		"Rules: Don't spam 5,6,7,8, and especially not 9!");
}

/******************************************************************************
 * Parse Tests
 *****************************************************************************/
#define test_ibis_formatting_parse(raw, expected, expected_attrs) G_STMT_START { \
	PangoAttrList *actual_attrs = NULL; \
	char *actual_text = NULL; \
	actual_text = ibis_formatting_parse(raw, &actual_attrs); \
	g_assert_cmpstr(actual_text, ==, expected); \
	g_clear_pointer(&actual_text, g_free); \
	if(expected_attrs != NULL) { \
		g_assert_true(pango_attr_list_equal(actual_attrs, expected_attrs)); \
		pango_attr_list_unref(expected_attrs); \
		pango_attr_list_unref(actual_attrs); \
	} else { \
		g_assert_null(actual_attrs); \
	} \
} G_STMT_END

static void
test_ibis_formatting_parse_null(void) {
	test_ibis_formatting_parse(NULL, NULL, NULL);
}

static void
test_ibis_formatting_parse_empty(void) {
	PangoAttrList *attrs = pango_attr_list_new();

	test_ibis_formatting_parse("", "", attrs);
}

static void
test_ibis_formatting_parse_color_comma(void) {
	PangoAttrList *attrs = pango_attr_list_new();

	test_ibis_formatting_parse("\003,", ",", attrs);
}

static void
test_ibis_formatting_parse_color_foreground_comma(void) {
	PangoAttrList *attrs = pango_attr_list_new();
	PangoAttribute *attr = NULL;

	attr = pango_attr_foreground_new(0x0000, 0x9393, 0x0000);
	attr->start_index = 0;
	attr->end_index = 1;
	pango_attr_list_insert(attrs, attr);

	test_ibis_formatting_parse("\0033,", ",", attrs);
}

static void
test_ibis_formatting_parse_color_full(void) {
	PangoAttrList *attrs = pango_attr_list_new();
	PangoAttribute *attr = NULL;

	attr = pango_attr_foreground_new(0x0000, 0x9393, 0x0000);
	attr->start_index = 0;
	attr->end_index = 4;
	pango_attr_list_insert(attrs, attr);

	attr = pango_attr_background_new(0x0000, 0xfcfc, 0x0000);
	attr->start_index = 0;
	attr->end_index = 4;
	pango_attr_list_insert(attrs, attr);

	test_ibis_formatting_parse("\0033,9whee", "whee", attrs);
}

static void
test_ibis_formatting_parse_color_foreground_3_digit(void) {
	PangoAttrList *attrs = pango_attr_list_new();
	PangoAttribute *attr = NULL;

	attr = pango_attr_foreground_new(0x5151, 0x7474, 0x0000);
	attr->start_index = 0;
	attr->end_index = 1;
	pango_attr_list_insert(attrs, attr);

	test_ibis_formatting_parse("\003314", "4", attrs);
}

static void
test_ibis_formatting_parse_color_background_3_digit(void) {
	PangoAttrList *attrs = pango_attr_list_new();
	PangoAttribute *attr = NULL;

	attr = pango_attr_foreground_new(0x0000, 0x0000, 0x0000);
	attr->start_index = 0;
	attr->end_index = 1;
	pango_attr_list_insert(attrs, attr);

	attr = pango_attr_background_new(0x0000, 0x2727, 0x4747);
	attr->start_index = 0;
	attr->end_index = 1;
	pango_attr_list_insert(attrs, attr);

	test_ibis_formatting_parse("\0031,234", "4", attrs);
}

static void
test_ibis_formatting_parse_hex_color(void) {
	PangoAttrList *attrs = pango_attr_list_new();
	PangoAttribute *attr = NULL;

	attr = pango_attr_foreground_new(0xffff, 0x0000, 0xffff);
	attr->start_index = 0;
	attr->end_index = 4;
	pango_attr_list_insert(attrs, attr);

	test_ibis_formatting_parse("\004FF00FFwoo!", "woo!", attrs);
}

static void
test_ibis_formatting_parse_hex_color_full(void) {
	PangoAttrList *attrs = pango_attr_list_new();
	PangoAttribute *attr = NULL;

	attr = pango_attr_foreground_new(0xffff, 0x0000, 0xffff);
	attr->start_index = 0;
	attr->end_index = 4;
	pango_attr_list_insert(attrs, attr);

	attr = pango_attr_background_new(0x0000, 0xffff, 0x0000);
	attr->start_index = 0;
	attr->end_index = 4;
	pango_attr_list_insert(attrs, attr);

	test_ibis_formatting_parse("\004FF00FF,00FF00woo!", "woo!", attrs);
}

static void
test_ibis_formatting_parse_hex_color_comma(void) {
	PangoAttrList *attrs = pango_attr_list_new();

	test_ibis_formatting_parse("\004,", ",", attrs);
}

static void
test_ibis_formatting_parse_hex_color_foreground_comma(void) {
	PangoAttrList *attrs = pango_attr_list_new();
	PangoAttribute *attr = NULL;

	attr = pango_attr_foreground_new(0xfefe, 0xfefe, 0xfefe);
	attr->start_index = 0;
	attr->end_index = 1;
	pango_attr_list_insert(attrs, attr);

	test_ibis_formatting_parse("\004FEFEFE,", ",", attrs);
}

static void
test_ibis_formatting_parse_hex_color_foreground_7_characters(void) {
	PangoAttrList *attrs = pango_attr_list_new();
	PangoAttribute *attr = NULL;

	attr = pango_attr_foreground_new(0xfefe, 0xfefe, 0xfefe);
	attr->start_index = 0;
	attr->end_index = 1;
	pango_attr_list_insert(attrs, attr);

	test_ibis_formatting_parse("\004FEFEFEF", "F", attrs);
}

static void
test_ibis_formatting_parse_hex_color_background_7_characters(void) {
	PangoAttrList *attrs = pango_attr_list_new();
	PangoAttribute *attr = NULL;

	attr = pango_attr_foreground_new(0xfefe, 0xfefe, 0xfefe);
	attr->start_index = 0;
	attr->end_index = 1;
	pango_attr_list_insert(attrs, attr);

	attr = pango_attr_background_new(0x2222, 0x2222, 0x2222);
	attr->start_index = 0;
	attr->end_index = 1;
	pango_attr_list_insert(attrs, attr);

	test_ibis_formatting_parse("\004FEFEFE,2222223", "3", attrs);
}

static void
test_ibis_formatting_parse_bold(void) {
	PangoAttrList *attrs = pango_attr_list_new();
	PangoAttribute *attr = NULL;

	attr = pango_attr_weight_new(PANGO_WEIGHT_BOLD);
	attr->start_index = 8;
	attr->end_index = 12;
	pango_attr_list_insert(attrs, attr);

	test_ibis_formatting_parse("this is \002bold\002!",
	                           "this is bold!",
	                           attrs);
}

static void
test_ibis_formatting_parse_italic(void) {
	PangoAttrList *attrs = pango_attr_list_new();
	PangoAttribute *attr = NULL;

	attr = pango_attr_style_new(PANGO_STYLE_ITALIC);
	attr->start_index = 12;
	attr->end_index = 16;
	pango_attr_list_insert(attrs, attr);

	test_ibis_formatting_parse("what do you \035mean\035?!",
	                           "what do you mean?!",
	                           attrs);
}

static void
test_ibis_formatting_parse_monospace(void) {
	PangoAttrList *attrs = pango_attr_list_new();
	PangoAttribute *attr = NULL;

	attr = pango_attr_family_new("monospace");
	attr->start_index = 0;
	attr->end_index = 4;
	pango_attr_list_insert(attrs, attr);

	test_ibis_formatting_parse("\021i++;\021", "i++;", attrs);
}

static void
test_ibis_formatting_parse_reset(void) {
	PangoAttrList *attrs = pango_attr_list_new();

	test_ibis_formatting_parse("end of formatting\017",
	                           "end of formatting",
	                           attrs);
}

static void
test_ibis_formatting_parse_reverse(void) {
	PangoAttrList *attrs = pango_attr_list_new();

	/* reverse is ignored right now as we don't know how to handle it. */
	test_ibis_formatting_parse("re\026ver\026se", "reverse", attrs);
}

static void
test_ibis_formatting_parse_strikethrough(void) {
	PangoAttrList *attrs = pango_attr_list_new();
	PangoAttribute *attr = NULL;

	attr = pango_attr_strikethrough_new(TRUE);
	attr->start_index = 0;
	attr->end_index = 16;
	pango_attr_list_insert(attrs, attr);

	test_ibis_formatting_parse("\036I could be wrong\036",
	                           "I could be wrong",
	                           attrs);
}

static void
test_ibis_formatting_parse_underline(void) {
	PangoAttrList *attrs = pango_attr_list_new();
	PangoAttribute *attr = NULL;

	attr = pango_attr_underline_new(PANGO_UNDERLINE_SINGLE);
	attr->start_index = 21;
	attr->end_index = 26;
	pango_attr_list_insert(attrs, attr);

	test_ibis_formatting_parse("You can't handle the \037truth\037!",
	                           "You can't handle the truth!",
	                           attrs);
}

static void
test_ibis_formatting_parse_spec_example1(void) {
	PangoAttrList *attrs = pango_attr_list_new();
	PangoAttribute *attr = NULL;

	attr = pango_attr_foreground_new(0x0, 0x9393, 0x0);
	attr->start_index = 7;
	attr->end_index = 12;
	pango_attr_list_insert(attrs, attr);

	attr = pango_attr_foreground_new(0xfcfc, 0x7f7f, 0x0);
	attr->start_index = 22;
	attr->end_index = 41;
	pango_attr_list_insert(attrs, attr);

	test_ibis_formatting_parse("I love \0033IRC! \003It is the \0037best protocol ever!",
	                           "I love IRC! It is the best protocol ever!",
	                           attrs);
}

static void
test_ibis_formatting_parse_spec_example2(void) {
	PangoAttrList *attrs = pango_attr_list_new();
	PangoAttribute *attr = NULL;

	attr = pango_attr_style_new(PANGO_STYLE_ITALIC);
	attr->start_index = 10;
	attr->end_index = 22;
	pango_attr_list_insert(attrs, attr);

	attr = pango_attr_foreground_new(0xffff, 0x0, 0xffff);
	attr->start_index = 10;
	attr->end_index = 15;
	pango_attr_list_insert(attrs, attr);

	attr = pango_attr_background_new(0x0, 0xfcfc, 0x0);
	attr->start_index = 10;
	attr->end_index = 15;
	pango_attr_list_insert(attrs, attr);

	test_ibis_formatting_parse("This is a \035\00313,9cool \003message",
	                           "This is a cool message",
	                           attrs);
}

static void
test_ibis_formatting_parse_spec_example3(void) {
	PangoAttrList *attrs = pango_attr_list_new();
	PangoAttribute *attr = NULL;

	attr = pango_attr_weight_new(PANGO_WEIGHT_BOLD);
	attr->start_index = 4;
	attr->end_index = 15;
	pango_attr_list_insert(attrs, attr);

	attr = pango_attr_foreground_new(0xffff, 0x0, 0x0);
	attr->start_index = 7;
	attr->end_index = 10;
	pango_attr_list_insert(attrs, attr);

	attr = pango_attr_background_new(0x0, 0x0, 0xfcfc);
	attr->start_index = 7;
	attr->end_index = 10;
	pango_attr_list_insert(attrs, attr);

	test_ibis_formatting_parse("IRC \002is \0034,12so \003great\017!",
	                           "IRC is so great!",
	                           attrs);
}

static void
test_ibis_formatting_parse_spec_example4(void) {
	PangoAttrList *attrs = pango_attr_list_new();
	PangoAttribute *attr = NULL;

	attr = pango_attr_foreground_new(0xffff, 0x0000, 0xffff);
	attr->start_index = 19;
	attr->end_index = 21;
	pango_attr_list_insert(attrs, attr);

	attr = pango_attr_background_new(0xffff, 0xffff, 0x0000);
	attr->start_index = 19;
	attr->end_index = 21;
	pango_attr_list_insert(attrs, attr);

	attr = pango_attr_weight_new(PANGO_WEIGHT_BOLD);
	attr->start_index = 46;
	attr->end_index = 47;
	pango_attr_list_insert(attrs, attr);

	attr = pango_attr_style_new(PANGO_STYLE_ITALIC);
	attr->start_index = 47;
	attr->end_index = 48;
	pango_attr_list_insert(attrs, attr);

	test_ibis_formatting_parse("Rules: Don't spam 5\00313,8,6\003,7,8, and especially not \0029\002\035!",
	                           "Rules: Don't spam 5,6,7,8, and especially not 9!",
	                           attrs);
}

static void
test_ibis_formatting_parse_change_color_foreground_with_background(void) {
	PangoAttrList *attrs = pango_attr_list_new();
	PangoAttribute *attr = NULL;

	attr = pango_attr_foreground_new(0x0000, 0xffff, 0x0000);
	attr->start_index = 0;
	attr->end_index = 4;
	pango_attr_list_insert(attrs, attr);

	attr = pango_attr_background_new(0x0000, 0x0000, 0x0000);
	attr->start_index = 0;
	attr->end_index = 9;
	pango_attr_list_insert(attrs, attr);

	attr = pango_attr_foreground_new(0xffff, 0x0000, 0x0000);
	attr->start_index = 4;
	attr->end_index = 9;
	pango_attr_list_insert(attrs, attr);

	test_ibis_formatting_parse("\00356,88Open\00352Close", "OpenClose", attrs);
}

static void
test_ibis_formatting_parse_change_hex_foreground_with_background(void) {
	PangoAttrList *attrs = pango_attr_list_new();
	PangoAttribute *attr = NULL;

	attr = pango_attr_foreground_new(0x0000, 0xffff, 0x0000);
	attr->start_index = 0;
	attr->end_index = 4;
	pango_attr_list_insert(attrs, attr);

	attr = pango_attr_background_new(0x0000, 0x0000, 0x0000);
	attr->start_index = 0;
	attr->end_index = 9;
	pango_attr_list_insert(attrs, attr);

	attr = pango_attr_foreground_new(0xffff, 0x0000, 0x0000);
	attr->start_index = 4;
	attr->end_index = 9;
	pango_attr_list_insert(attrs, attr);

	test_ibis_formatting_parse("\00400ff00,000000Open\004ff0000Close",
	                           "OpenClose",
	                           attrs);
}

/******************************************************************************
 * Main
 *****************************************************************************/
int
main(int argc, char *argv[]) {
	g_test_init(&argc, &argv, NULL);

	/* Strip tests */
	g_test_add_func("/ibis/formatting/strip/null",
	                test_ibis_formatting_strip_null);
	g_test_add_func("/ibis/formatting/strip/empty",
	                test_ibis_formatting_strip_empty);

	g_test_add_func("/ibis/formatting/strip/color-comma",
	                test_ibis_formatting_strip_color_comma);
	g_test_add_func("/ibis/formatting/strip/color-full",
	                test_ibis_formatting_strip_color_full);
	g_test_add_func("/ibis/formatting/strip/color-foreground-comma",
	                test_ibis_formatting_strip_color_foreground_comma);
	g_test_add_func("/ibis/formatting/strip/color-foreground-3-digit",
	                test_ibis_formatting_strip_color_foreground_3_digit);
	g_test_add_func("/ibis/formatting/strip/color-background-3-digit",
	                test_ibis_formatting_strip_color_background_3_digit);

	g_test_add_func("/ibis/formatting/strip/hex-color",
	                test_ibis_formatting_strip_hex_color);
	g_test_add_func("/ibis/formatting/strip/hex-color-full",
	                test_ibis_formatting_strip_hex_color_full);
	g_test_add_func("/ibis/formatting/strip/hex-color-comma",
	                test_ibis_formatting_strip_hex_color_comma);
	g_test_add_func("/ibis/formatting/strip/hex-color-foreground-comma",
	                test_ibis_formatting_strip_hex_color_foreground_comma);
	g_test_add_func("/ibis/formatting/strip/hex-color-foreground-7-characters",
	                test_ibis_formatting_strip_hex_color_foreground_7_characters);
	g_test_add_func("/ibis/formatting/strip/hex-color-background-7-characters",
	                test_ibis_formatting_strip_hex_color_background_7_characters);

	g_test_add_func("/ibis/formatting/strip/bold",
	                test_ibis_formatting_strip_bold);
	g_test_add_func("/ibis/formatting/strip/italic",
	                test_ibis_formatting_strip_italic);
	g_test_add_func("/ibis/formatting/strip/monospace",
	                test_ibis_formatting_strip_monospace);
	g_test_add_func("/ibis/formatting/strip/reset",
	                test_ibis_formatting_strip_reset);
	g_test_add_func("/ibis/formatting/strip/reverse",
	                test_ibis_formatting_strip_reverse);
	g_test_add_func("/ibis/formatting/strip/strikethrough",
	                test_ibis_formatting_strip_strikethrough);
	g_test_add_func("/ibis/formatting/strip/underline",
	                test_ibis_formatting_strip_underline);

	/* These tests are based on the examples here
	 * https://modern.ircdocs.horse/formatting.html#examples
	 */
	g_test_add_func("/ibis/formatting/strip/spec-example1",
	                test_ibis_formatting_strip_spec_example1);
	g_test_add_func("/ibis/formatting/strip/spec-example2",
	                test_ibis_formatting_strip_spec_example2);
	g_test_add_func("/ibis/formatting/strip/spec-example3",
	                test_ibis_formatting_strip_spec_example3);
	g_test_add_func("/ibis/formatting/strip/spec-example4",
	                test_ibis_formatting_strip_spec_example4);

	/* Parsing tests */
	g_test_add_func("/ibis/formatting/parse/null",
	                test_ibis_formatting_parse_null);
	g_test_add_func("/ibis/formatting/parse/empty",
	                test_ibis_formatting_parse_empty);

	g_test_add_func("/ibis/formatting/parse/color-comma",
	                test_ibis_formatting_parse_color_comma);
	g_test_add_func("/ibis/formatting/parse/color-full",
	                test_ibis_formatting_parse_color_full);
	g_test_add_func("/ibis/formatting/parse/color-foreground-comma",
	                test_ibis_formatting_parse_color_foreground_comma);
	g_test_add_func("/ibis/formatting/parse/color-foreground-3-digit",
	                test_ibis_formatting_parse_color_foreground_3_digit);
	g_test_add_func("/ibis/formatting/parse/color-background-3-digit",
	                test_ibis_formatting_parse_color_background_3_digit);

	g_test_add_func("/ibis/formatting/parse/hex-color",
	                test_ibis_formatting_parse_hex_color);
	g_test_add_func("/ibis/formatting/parse/hex-color-full",
	                test_ibis_formatting_parse_hex_color_full);
	g_test_add_func("/ibis/formatting/parse/hex-color-comma",
	                test_ibis_formatting_parse_hex_color_comma);
	g_test_add_func("/ibis/formatting/parse/hex-color-foreground-comma",
	                test_ibis_formatting_parse_hex_color_foreground_comma);
	g_test_add_func("/ibis/formatting/parse/hex-color-foreground-7-characters",
	                test_ibis_formatting_parse_hex_color_foreground_7_characters);
	g_test_add_func("/ibis/formatting/parse/hex-color-background-7-characters",
	                test_ibis_formatting_parse_hex_color_background_7_characters);

	g_test_add_func("/ibis/formatting/parse/bold",
	                test_ibis_formatting_parse_bold);
	g_test_add_func("/ibis/formatting/parse/italic",
	                test_ibis_formatting_parse_italic);
	g_test_add_func("/ibis/formatting/parse/monospace",
	                test_ibis_formatting_parse_monospace);
	g_test_add_func("/ibis/formatting/parse/reset",
	                test_ibis_formatting_parse_reset);
	g_test_add_func("/ibis/formatting/parse/reverse",
	                test_ibis_formatting_parse_reverse);
	g_test_add_func("/ibis/formatting/parse/strikethrough",
	                test_ibis_formatting_parse_strikethrough);
	g_test_add_func("/ibis/formatting/parse/underline",
	                test_ibis_formatting_parse_underline);

	g_test_add_func("/ibis/formatting/parse/spec-example1",
	                test_ibis_formatting_parse_spec_example1);
	g_test_add_func("/ibis/formatting/parse/spec-example2",
	                test_ibis_formatting_parse_spec_example2);
	g_test_add_func("/ibis/formatting/parse/spec-example3",
	                test_ibis_formatting_parse_spec_example3);
	g_test_add_func("/ibis/formatting/parse/spec-example4",
	                test_ibis_formatting_parse_spec_example4);

	g_test_add_func("/ibis/formatting/parse/change-color-foreground-with-background",
	                test_ibis_formatting_parse_change_color_foreground_with_background);
	g_test_add_func("/ibis/formatting/parse/change-hex-foreground-with-background",
	                test_ibis_formatting_parse_change_hex_foreground_with_background);

	return g_test_run();
}
