r1595: Updated C test functions
[uffi.git] / examples / c-test-fns.c
1 /***************************************************************************
2  * FILE IDENTIFICATION
3  *  
4  *  Name:         c-test-fns.c
5  *  Purpose:      Test functions in C for UFFI library
6  *  Programer:    Kevin M. Rosenberg
7  *  Date Started: Mar 2002
8  *
9  *  CVS Id:   $Id: c-test-fns.c,v 1.1 2002/03/21 02:41:30 kevin Exp $
10  *
11  * This file, part of UFFI, is Copyright (c) 2002 by Kevin M. Rosenberg
12  *
13  * UFFI users are granted the rights to distribute and use this software
14  * as governed by the terms of the Lisp Lesser GNU Public License
15  * (http://opensource.franz.com/preamble.html), also known as the LLGPL.
16
17  * These variables are correct for GCC
18  * you'll need to modify these for other compilers
19  ***************************************************************************/
20
21 #include <ctype.h>
22 #include <stdlib.h>
23
24
25 /* Test of constant input string */
26 int
27 cstring_count_upper (char* psz)
28 {
29   int count = 0;
30   while (*psz) {
31     if (isupper (*psz))
32       ++count;
33     ++psz;
34   }
35 }
36
37 /* Test of input and output of a string */
38 void
39 cstring_to_upper (char* psz)
40 {
41   while (*psz) {
42     *psz = toupper (*psz);
43     ++psz;
44   }
45 }
46
47 /* Test of an output only string */
48 void
49 cstring_make_random (int size, char* buffer)
50 {
51   int i;
52   for (i = 0; i < size; i++)
53     buffer[i] = 'A' + (rand() % 26);
54 }
55
56     
57
58