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

Last change on this file since 1393 was 1393, checked in by Sam Hocevar, 14 years ago
  • Renamed the "all" test to "cucul" because it otherwise conflicted with the automake "all" rule.
  • Property svn:keywords set to Id
File size: 1.5 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 1393 2006-11-14 07:46:51Z sam $
7 *
8 *  This program is free software; you can redistribute it and/or
9 *  modify it under the terms of the Do What The Fuck You Want To
10 *  Public License, Version 2, as published by Sam Hocevar. See
11 *  http://sam.zoy.org/wtfpl/COPYING for more details.
12 */
13
14#include "config.h"
15#include "common.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    for(i = 0; i < ITER; i++)
47    {
48        cucul_create_frame(cv, 0);
49        for(j = 0; j < ITER; j++)
50        {
51            char buf[BUFSIZ];
52            w = cucul_rand(1, 1000);
53            memset(buf, 'x', w);
54            buf[w] = '\0';
55            cucul_set_frame_name(cv, buf);
56        }
57    }
58    cucul_free_canvas(cv);
59
60    fprintf(stderr, "all tests passed\n");
61    return 0;
62}
63
Note: See TracBrowser for help on using the repository browser.