diff options
author | Martin Schanzenbach <mschanzenbach@posteo.de> | 2020-08-01 16:07:08 +0200 |
---|---|---|
committer | Martin Schanzenbach <mschanzenbach@posteo.de> | 2020-08-01 16:07:08 +0200 |
commit | 754d8c1b496624e5c879af7d142fc9fd34de3a21 (patch) | |
tree | c8fbe2e357c37de4dcabdaaae790fb5f83bdd40c /src/util/test_strings.c | |
parent | 7f4ddbcab8598e3d5e29c23ce883cdfa664408f1 (diff) | |
download | gnunet-754d8c1b496624e5c879af7d142fc9fd34de3a21.tar.gz gnunet-754d8c1b496624e5c879af7d142fc9fd34de3a21.zip |
util: add percent/url encoding
Diffstat (limited to 'src/util/test_strings.c')
-rw-r--r-- | src/util/test_strings.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/util/test_strings.c b/src/util/test_strings.c index 90d06a473..28b1bb6f8 100644 --- a/src/util/test_strings.c +++ b/src/util/test_strings.c | |||
@@ -39,6 +39,10 @@ | |||
39 | #define WANTB(a, b, l) if (0 != memcmp (a, b, l)) { GNUNET_break (0); return 1; \ | 39 | #define WANTB(a, b, l) if (0 != memcmp (a, b, l)) { GNUNET_break (0); return 1; \ |
40 | } else { } | 40 | } else { } |
41 | 41 | ||
42 | #define URLENCODE_TEST_VECTOR_PLAIN "Asbjlaw=ljsdlasjd?aslkdsa" | ||
43 | |||
44 | #define URLENCODE_TEST_VECTOR_ENCODED "Asbjlaw\%3Dljsdlasjd\%3Faslkdsa" | ||
45 | |||
42 | int | 46 | int |
43 | main (int argc, char *argv[]) | 47 | main (int argc, char *argv[]) |
44 | { | 48 | { |
@@ -137,6 +141,16 @@ main (int argc, char *argv[]) | |||
137 | GNUNET_STRINGS_fancy_time_to_relative ("15 m", &rtx)); | 141 | GNUNET_STRINGS_fancy_time_to_relative ("15 m", &rtx)); |
138 | GNUNET_assert (rt.rel_value_us == rtx.rel_value_us); | 142 | GNUNET_assert (rt.rel_value_us == rtx.rel_value_us); |
139 | 143 | ||
144 | GNUNET_assert (0 != GNUNET_STRINGS_urlencode (URLENCODE_TEST_VECTOR_PLAIN, | ||
145 | strlen (URLENCODE_TEST_VECTOR_PLAIN), | ||
146 | &b)); | ||
147 | WANT (URLENCODE_TEST_VECTOR_ENCODED, b); | ||
148 | GNUNET_free (b); | ||
149 | GNUNET_assert (0 != GNUNET_STRINGS_urldecode (URLENCODE_TEST_VECTOR_ENCODED, | ||
150 | strlen (URLENCODE_TEST_VECTOR_ENCODED), | ||
151 | &b)); | ||
152 | WANT (URLENCODE_TEST_VECTOR_PLAIN, b); | ||
153 | GNUNET_free (b); | ||
140 | return 0; | 154 | return 0; |
141 | } | 155 | } |
142 | 156 | ||