source: libcaca/trunk/examples/cucul.c @ 2299

Last change on this file since 2299 was 2299, checked in by Sam Hocevar, 12 years ago
  • Remove #include <stdint.h> etc. from "common.h". Instead, make sure that <cucul.h> will provide the C99 types, even if libcaca has been installed.
  • Rename what's left of "common.h" to "stubs.h".
  • Remove all references to erroneous <inttypes.h> from source files.
  • Property svn:keywords set to Id
File size: 1.7 KB
Line 
1/*
2 *  all           full libcaca API test
3 *  Copyright (c) 2006 Sam Hocevar <sam@zoy.org>
4 *                All Rights Reserved
5 *
6 *  $Id: cucul.c 2299 2008-04-19 12:42:50Z 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 "cucul.h"
23#include "caca.h"
24
25#define ITER 128
26
27int main(int argc, char *argv[])
28{
29    cucul_canvas_t *cv;
30    unsigned int i, j, w, h;
31
32    fprintf(stderr, "testing cucul_create_canvas()\n");
33    for(i = 0; i < ITER; i++)
34    {
35        w = cucul_rand(1, 1000);
36        h = cucul_rand(1, 1000);
37        cv = cucul_create_canvas(w, h);
38        cucul_put_char(cv, w - 1, h - 1, 'x');
39        if(cucul_get_char(cv, w - 1, h - 1) != 'x')
40            fprintf(stderr, "  failed (%ux%u)\n", w, h);
41        cucul_free_canvas(cv);
42    }
43
44    fprintf(stderr, "testing cucul_set_frame_name()\n");
45    cv = cucul_create_canvas(1, 1);
46    if(cv == NULL)
47    {
48        printf("Failed to create canvas\n");
49        return 1;
50    }
51
52    for(i = 0; i < ITER; i++)
53    {
54        cucul_create_frame(cv, 0);
55        for(j = 0; j < ITER; j++)
56        {
57            char buf[BUFSIZ];
58            w = cucul_rand(1, 1000);
59            memset(buf, 'x', w);
60            buf[w] = '\0';
61            cucul_set_frame_name(cv, buf);
62        }
63    }
64    cucul_free_canvas(cv);
65
66    fprintf(stderr, "all tests passed\n");
67    return 0;
68}
69
Note: See TracBrowser for help on using the repository browser.