-fixing misc minor ats test/driver bugs
[oweals/gnunet.git] / src / dns / test_hexcoder.c
1 /*
2      This file is part of GNUnet.
3      (C) 2014 Christian Grothoff (and other contributing authors)
4
5      GNUnet is free software; you can redistribute it and/or modify
6      it under the terms of the GNU General Public License as published
7      by the Free Software Foundation; either version 3, or (at your
8      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      General Public License for more details.
14
15      You should have received a copy of the GNU General Public License
16      along with GNUnet; see the file COPYING.  If not, write to the
17      Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18      Boston, MA 02111-1307, USA.
19
20 */
21 /**
22  * @author Christian Grothoff
23  * @file dns/test_hexcoder.c
24  * @brief test for #GNUNET_DNSPARSER_hex_to_bin() and
25  *                 #GNUNET_DNSPARSER_bin_to_hex()
26  */
27 #include "platform.h"
28 #include "gnunet_util_lib.h"
29 #include "gnunet_dnsparser_lib.h"
30
31 #define TESTSTRING "Hello World!"
32
33
34 int
35 main (int argc,
36       char *argv[])
37 {
38   char buf[strlen (TESTSTRING)  + 1];
39   char *ret;
40
41   GNUNET_log_setup ("test-hexcoder", "WARNING", NULL);
42   ret = GNUNET_DNSPARSER_bin_to_hex (TESTSTRING,
43                                      strlen (TESTSTRING) + 1);
44   GNUNET_assert (NULL != ret);
45   GNUNET_assert (sizeof (buf) ==
46                  GNUNET_DNSPARSER_hex_to_bin (ret,
47                                               buf));
48   GNUNET_assert (0 == memcmp (TESTSTRING,
49                               buf,
50                               sizeof (buf)));
51   GNUNET_free (ret);
52   return 0;
53 }
54
55
56 /* end of test_hexcoder.c */