test-crypto.c 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #include <glib.h>
  2. #include <gio/gio.h>
  3. #include <string.h>
  4. #include "iridium-crypto.h"
  5. static void
  6. test_hexlify (void)
  7. {
  8. guint8 data[] = { 'A', '1', 'x', ';' };
  9. gchar *hexlified = iridium_crypto_hexlify (data, 4);
  10. g_assert_cmpstr (hexlified, ==, "4131783b");
  11. g_free (hexlified);
  12. }
  13. static void
  14. test_unhexlify (void)
  15. {
  16. gchar *hexlified = "466f6f62617221";
  17. guint8 *data = iridium_crypto_unhexlify (hexlified, strlen (hexlified));
  18. g_assert_cmpstr ((gchar *) data, ==, "Foobar!");
  19. g_free (data);
  20. }
  21. static void
  22. test_decrypt_003 (void)
  23. {
  24. GBytes *data;
  25. data = g_resources_lookup_data ("/net/bloerg/Test/dumps/003.json",
  26. G_RESOURCE_LOOKUP_FLAGS_NONE, NULL);
  27. g_assert_nonnull (data);
  28. g_bytes_unref (data);
  29. }
  30. int
  31. main (int argc, char * argv[])
  32. {
  33. g_test_init (&argc, &argv, NULL);
  34. g_test_add_func ("/crypto/hexlify", test_hexlify);
  35. g_test_add_func ("/crypto/unhexlify", test_unhexlify);
  36. g_test_add_func ("/crypto/decrypt/003", test_decrypt_003);
  37. return g_test_run ();
  38. }