source: libcaca/trunk/tests/simple.c @ 2103

Last change on this file since 2103 was 2103, checked in by Sam Hocevar, 16 years ago
  • Created a tests/ directory for regression tests. Run with "make check".
  • Added a first, simple test program.
File size: 1.5 KB
Line 
1/*
2 *  simple        simple testsuite program
3 *  Copyright (c) 2007 Sam Hocevar <sam@zoy.org>
4 *                All Rights Reserved
5 *
6 *  $Id$
7 *
8 *  This program is free software. It comes without any warranty, to
9 *  the extent permitted by applicable law. You can redistribute it
10 *  and/or modify it under the terms of the Do What The Fuck You Want
11 *  To Public License, Version 2, as published by Sam Hocevar. See
12 *  http://sam.zoy.org/wtfpl/COPYING for more details.
13 */
14
15#include "config.h"
16#include "common.h"
17
18
19#if !defined(__KERNEL__)
20#   if defined(HAVE_INTTYPES_H)
21#      include <inttypes.h>
22#   endif
23#   include <stdio.h>
24#   include <stdlib.h>
25#endif
26
27#include "cucul.h"
28
29#define TEST(x) \
30    do \
31    { \
32        tests++; \
33        if((x)) \
34            passed++; \
35        else \
36            fprintf(stderr, "test #%i failed\n", (tests)); \
37    } \
38    while(0)
39
40int main(int argc, char *argv[])
41{
42    cucul_canvas_t *cv;
43    int tests = 0, passed = 0;
44
45    cv = cucul_create_canvas(0, 0);
46    cucul_put_char(cv, 0, 0, 'x');
47    TEST(cucul_get_char(cv, 0, 0) != 'x');
48
49    cucul_set_canvas_size(cv, 1, 1);
50    TEST(cucul_get_char(cv, 0, 0) != 'x');
51    TEST(cucul_get_char(cv, 0, 0) == ' ');
52
53    cucul_put_char(cv, 0, 0, 'y');
54    TEST(cucul_get_char(cv, 0, 0) == 'y');
55
56    cucul_set_canvas_size(cv, 1000, 1000);
57    TEST(cucul_get_canvas_width(cv) == 1000);
58
59    cucul_put_char(cv, 999, 999, 'z');
60    TEST(cucul_get_char(cv, 999, 999) == 'z');
61
62    cucul_free_canvas(cv);
63
64    fprintf(stderr, "%i tests, %i errors\n", tests, tests - passed);
65
66    return 0;
67}
68
Note: See TracBrowser for help on using the repository browser.