13#include <cppunit/extensions/HelperMacros.h>
46 unescaped_str =
xstrdup(
"%2Fdata%2Fsource%2Fpath");
48 CPPUNIT_ASSERT(memcmp(unescaped_str,
"/data/source/path",18)==0);
52 unescaped_str =
xstrdup(
"http://foo.invalid%2Fdata%2Fsource%2Fpath");
54 CPPUNIT_ASSERT(memcmp(unescaped_str,
"http://foo.invalid/data/source/path",36)==0);
60 unescaped_str =
xstrdup(
"w%0Ard");
62 CPPUNIT_ASSERT(memcmp(unescaped_str,
"w\nrd",5)==0);
66 unescaped_str =
xstrdup(
"w%rd");
68 CPPUNIT_ASSERT(memcmp(unescaped_str,
"w%rd",5)==0);
72 unescaped_str =
xstrdup(
"w%%rd");
74 CPPUNIT_ASSERT(memcmp(unescaped_str,
"w%rd",5)==0);
78 unescaped_str =
xstrdup(
"w%%%rd");
80 CPPUNIT_ASSERT(memcmp(unescaped_str,
"w%%rd",6)==0);
84 unescaped_str =
xstrdup(
"Bad String %1");
86 CPPUNIT_ASSERT(memcmp(unescaped_str,
"Bad String %1",14)==0);
90 unescaped_str =
xstrdup(
"Bad String %1A%3");
92 CPPUNIT_ASSERT(memcmp(unescaped_str,
"Bad String \032%3",15)==0);
96 unescaped_str =
xstrdup(
"Good String %1A");
98 CPPUNIT_ASSERT(memcmp(unescaped_str,
"Good String \032",14)==0);
118 CPPUNIT_ASSERT(memcmp(result,
"http://foo.invalid/data/source/path",36)==0);
121 result =
rfc1738_do_escape(
"################ ################ ################ ################ ################ ################ ################ ################",
RFC1738_ESCAPE_UNSAFE);
122 CPPUNIT_ASSERT(memcmp(result,
"%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%20%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%20%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%20%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%20%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%20%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%20%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%20%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23",406)==0);
128 CPPUNIT_ASSERT(memcmp(result,
"http%3A%2F%2Ffoo.invalid%2Fdata%2Fsource%2Fpath",48)==0);
132 CPPUNIT_ASSERT(memcmp(result,
"%2Fdata%2Fsource%2Fpath",24)==0);
138 CPPUNIT_ASSERT(memcmp(result,
"http://foo.invalid/data%2Fsource%5B%5D",39)==0);
142 CPPUNIT_ASSERT(memcmp(result,
"http://foo.invalid/data%2Fsource%FF%FF",39)==0);
152 unescaped_str =
xstrdup(
"w%00rd");
154 CPPUNIT_ASSERT(memcmp(unescaped_str,
"w%00rd",7)==0);
155 xfree(unescaped_str);
158 unescaped_str =
xstrdup(
"w%0rd");
160 CPPUNIT_ASSERT(memcmp(unescaped_str,
"w%0rd",6)==0);
161 xfree(unescaped_str);
164 unescaped_str =
xstrdup(
"w%%00%rd");
166 CPPUNIT_ASSERT(memcmp(unescaped_str,
"w%00%rd",8)==0);
167 xfree(unescaped_str);
170 unescaped_str =
xstrdup(
"w%%%00%rd");
172 CPPUNIT_ASSERT(memcmp(unescaped_str,
"w%%00%rd",9)==0);
173 xfree(unescaped_str);
implements test program's main() function while enabling customization
int run(int argc, char *argv[])
CPPUNIT_TEST(testUrlDecode)
CPPUNIT_TEST(testUrlEncode)
CPPUNIT_TEST_SUITE(TestRfc1738)
CPPUNIT_TEST(PercentZeroNullDecoding)
void PercentZeroNullDecoding()
#define RFC1738_ESCAPE_UNSAFE
char * rfc1738_do_escape(const char *url, int flags)
#define RFC1738_ESCAPE_UNESCAPED
#define RFC1738_ESCAPE_RESERVED
void rfc1738_unescape(char *url)
int main(int argc, char *argv[])
CPPUNIT_TEST_SUITE_REGISTRATION(TestRfc1738)