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

Last change on this file since 2101 was 2101, checked in by Sam Hocevar, 12 years ago
  • Rename "test" to "examples". The former will become a real testsuite.
  • Autodetect zzuf in the configure step. It might become handy.
  • 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 2101 2007-11-30 23:48:39Z 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#include "common.h"
17
18#if !defined(__KERNEL__)
19#   include <stdio.h>
20#   include <string.h>
21#endif
22
23#include "cucul.h"
24#include "caca.h"
25
26#define ITER 128
27
28int main(int argc, char *argv[])
29{
30    cucul_canvas_t *cv;
31    unsigned int i, j, w, h;
32
33    fprintf(stderr, "testing cucul_create_canvas()\n");
34    for(i = 0; i < ITER; i++)
35    {
36        w = cucul_rand(1, 1000);
37        h = cucul_rand(1, 1000);
38        cv = cucul_create_canvas(w, h);
39        cucul_put_char(cv, w - 1, h - 1, 'x');
40        if(cucul_get_char(cv, w - 1, h - 1) != 'x')
41            fprintf(stderr, "  failed (%ux%u)\n", w, h);
42        cucul_free_canvas(cv);
43    }
44
45    fprintf(stderr, "testing cucul_set_frame_name()\n");
46    cv = cucul_create_canvas(1, 1);
47    if(cv == NULL)
48    {
49        printf("Failed to create canvas\n");
50        return 1;
51    }
52
53    for(i = 0; i < ITER; i++)
54    {
55        cucul_create_frame(cv, 0);
56        for(j = 0; j < ITER; j++)
57        {
58            char buf[BUFSIZ];
59            w = cucul_rand(1, 1000);
60            memset(buf, 'x', w);
61            buf[w] = '\0';
62            cucul_set_frame_name(cv, buf);
63        }
64    }
65    cucul_free_canvas(cv);
66
67    fprintf(stderr, "all tests passed\n");
68    return 0;
69}
70
Note: See TracBrowser for help on using the repository browser.