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 | |
---|
17 | #if !defined(__KERNEL__) |
---|
18 | # include <stdio.h> |
---|
19 | # include <stdlib.h> |
---|
20 | #endif |
---|
21 | |
---|
22 | #include "caca.h" |
---|
23 | |
---|
24 | #define TEST(x) \ |
---|
25 | do \ |
---|
26 | { \ |
---|
27 | tests++; \ |
---|
28 | if((x)) \ |
---|
29 | passed++; \ |
---|
30 | else \ |
---|
31 | fprintf(stderr, "test #%i failed\n", (tests)); \ |
---|
32 | } \ |
---|
33 | while(0) |
---|
34 | |
---|
35 | int main(int argc, char *argv[]) |
---|
36 | { |
---|
37 | caca_canvas_t *cv; |
---|
38 | int tests = 0, passed = 0; |
---|
39 | |
---|
40 | cv = caca_create_canvas(0, 0); |
---|
41 | caca_put_char(cv, 0, 0, 'x'); |
---|
42 | TEST(caca_get_char(cv, 0, 0) != 'x'); |
---|
43 | |
---|
44 | caca_rotate_180(cv); |
---|
45 | |
---|
46 | caca_set_canvas_size(cv, 1, 1); |
---|
47 | TEST(caca_get_char(cv, 0, 0) != 'x'); |
---|
48 | TEST(caca_get_char(cv, 0, 0) == ' '); |
---|
49 | |
---|
50 | caca_put_char(cv, 0, 0, 'y'); |
---|
51 | TEST(caca_get_char(cv, 0, 0) == 'y'); |
---|
52 | |
---|
53 | caca_set_canvas_size(cv, 1000, 1000); |
---|
54 | TEST(caca_get_canvas_width(cv) == 1000); |
---|
55 | |
---|
56 | caca_put_char(cv, 999, 999, 'z'); |
---|
57 | TEST(caca_get_char(cv, 999, 999) == 'z'); |
---|
58 | |
---|
59 | caca_free_canvas(cv); |
---|
60 | |
---|
61 | fprintf(stderr, "%i tests, %i errors\n", tests, tests - passed); |
---|
62 | |
---|
63 | return 0; |
---|
64 | } |
---|
65 | |
---|