-#define SQUID_UNIT_TEST 1
-#include "config.h"
-
-#if HAVE_ASSERT_H
-#include <assert.h>
-#endif
+/*
+ * Copyright (C) 1996-2017 The Squid Software Foundation and contributors
+ *
+ * Squid software is distributed under GPLv2+ license and includes
+ * contributions from numerous individuals and organizations.
+ * Please see the COPYING and CONTRIBUTORS files for details.
+ */
+#include "squid.h"
#include "testRFC1738.h"
+#include "unitTestMain.h"
+
+#include <cassert>
/* Being a C library code it is best bodily included and tested with C++ type-safe techniques. */
#include "lib/rfc1738.c"
CPPUNIT_ASSERT(memcmp(unescaped_str, "Bad String %1",14)==0);
xfree(unescaped_str);
-
/* A partly corrupt string */
unescaped_str = xstrdup("Bad String %1A%3");
rfc1738_unescape(unescaped_str);
result = rfc1738_do_escape("################ ################ ################ ################ ################ ################ ################ ################", RFC1738_ESCAPE_UNSAFE);
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);
-
/* TEST: escaping only reserved characters */
/* regular URL (full encoding requested) */
result = rfc1738_do_escape("/data/source/path", RFC1738_ESCAPE_RESERVED);
CPPUNIT_ASSERT(memcmp(result, "%2Fdata%2Fsource%2Fpath",24)==0);
-
/* TEST: safety-escaping a string already partially escaped */
/* escaping of dangerous characters in a partially escaped string */
CPPUNIT_ASSERT(memcmp(unescaped_str, "w%%00%rd",9)==0);
xfree(unescaped_str);
}
+