/*
 * Copyright (C) Birb Developers
 *
 * Birb is the legal property of its developers, whose names are too numerous
 * to list here. Please refer to the AUTHORS 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 <birb.h>

/******************************************************************************
 * Mention Tests
 *****************************************************************************/
static void
test_birb_attr_mention_new(void) {
	BirbAttrMention *mention = NULL;
	PangoAttribute *attribute = NULL;

	attribute = birb_attr_mention_new(BIRB_MENTION_USER, "foo", "#FF00FF");
	g_assert_nonnull(attribute);

	mention = (BirbAttrMention *)attribute;

	g_assert_cmpuint(mention->type, ==, BIRB_MENTION_USER);
	g_assert_cmpstr(mention->id, ==, "foo");
	g_assert_cmpstr(mention->color, ==, "#FF00FF");

	g_clear_pointer(&attribute, pango_attribute_destroy);
}

static void
test_birb_attr_mention_nulls(void) {
	BirbAttrMention *mention = NULL;
	PangoAttribute *attribute = NULL;

	attribute = birb_attr_mention_new(BIRB_MENTION_GROUP, NULL, NULL);
	g_assert_nonnull(attribute);

	mention = (BirbAttrMention *)attribute;

	g_assert_cmpuint(mention->type, ==, BIRB_MENTION_GROUP);
	g_assert_cmpstr(mention->id, ==, NULL);
	g_assert_cmpstr(mention->color, ==, NULL);

	g_clear_pointer(&attribute, pango_attribute_destroy);
}

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

	g_test_set_nonfatal_assertions();

	g_test_add_func("/attr/mention/new", test_birb_attr_mention_new);
	g_test_add_func("/attr/mention/nulls", test_birb_attr_mention_nulls);

	return g_test_run();
}
