@@ -84,6 +84,8 @@ AC_ARG_ENABLE(plugins, | |||||
[ --enable-plugins make X11 and GL drivers plugins (default disabled)]) | [ --enable-plugins make X11 and GL drivers plugins (default disabled)]) | ||||
AC_ARG_ENABLE(doc, | AC_ARG_ENABLE(doc, | ||||
[ --enable-doc build documentation (needs doxygen and LaTeX)]) | [ --enable-doc build documentation (needs doxygen and LaTeX)]) | ||||
AC_ARG_ENABLE(cppunit, | |||||
[ --enable-cppunit use cppunit for unit tests (autodetected)]) | |||||
AC_ARG_ENABLE(zzuf, | AC_ARG_ENABLE(zzuf, | ||||
[ --enable-zzuf use zzuf for fuzzing tests (autodetected)]) | [ --enable-zzuf use zzuf for fuzzing tests (autodetected)]) | ||||
@@ -451,6 +453,11 @@ fi | |||||
AM_CONDITIONAL(BUILD_DOCUMENTATION, test "${DOXYGEN}" != "no") | AM_CONDITIONAL(BUILD_DOCUMENTATION, test "${DOXYGEN}" != "no") | ||||
AM_CONDITIONAL(USE_LATEX, test "${LATEX}" != "no") | AM_CONDITIONAL(USE_LATEX, test "${LATEX}" != "no") | ||||
# Use cppunit for unit tests? | |||||
CPPUNIT="no" | |||||
PKG_CHECK_MODULES(CPPUNIT, cppunit, [CPPUNIT="yes"], [AC_MSG_RESULT(no)]) | |||||
AM_CONDITIONAL(USE_CPPUNIT, test "$CPPUNIT" != "no") | |||||
# Use zzuf for fuzzing tests? | # Use zzuf for fuzzing tests? | ||||
ZZUF="no" | ZZUF="no" | ||||
if test "${enable_zzuf}" != "no"; then | if test "${enable_zzuf}" != "no"; then | ||||
@@ -1 +1,2 @@ | |||||
simple | simple | ||||
cucul-test |
@@ -2,10 +2,18 @@ | |||||
AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/cucul -I../cucul | AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/cucul -I../cucul | ||||
TESTS = simple | |||||
if USE_CPPUNIT | |||||
cppunit_tests = cucul-test | |||||
endif | |||||
check_PROGRAMS = simple | |||||
noinst_PROGRAMS = simple $(cppunit_tests) | |||||
TESTS = $(noinst_PROGRAMS) | |||||
simple_SOURCES = simple.c | simple_SOURCES = simple.c | ||||
simple_LDADD = ../cucul/libcucul.la | simple_LDADD = ../cucul/libcucul.la | ||||
cucul_test_SOURCES = cucul-test.cpp canvas.cpp | |||||
cucul_test_CPPFLAGS = $(CPPUNIT_CFLAGS) | |||||
cucul_test_LDADD = ../cucul/libcucul.la $(CPPUNIT_LIBS) | |||||
@@ -0,0 +1,103 @@ | |||||
/* | |||||
* cucul-test testsuite program for libcucul | |||||
* Copyright (c) 2008 Sam Hocevar <sam@zoy.org> | |||||
* Copyright (c) 2008 Sam Hocevar <sam@zoy.org> | |||||
* All Rights Reserved | |||||
* | |||||
* $Id$ | |||||
* | |||||
* This program is free software. It comes without any warranty, to | |||||
* the extent permitted by applicable law. You can redistribute it | |||||
* and/or modify it under the terms of the Do What The Fuck You Want | |||||
* To Public License, Version 2, as published by Sam Hocevar. See | |||||
* http://sam.zoy.org/wtfpl/COPYING for more details. | |||||
*/ | |||||
#include "config.h" | |||||
#include <cppunit/extensions/HelperMacros.h> | |||||
#include <cppunit/TestCaller.h> | |||||
#include <cppunit/TestCase.h> | |||||
#include <cppunit/TestSuite.h> | |||||
#include "cucul.h" | |||||
class CanvasTest : public CppUnit::TestCase | |||||
{ | |||||
CPPUNIT_TEST_SUITE(CanvasTest); | |||||
CPPUNIT_TEST(test_creation); | |||||
CPPUNIT_TEST(test_resize); | |||||
CPPUNIT_TEST(test_chars); | |||||
CPPUNIT_TEST_SUITE_END(); | |||||
public: | |||||
CanvasTest() : CppUnit::TestCase("Canvas Test") {} | |||||
void setUp() {} | |||||
void tearDown() {} | |||||
void test_creation() | |||||
{ | |||||
cucul_canvas_t *cv; | |||||
cv = cucul_create_canvas(0, 0); | |||||
CPPUNIT_ASSERT(cv != NULL); | |||||
cucul_free_canvas(cv); | |||||
} | |||||
void test_resize() | |||||
{ | |||||
cucul_canvas_t *cv; | |||||
cv = cucul_create_canvas(0, 0); | |||||
CPPUNIT_ASSERT_EQUAL(cucul_get_canvas_width(cv), 0U); | |||||
CPPUNIT_ASSERT_EQUAL(cucul_get_canvas_height(cv), 0U); | |||||
cucul_set_canvas_size(cv, 1, 1); | |||||
CPPUNIT_ASSERT_EQUAL(cucul_get_canvas_width(cv), 1U); | |||||
CPPUNIT_ASSERT_EQUAL(cucul_get_canvas_height(cv), 1U); | |||||
cucul_set_canvas_size(cv, 1234, 1001); | |||||
CPPUNIT_ASSERT_EQUAL(cucul_get_canvas_width(cv), 1234U); | |||||
CPPUNIT_ASSERT_EQUAL(cucul_get_canvas_height(cv), 1001U); | |||||
cucul_set_canvas_size(cv, 0, 0); | |||||
CPPUNIT_ASSERT_EQUAL(cucul_get_canvas_width(cv), 0U); | |||||
CPPUNIT_ASSERT_EQUAL(cucul_get_canvas_height(cv), 0U); | |||||
cucul_free_canvas(cv); | |||||
} | |||||
void test_chars() | |||||
{ | |||||
cucul_canvas_t *cv; | |||||
cv = cucul_create_canvas(0, 0); | |||||
CPPUNIT_ASSERT(cucul_get_char(cv, 0, 0) == ' '); | |||||
cucul_put_char(cv, 0, 0, 'x'); | |||||
CPPUNIT_ASSERT(cucul_get_char(cv, 0, 0) == ' '); | |||||
cucul_set_canvas_size(cv, 1, 1); | |||||
CPPUNIT_ASSERT(cucul_get_char(cv, 0, 0) == ' '); | |||||
cucul_put_char(cv, 0, 0, 'x'); | |||||
CPPUNIT_ASSERT(cucul_get_char(cv, 0, 0) == 'x'); | |||||
cucul_put_char(cv, 0, 0, 'y'); | |||||
CPPUNIT_ASSERT(cucul_get_char(cv, 0, 0) == 'y'); | |||||
cucul_set_canvas_size(cv, 1000, 1000); | |||||
CPPUNIT_ASSERT(cucul_get_char(cv, 999, 999) == ' '); | |||||
cucul_put_char(cv, 999, 999, 'z'); | |||||
CPPUNIT_ASSERT(cucul_get_char(cv, 999, 999) == 'z'); | |||||
cucul_free_canvas(cv); | |||||
} | |||||
}; | |||||
CPPUNIT_TEST_SUITE_REGISTRATION(CanvasTest); | |||||
@@ -0,0 +1,29 @@ | |||||
/* | |||||
* cucul-test testsuite program for libcucul | |||||
* Copyright (c) 2008 Sam Hocevar <sam@zoy.org> | |||||
* All Rights Reserved | |||||
* | |||||
* $Id$ | |||||
* | |||||
* This program is free software. It comes without any warranty, to | |||||
* the extent permitted by applicable law. You can redistribute it | |||||
* and/or modify it under the terms of the Do What The Fuck You Want | |||||
* To Public License, Version 2, as published by Sam Hocevar. See | |||||
* http://sam.zoy.org/wtfpl/COPYING for more details. | |||||
*/ | |||||
#include "config.h" | |||||
#include <cppunit/TextTestRunner.h> | |||||
#include <cppunit/extensions/TestFactoryRegistry.h> | |||||
int main(int argc, char *argv[]) | |||||
{ | |||||
CppUnit::TextTestRunner runner; | |||||
runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest()); | |||||
runner.run(); | |||||
return 0; | |||||
} | |||||