--- a/gflib-ui/tests/CMakeLists.txt Mon Dec 20 01:09:11 2010 -0600
+++ b/gflib-ui/tests/CMakeLists.txt Mon Dec 20 01:12:27 2010 -0600
@@ -1,2 +1,14 @@
+add_executable(testcolor testcolor.c) +target_link_libraries(testcolor ${GLIB_LIBRARIES} ${GFLIB_LIBRARIES} gflib-ui) +list(APPEND TESTS testcolor) +set(GTESTER_TESTS "${TESTS}") + ${GTESTER} -k --verbose -o testgflib-ui.log --- a/gflib-ui/tests/testcolor.c Mon Dec 20 01:09:11 2010 -0600
+++ b/gflib-ui/tests/testcolor.c Mon Dec 20 01:12:27 2010 -0600
@@ -1,6 +1,6 @@
* Guifications - The end-all, be-all notification framework
- * Copyright (C) 2003-2009 Gary Kramlich <grim@reaperworld.com>
+ * Copyright (C) 2003-2010 Gary Kramlich <grim@reaperworld.com> * 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
@@ -15,86 +15,41 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
-#include <gflib/gf_lib.h>
+/****************************************************************************** + *****************************************************************************/ /******************************************************************************
*****************************************************************************/
-#define COLOR_FROM_RGB(r,g,b) { \
- fail_unless(gf_color_from_rgb(&c, (r), (g), (b)) == TRUE, NULL); \
- res = (c.red == (r) && c.green == (g) && c.blue == (b)); \
- fail_unless(res, NULL); \
+test_gf_color_from_rgb(gconstpointer d) { + TestGfColorRGBData **data = (TestGfColorRGBData **)d; + g_assert(gf_color_from_rgb(&c, data[i]->red, data[i]->green, + data[i]->blue) == TRUE); + g_assert(c.red == data[i]->red && + c.green == data[i]->green && + c.blue == data[i]->blue); + } while(data[i]->red != 0 && -START_TEST(test_color_from_rgb_black)
- COLOR_FROM_RGB( 0, 0, 0)
-START_TEST(test_color_from_rgb_dark_red)
- COLOR_FROM_RGB(127, 0, 0)
-START_TEST(test_color_from_rgb_dark_yellow)
- COLOR_FROM_RGB(127, 127, 0)
-START_TEST(test_color_from_rgb_dark_green)
- COLOR_FROM_RGB( 0, 127, 0)
-START_TEST(test_color_from_rgb_dark_cyan)
- COLOR_FROM_RGB( 0, 127, 127)
-START_TEST(test_color_from_rgb_dark_blue)
- COLOR_FROM_RGB( 0, 0, 127)
-START_TEST(test_color_from_rgb_purple)
- COLOR_FROM_RGB(127, 0, 127)
-START_TEST(test_color_from_rgb_gray)
- COLOR_FROM_RGB(127, 127, 127)
-START_TEST(test_color_from_rgb_red)
- COLOR_FROM_RGB(255, 0, 0)
-START_TEST(test_color_from_rgb_yellow)
- COLOR_FROM_RGB(255, 255, 0)
-START_TEST(test_color_from_rgb_green)
- COLOR_FROM_RGB( 0, 255, 0)
-START_TEST(test_color_from_rgb_cyan)
- COLOR_FROM_RGB( 0, 255, 255)
-START_TEST(test_color_from_rgb_blue)
- COLOR_FROM_RGB( 0, 0, 255)
-START_TEST(test_color_from_rgb_magenta)
- COLOR_FROM_RGB(255, 0, 255)
-START_TEST(test_color_from_rgb_white)
- COLOR_FROM_RGB(255, 255, 255)
/******************************************************************************
*****************************************************************************/
@@ -476,124 +431,41 @@
START_TEST(test_color_to_html_white)
COLOR_TO_HTML(255, 255, 255, "#ffffff");
/******************************************************************************
*****************************************************************************/
- Suite *s = suite_create("GfColor");
- tc = tcase_create("Color from RGB");
- tcase_add_test(tc, test_color_from_rgb_black);
- tcase_add_test(tc, test_color_from_rgb_dark_red);
- tcase_add_test(tc, test_color_from_rgb_dark_yellow);
- tcase_add_test(tc, test_color_from_rgb_dark_green);
- tcase_add_test(tc, test_color_from_rgb_dark_cyan);
- tcase_add_test(tc, test_color_from_rgb_dark_blue);
- tcase_add_test(tc, test_color_from_rgb_purple);
- tcase_add_test(tc, test_color_from_rgb_gray);
- tcase_add_test(tc, test_color_from_rgb_red);
- tcase_add_test(tc, test_color_from_rgb_yellow);
- tcase_add_test(tc, test_color_from_rgb_green);
- tcase_add_test(tc, test_color_from_rgb_cyan);
- tcase_add_test(tc, test_color_from_rgb_blue);
- tcase_add_test(tc, test_color_from_rgb_magenta);
- tcase_add_test(tc, test_color_from_rgb_white);
- suite_add_tcase(s, tc);
- tc = tcase_create("Color to RGB");
- tcase_add_test(tc, test_color_to_rgb_black);
- tcase_add_test(tc, test_color_to_rgb_dark_red);
- tcase_add_test(tc, test_color_to_rgb_dark_yellow);
- tcase_add_test(tc, test_color_to_rgb_dark_green);
- tcase_add_test(tc, test_color_to_rgb_dark_cyan);
- tcase_add_test(tc, test_color_to_rgb_dark_blue);
- tcase_add_test(tc, test_color_to_rgb_purple);
- tcase_add_test(tc, test_color_to_rgb_gray);
- tcase_add_test(tc, test_color_to_rgb_red);
- tcase_add_test(tc, test_color_to_rgb_yellow);
- tcase_add_test(tc, test_color_to_rgb_green);
- tcase_add_test(tc, test_color_to_rgb_cyan);
- tcase_add_test(tc, test_color_to_rgb_blue);
- tcase_add_test(tc, test_color_to_rgb_magenta);
- tcase_add_test(tc, test_color_to_rgb_white);
- suite_add_tcase(s, tc);
+main(gint argc, gchar **argv) { + TestGfColorRGBData rgb_data[] = { + { 0, 0, 0 }, /* end point */ - tc = tcase_create("Color from HSV");
- tcase_add_test(tc, test_color_from_hsv_black);
- tcase_add_test(tc, test_color_from_hsv_dark_red);
- tcase_add_test(tc, test_color_from_hsv_dark_yellow);
- tcase_add_test(tc, test_color_from_hsv_dark_green);
- tcase_add_test(tc, test_color_from_hsv_dark_cyan);
- tcase_add_test(tc, test_color_from_hsv_dark_blue);
- tcase_add_test(tc, test_color_from_hsv_purple);
- tcase_add_test(tc, test_color_from_hsv_gray);
- tcase_add_test(tc, test_color_from_hsv_red);
- tcase_add_test(tc, test_color_from_hsv_yellow);
- tcase_add_test(tc, test_color_from_hsv_green);
- tcase_add_test(tc, test_color_from_hsv_cyan);
- tcase_add_test(tc, test_color_from_hsv_blue);
- tcase_add_test(tc, test_color_from_hsv_magenta);
- tcase_add_test(tc, test_color_from_hsv_white);
- suite_add_tcase(s, tc);
+ g_test_init(&argc, &argv, NULL); - tc = tcase_create("Color to HSV");
- tcase_add_test(tc, test_color_to_hsv_black);
- tcase_add_test(tc, test_color_to_hsv_dark_red);
- tcase_add_test(tc, test_color_to_hsv_dark_yellow);
- tcase_add_test(tc, test_color_to_hsv_dark_green);
- tcase_add_test(tc, test_color_to_hsv_dark_cyan);
- tcase_add_test(tc, test_color_to_hsv_dark_blue);
- tcase_add_test(tc, test_color_to_hsv_purple);
- tcase_add_test(tc, test_color_to_hsv_gray);
- tcase_add_test(tc, test_color_to_hsv_red);
- tcase_add_test(tc, test_color_to_hsv_yellow);
- tcase_add_test(tc, test_color_to_hsv_green);
- tcase_add_test(tc, test_color_to_hsv_cyan);
- tcase_add_test(tc, test_color_to_hsv_blue);
- tcase_add_test(tc, test_color_to_hsv_magenta);
- tcase_add_test(tc, test_color_to_hsv_white);
- suite_add_tcase(s, tc);
+ gf_lib_init(NULL, NULL); - tc = tcase_create("HTML to Color");
- tcase_add_test(tc, test_html_to_color_black);
- tcase_add_test(tc, test_html_to_color_dark_red);
- tcase_add_test(tc, test_html_to_color_dark_yellow);
- tcase_add_test(tc, test_html_to_color_dark_green);
- tcase_add_test(tc, test_html_to_color_dark_cyan);
- tcase_add_test(tc, test_html_to_color_dark_blue);
- tcase_add_test(tc, test_html_to_color_purple);
- tcase_add_test(tc, test_html_to_color_gray);
- tcase_add_test(tc, test_html_to_color_red);
- tcase_add_test(tc, test_html_to_color_yellow);
- tcase_add_test(tc, test_html_to_color_green);
- tcase_add_test(tc, test_html_to_color_cyan);
- tcase_add_test(tc, test_html_to_color_blue);
- tcase_add_test(tc, test_html_to_color_magenta);
- tcase_add_test(tc, test_html_to_color_white);
- suite_add_tcase(s, tc);
+ g_test_add_data_func("/gfcolor/from_rgb/", + test_gf_color_from_rgb); - tc = tcase_create("Color to HTML");
- tcase_add_test(tc, test_color_to_html_black);
- tcase_add_test(tc, test_color_to_html_dark_red);
- tcase_add_test(tc, test_color_to_html_dark_yellow);
- tcase_add_test(tc, test_color_to_html_dark_green);
- tcase_add_test(tc, test_color_to_html_dark_cyan);
- tcase_add_test(tc, test_color_to_html_dark_blue);
- tcase_add_test(tc, test_color_to_html_purple);
- tcase_add_test(tc, test_color_to_html_gray);
- tcase_add_test(tc, test_color_to_html_red);
- tcase_add_test(tc, test_color_to_html_yellow);
- tcase_add_test(tc, test_color_to_html_green);
- tcase_add_test(tc, test_color_to_html_cyan);
- tcase_add_test(tc, test_color_to_html_blue);
- tcase_add_test(tc, test_color_to_html_magenta);
- tcase_add_test(tc, test_color_to_html_white);
- suite_add_tcase(s, tc);