test_hexcoder.c 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*
  2. This file is part of GNUnet.
  3. Copyright (C) 2014 GNUnet e.V.
  4. GNUnet is free software: you can redistribute it and/or modify it
  5. under the terms of the GNU Affero General Public License as published
  6. by the Free Software Foundation, either version 3 of the License,
  7. or (at your option) any later version.
  8. GNUnet is distributed in the hope that it will be useful, but
  9. WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Affero General Public License for more details.
  12. You should have received a copy of the GNU Affero General Public License
  13. along with this program. If not, see <http://www.gnu.org/licenses/>.
  14. SPDX-License-Identifier: AGPL3.0-or-later
  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. #define TESTSTRING "Hello World!"
  26. int
  27. main (int argc,
  28. char *argv[])
  29. {
  30. char buf[strlen (TESTSTRING) + 1];
  31. char *ret;
  32. GNUNET_log_setup ("test-hexcoder", "WARNING", NULL);
  33. ret = GNUNET_DNSPARSER_bin_to_hex (TESTSTRING,
  34. strlen (TESTSTRING) + 1);
  35. GNUNET_assert (NULL != ret);
  36. GNUNET_assert (sizeof(buf) ==
  37. GNUNET_DNSPARSER_hex_to_bin (ret,
  38. buf));
  39. GNUNET_assert (0 == memcmp (TESTSTRING,
  40. buf,
  41. sizeof(buf)));
  42. GNUNET_free (ret);
  43. return 0;
  44. }
  45. /* end of test_hexcoder.c */