source: libcaca/trunk/examples/canvas.c @ 4148

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

Update my e-mail address everywhere.

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