/*
 * Purple - Internet Messaging Library
 * Copyright (C) Pidgin Developers <devel@pidgin.im>
 *
 * 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 <https://www.gnu.org/licenses/>.
 */

#include <glib.h>

#include <birb.h>

#include <purple.h>

/******************************************************************************
 * Tests
 *****************************************************************************/
static void
test_purple_qr_code_new(void) {
	PurpleQrCode *qr_code = NULL;

	qr_code = purple_qr_code_new("title", NULL, "text", NULL);
	birb_assert_type(qr_code, PURPLE_TYPE_QR_CODE);

	g_assert_finalize_object(qr_code);
}

static void
test_purple_qr_code_properties(void) {
	PurpleQrCode *qr_code = NULL;
	char *alt_text = NULL;
	char *description = NULL;
	char *text = NULL;
	char *title = NULL;

	qr_code = g_object_new(PURPLE_TYPE_QR_CODE,
	                       "alt-text", "alt-text",
	                       "description", "description",
	                       "text", "text",
	                       "title", "title",
	                       NULL);

	g_object_get(G_OBJECT(qr_code),
	             "alt-text", &alt_text,
	             "description", &description,
	             "text", &text,
	             "title", &title,
	             NULL);

	g_assert_cmpstr(alt_text, ==, "alt-text");
	g_clear_pointer(&alt_text, g_free);

	g_assert_cmpstr(description, ==, "description");
	g_clear_pointer(&description, g_free);

	g_assert_cmpstr(text, ==, "text");
	g_clear_pointer(&text, g_free);

	g_assert_cmpstr(title, ==, "title");
	g_clear_pointer(&title, g_free);

	g_assert_finalize_object(qr_code);
}

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

	g_test_add_func("/qr-code/new", test_purple_qr_code_new);
	g_test_add_func("/qr-code/properties", test_purple_qr_code_properties);

	return g_test_run();
}

