source: libcaca/trunk/examples/canvas.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.

  • Property svn:keywords set to Id
File size: 1.6 KB
Line 
1/*
2 *  all           full libcaca API test
3 *  Copyright (c) 2006 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 <string.h>
18#endif
19
20#include "caca.h"
21
22#define ITER 128
23
24int main(int argc, char *argv[])
25{
26    caca_canvas_t *cv;
27    unsigned int i, j, w, h;
28
29    fprintf(stderr, "testing caca_create_canvas()\n");
30    for(i = 0; i < ITER; i++)
31    {
32        w = caca_rand(1, 1000);
33        h = caca_rand(1, 1000);
34        cv = caca_create_canvas(w, h);
35        caca_put_char(cv, w - 1, h - 1, 'x');
36        if(caca_get_char(cv, w - 1, h - 1) != 'x')
37            fprintf(stderr, "  failed (%ux%u)\n", w, h);
38        caca_free_canvas(cv);
39    }
40
41    fprintf(stderr, "testing caca_set_frame_name()\n");
42    cv = caca_create_canvas(1, 1);
43    if(cv == NULL)
44    {
45        printf("Failed to create canvas\n");
46        return 1;
47    }
48
49    for(i = 0; i < ITER; i++)
50    {
51        caca_create_frame(cv, 0);
52        for(j = 0; j < ITER; j++)
53        {
54            char buf[BUFSIZ];
55            w = caca_rand(1, 1000);
56            memset(buf, 'x', w);
57            buf[w] = '\0';
58            caca_set_frame_name(cv, buf);
59        }
60    }
61    caca_free_canvas(cv);
62
63    fprintf(stderr, "all tests passed\n");
64    return 0;
65}
66
Note: See TracBrowser for help on using the repository browser.