root/common/trunk/tests/test_base64.c @ 3922

Revision 3922, 2.7 KB (checked in by ucacsva, 7 years ago)

1. Removed some tagged comments from previous commits (//SV-XXX).
2. Added newer config.[sub/guess]
3. Various fixes to sync common library with that of ANL:

  • Replaced some "dnl" comments with "#" and stripped off some dnl's from the end of lines
  • Require autoconf v2.5 with AC_PREREQ(2.5)
  • Replaced LIBOBJS="$LIBOBJS inet_ntop.o" by AC_LIBOBJ([inet_ntop])
  • Find which network interface is in use (WinXP).
  • Forgotten NDEF replaced by HAVE_MSGHDR_MSGCTRL.
  • Sets event.data to s->last.active (used by AccessGrid?'s logging code).
  • Introduced rtp_get_ssrc_count() (AccessGrid? logging code).


  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1/*
2 * FILE:    test_base64.c
3 * AUTHORS: Colin Perkins
4 *
5 * Copyright (c) 1999-2000 University College London
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, is permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 *    notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 *    notice, this list of conditions and the following disclaimer in the
15 *    documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 *    must display the following acknowledgement:
18 *      This product includes software developed by the Computer Science
19 *      Department at University College London
20 * 4. Neither the name of the University nor of the Department may be used
21 *    to endorse or promote products derived from this software without
22 *    specific prior written permission.
23 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
24 * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE.
34 */
35
36#include "config_unix.h"
37#include "config_win32.h"
38#include "debug.h"
39#include "base64.h"
40#include "test_base64.h"
41
42void test_base64(void)
43{
44        /* The string "Hello, world" should encode as "SGVsbG8sIHdvcmxk" */
45        const char      *input = "Hello, world";
46        char     output[100];
47        char     decode[100];
48        int      i;
49
50        for (i = 0; i < 100; i++) {
51                output[i] = '\0';
52        }
53
54        printf("Base64 encode.......................... "); fflush(stdout);
55        i = base64encode((const unsigned char *)input, strlen(input), (unsigned char *)output, 100);
56        if ((i != 16) || (strncmp(output, "SGVsbG8sIHdvcmxk", i) != 0)) {
57                printf("fail\n");
58                return;
59        }
60        printf("pass\n");
61
62        printf("Base64 decode.......................... "); fflush(stdout);
63        i = base64decode((unsigned char *)output, i, (unsigned char *)decode, 100);
64        if ((i != 12) || (strncmp(decode, "Hello, world", i) != 0)) {
65                printf("fail\n");
66                return;
67        }
68        printf("pass\n");
69}
Note: See TracBrowser for help on using the browser.