Browse Source

* Created a tests/ directory for regression tests. Run with "make check".

* Added a first, simple test program.
tags/v0.99.beta14
Sam Hocevar sam 17 years ago
parent
commit
ca559d93d8
5 changed files with 82 additions and 1 deletions
  1. +1
    -1
      Makefile.am
  2. +1
    -0
      configure.ac
  3. +1
    -0
      tests/.gitignore
  4. +11
    -0
      tests/Makefile.am
  5. +68
    -0
      tests/simple.c

+ 1
- 1
Makefile.am View File

@@ -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


+ 1
- 0
configure.ac View File

@@ -445,6 +445,7 @@ AC_CONFIG_FILES([
caca/Makefile
src/Makefile
examples/Makefile
tests/Makefile
tools/Makefile
csharp/Makefile
cxx/Makefile


+ 1
- 0
tests/.gitignore View File

@@ -0,0 +1 @@
simple

+ 11
- 0
tests/Makefile.am View File

@@ -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


+ 68
- 0
tests/simple.c View File

@@ -0,0 +1,68 @@
/*
* simple simple testsuite program
* Copyright (c) 2007 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 "common.h"


#if !defined(__KERNEL__)
# if defined(HAVE_INTTYPES_H)
# include <inttypes.h>
# endif
# include <stdio.h>
# include <stdlib.h>
#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;
}


Loading…
Cancel
Save