source: libcaca/trunk/test/simple.c @ 4333

Last change on this file since 4333 was 4333, checked in by Sam Hocevar, 10 years ago

Large source code cleanup, getting rid of spaces, tabs, and svn keywords.

File size: 1.5 KB
Line 
1/*
2 *  simple        simple testsuite program
3 *  Copyright (c) 2007 Sam Hocevar <sam@hocevar.net>
4 *                All Rights Reserved
5 *
6 *  This program is free software. It comes without any warranty, to
7 *  the extent permitted by applicable law. You can redistribute it
8 *  and/or modify it under the terms of the Do What The Fuck You Want
9 *  To Public License, Version 2, as published by Sam Hocevar. See
10 *  http://sam.zoy.org/wtfpl/COPYING for more details.
11 */
12
13#include "config.h"
14
15#if !defined(__KERNEL__)
16#   include <stdio.h>
17#   include <stdlib.h>
18#endif
19
20#include "caca.h"
21
22#define TEST(x) \
23    do \
24    { \
25        tests++; \
26        if((x)) \
27            passed++; \
28        else \
29            fprintf(stderr, "test #%i failed\n", (tests)); \
30    } \
31    while(0)
32
33int main(int argc, char *argv[])
34{
35    caca_canvas_t *cv;
36    int tests = 0, passed = 0;
37
38    cv = caca_create_canvas(0, 0);
39    caca_put_char(cv, 0, 0, 'x');
40    TEST(caca_get_char(cv, 0, 0) != 'x');
41
42    caca_rotate_180(cv);
43
44    caca_set_canvas_size(cv, 1, 1);
45    TEST(caca_get_char(cv, 0, 0) != 'x');
46    TEST(caca_get_char(cv, 0, 0) == ' ');
47
48    caca_put_char(cv, 0, 0, 'y');
49    TEST(caca_get_char(cv, 0, 0) == 'y');
50
51    caca_set_canvas_size(cv, 1000, 1000);
52    TEST(caca_get_canvas_width(cv) == 1000);
53
54    caca_put_char(cv, 999, 999, 'z');
55    TEST(caca_get_char(cv, 999, 999) == 'z');
56
57    caca_free_canvas(cv);
58
59    fprintf(stderr, "%i tests, %i errors\n", tests, tests - passed);
60
61    return 0;
62}
63
Note: See TracBrowser for help on using the repository browser.