~ubuntu-branches/ubuntu/gutsy/libcaca/gutsy

« back to all changes in this revision

Viewing changes to test/cucul.c

  • Committer: Bazaar Package Importer
  • Author(s): Sam Hocevar (Debian packages)
  • Date: 2006-12-03 02:05:11 UTC
  • mfrom: (3.1.6 feisty)
  • Revision ID: james.westby@ubuntu.com-20061203020511-h5nzqgf8nov7ns3z
Tags: 0.99.beta11.debian-2
Remove toilet from caca-utils now that it has entered testing.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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 1066 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
 
 
27
int 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