first batch of license fixes (boring)
[oweals/gnunet.git] / src / dns / test_hexcoder.c
1 /*
2      This file is part of GNUnet.
3      Copyright (C) 2014 GNUnet e.V.
4
5      GNUnet is free software: you can redistribute it and/or modify it
6      under the terms of the GNU General Public License as published
7      by the Free Software Foundation, either version 3 of the License,
8      or (at your option) any later version.
9
10      GNUnet is distributed in the hope that it will be useful, but
11      WITHOUT ANY WARRANTY; without even the implied warranty of
12      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13      Affero General Public License for more details.
14
15 */
16 /**
17  * @author Christian Grothoff
18  * @file dns/test_hexcoder.c
19  * @brief test for #GNUNET_DNSPARSER_hex_to_bin() and
20  *                 #GNUNET_DNSPARSER_bin_to_hex()
21  */
22 #include "platform.h"
23 #include "gnunet_util_lib.h"
24 #include "gnunet_dnsparser_lib.h"
25
26 #define TESTSTRING "Hello World!"
27
28
29 int
30 main (int argc,
31       char *argv[])
32 {
33   char buf[strlen (TESTSTRING)  + 1];
34   char *ret;
35
36   GNUNET_log_setup ("test-hexcoder", "WARNING", NULL);
37   ret = GNUNET_DNSPARSER_bin_to_hex (TESTSTRING,
38                                      strlen (TESTSTRING) + 1);
39   GNUNET_assert (NULL != ret);
40   GNUNET_assert (sizeof (buf) ==
41                  GNUNET_DNSPARSER_hex_to_bin (ret,
42                                               buf));
43   GNUNET_assert (0 == memcmp (TESTSTRING,
44                               buf,
45                               sizeof (buf)));
46   GNUNET_free (ret);
47   return 0;
48 }
49
50
51 /* end of test_hexcoder.c */