summaryrefslogtreecommitdiff
path: root/src/util/test_payto.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2020-01-14 23:54:43 +0100
committerChristian Grothoff <christian@grothoff.org>2020-01-14 23:54:43 +0100
commit1d9049ab9963b69a6716943109ec0a7458135d1a (patch)
tree086df02d8bf9fa707f0cd5c36b22c094c84ce5f7 /src/util/test_payto.c
parent2edee5ac4a4886e71db6e28314334cd24c6d3a55 (diff)
downloadexchange-1d9049ab9963b69a6716943109ec0a7458135d1a.tar.gz
exchange-1d9049ab9963b69a6716943109ec0a7458135d1a.tar.bz2
exchange-1d9049ab9963b69a6716943109ec0a7458135d1a.zip
add payto URL test, fix payto parser implementation
Diffstat (limited to 'src/util/test_payto.c')
-rw-r--r--src/util/test_payto.c44
1 files changed, 43 insertions, 1 deletions
diff --git a/src/util/test_payto.c b/src/util/test_payto.c
index 80bf652e0..f966e046f 100644
--- a/src/util/test_payto.c
+++ b/src/util/test_payto.c
@@ -21,13 +21,55 @@
#include "platform.h"
#include "taler_util.h"
+#define CHECK(a,b) do { \
+ if (0 != strcmp (a,b)) { \
+ GNUNET_break (0); \
+ fprintf (stderr, "Got %s, wanted %s\n", b, a); \
+ GNUNET_free (b); \
+ return 1; \
+ } else { \
+ GNUNET_free (b); \
+ } \
+} while (0)
+
int
main (int argc,
const char *const argv[])
{
+ char *r;
-
+ GNUNET_log_setup ("test-payto",
+ "WARNING",
+ NULL);
+ r = TALER_payto_xtalerbank_make ("https://localhost/",
+ "account");
+ CHECK ("payto://x-taler-bank/localhost/account",
+ r);
+ r = TALER_payto_xtalerbank_make ("http://localhost:80/",
+ "account");
+ CHECK ("payto://x-taler-bank/localhost:80/account",
+ r);
+ r = TALER_payto_xtalerbank_make ("http://localhost/",
+ "account");
+ CHECK ("payto://x-taler-bank/localhost:80/account",
+ r);
+ r = TALER_xtalerbank_base_url_from_payto (
+ "payto://x-taler-bank/localhost/bob");
+ CHECK ("https://localhost/",
+ r);
+ r = TALER_xtalerbank_base_url_from_payto (
+ "payto://x-taler-bank/localhost:1080/bob");
+ CHECK ("http://localhost:1080/",
+ r);
+ r = TALER_xtalerbank_account_url_from_payto (
+ "payto://x-taler-bank/localhost/bob");
+ CHECK ("https://localhost/bob",
+ r);
+ r = TALER_xtalerbank_account_url_from_payto (
+ "payto://x-taler-bank/localhost:1080/alice");
+ CHECK ("http://localhost:1080/alice",
+ r);
return 0;
}