diff --git a/Makefile.am b/Makefile.am index 96ae024..ff1b516 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,6 +1,6 @@ # $Id$ -SUBDIRS = kernel cucul caca src examples tools csharp cxx python ruby doc +SUBDIRS = kernel cucul caca src examples tests tools csharp cxx python ruby doc DIST_SUBDIRS = $(SUBDIRS) msvc EXTRA_DIST = NOTES COPYING.GPL COPYING.LGPL bootstrap build-dos build-kernel build-win32 caca-config.in common.h libcaca.spec diff --git a/configure.ac b/configure.ac index df02aed..329abde 100644 --- a/configure.ac +++ b/configure.ac @@ -445,6 +445,7 @@ AC_CONFIG_FILES([ caca/Makefile src/Makefile examples/Makefile + tests/Makefile tools/Makefile csharp/Makefile cxx/Makefile diff --git a/tests/.gitignore b/tests/.gitignore new file mode 100644 index 0000000..ab23474 --- /dev/null +++ b/tests/.gitignore @@ -0,0 +1 @@ +simple diff --git a/tests/Makefile.am b/tests/Makefile.am new file mode 100644 index 0000000..0438caa --- /dev/null +++ b/tests/Makefile.am @@ -0,0 +1,11 @@ +# $Id$ + +AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/cucul + +TESTS = simple + +check_PROGRAMS = simple + +simple_SOURCES = simple.c +simple_LDADD = ../cucul/libcucul.la + diff --git a/tests/simple.c b/tests/simple.c new file mode 100644 index 0000000..0076d3b --- /dev/null +++ b/tests/simple.c @@ -0,0 +1,68 @@ +/* + * simple simple testsuite program + * Copyright (c) 2007 Sam Hocevar + * 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 "common.h" + + +#if !defined(__KERNEL__) +# if defined(HAVE_INTTYPES_H) +# include +# endif +# include +# include +#endif + +#include "cucul.h" + +#define TEST(x) \ + do \ + { \ + tests++; \ + if((x)) \ + passed++; \ + else \ + fprintf(stderr, "test #%i failed\n", (tests)); \ + } \ + while(0) + +int main(int argc, char *argv[]) +{ + cucul_canvas_t *cv; + int tests = 0, passed = 0; + + cv = cucul_create_canvas(0, 0); + cucul_put_char(cv, 0, 0, 'x'); + TEST(cucul_get_char(cv, 0, 0) != 'x'); + + cucul_set_canvas_size(cv, 1, 1); + TEST(cucul_get_char(cv, 0, 0) != 'x'); + TEST(cucul_get_char(cv, 0, 0) == ' '); + + cucul_put_char(cv, 0, 0, 'y'); + TEST(cucul_get_char(cv, 0, 0) == 'y'); + + cucul_set_canvas_size(cv, 1000, 1000); + TEST(cucul_get_canvas_width(cv) == 1000); + + cucul_put_char(cv, 999, 999, 'z'); + TEST(cucul_get_char(cv, 999, 999) == 'z'); + + cucul_free_canvas(cv); + + fprintf(stderr, "%i tests, %i errors\n", tests, tests - passed); + + return 0; +} +