/*
 * Copyright (C) 2023-2025 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 General Public License as published by
 * the Free Software Foundation; either version 2 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, see <https://www.gnu.org/licenses/>.
 */

#include <birb.h>

/******************************************************************************
 * Tests
 *****************************************************************************/
static void
test_birb_str_is_empty(void) {
	g_assert_true(birb_str_is_empty(NULL));
	g_assert_true(birb_str_is_empty(""));

	g_assert_false(birb_str_is_empty("birb"));
}

static void
test_birb_str_equal(void) {
	g_assert_true(birb_str_equal(NULL, NULL));
	g_assert_true(birb_str_equal("", ""));
	g_assert_true(birb_str_equal("birb", "birb"));

	g_assert_false(birb_str_equal(NULL, "birb"));
	g_assert_false(birb_str_equal("birb", NULL));
}

static void
test_birb_str_to_uint(void) {
	g_assert_cmpuint(birb_str_to_uint(NULL), ==, 0);
	g_assert_cmpuint(birb_str_to_uint(""), ==, 0);
	g_assert_cmpuint(birb_str_to_uint("10"), ==, 10);
	g_assert_cmpuint(birb_str_to_uint("birb"), ==, 0);
	g_assert_cmpuint(birb_str_to_uint("3.14"), ==, 3);
}

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

	g_test_add_func("/birb/str/is-empty", test_birb_str_is_empty);
	g_test_add_func("/birb/str/equal", test_birb_str_equal);
	g_test_add_func("/birb/str/to-uint", test_birb_str_to_uint);

	return g_test_run();
}
