source: libcaca/trunk/test/cucul.c @ 1452

Last change on this file since 1452 was 1452, checked in by Sam Hocevar, 13 years ago
  • Add a no warranty clause to the code.
  • 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@zoy.org>
4 *                All Rights Reserved
5 *
6 *  $Id: cucul.c 1452 2006-12-11 15:48:46Z sam $
7 *
8 *  This program is free software. It commes 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    for(i = 0; i < ITER; i++)
48    {
49        cucul_create_frame(cv, 0);
50        for(j = 0; j < ITER; j++)
51        {
52            char buf[BUFSIZ];
53            w = cucul_rand(1, 1000);
54            memset(buf, 'x', w);
55            buf[w] = '\0';
56            cucul_set_frame_name(cv, buf);
57        }
58    }
59    cucul_free_canvas(cv);
60
61    fprintf(stderr, "all tests passed\n");
62    return 0;
63}
64
Note: See TracBrowser for help on using the repository browser.