aboutsummaryrefslogtreecommitdiff
path: root/tests/unit
diff options
context:
space:
mode:
authorDan Fandrich <dan@coneharvesters.com>2014-01-28 23:23:24 +0100
committerDan Fandrich <dan@coneharvesters.com>2014-01-28 23:27:22 +0100
commit00b1e52823d5914b606b3f70eb58a1eaa15e35cd (patch)
tree7376e7b11051b403a24f39545c11c5dc24a1abbc /tests/unit
parent31860ab8c83b35b21f331c85e4535b08b13dc8f9 (diff)
unit1396: make the test pass the OOM torture tests
Diffstat (limited to 'tests/unit')
-rw-r--r--tests/unit/unit1396.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/tests/unit/unit1396.c b/tests/unit/unit1396.c
index 797443dec..b18d7a8e2 100644
--- a/tests/unit/unit1396.c
+++ b/tests/unit/unit1396.c
@@ -21,6 +21,8 @@
***************************************************************************/
#include "curlcheck.h"
+CURL *hnd;
+
static CURLcode unit_setup(void)
{
return CURLE_OK;
@@ -28,6 +30,8 @@ static CURLcode unit_setup(void)
static void unit_stop(void)
{
+ if (hnd)
+ curl_easy_cleanup(hnd);
}
struct test {
@@ -40,7 +44,7 @@ struct test {
UNITTEST_START
{
/* unescape, this => that */
- struct test list1[]={
+ const struct test list1[]={
{"%61", 3, "a", 1},
{"%61a", 4, "aa", 2},
{"%61b", 4, "ab", 2},
@@ -56,7 +60,7 @@ UNITTEST_START
{NULL, 0, NULL, 0} /* end of list marker */
};
/* escape, this => that */
- struct test list2[]={
+ const struct test list2[]={
{"a", 1, "a", 1},
{"/", 1, "%2F", 3},
{"a=b", 3, "a%3Db", 5},
@@ -70,16 +74,16 @@ UNITTEST_START
{NULL, 0, NULL, 0} /* end of list marker */
};
int i;
- CURL *hnd;
hnd = curl_easy_init();
+ abort_unless(hnd != NULL, "returned NULL!");
for(i=0; list1[i].in; i++) {
int outlen;
char *out = curl_easy_unescape(hnd,
list1[i].in, list1[i].inlen,
&outlen);
- fail_unless(out != NULL, "returned NULL!");
+ abort_unless(out != NULL, "returned NULL!");
fail_unless(outlen == list1[i].outlen, "wrong output length returned");
fail_unless(!memcmp(out, list1[i].out, list1[i].outlen),
"bad output data returned");
@@ -90,10 +94,11 @@ UNITTEST_START
}
for(i=0; list2[i].in; i++) {
+ int outlen;
char *out = curl_easy_escape(hnd, list2[i].in, list2[i].inlen);
- int outlen = (int)strlen(out);
+ abort_unless(out != NULL, "returned NULL!");
- fail_unless(out != NULL, "returned NULL!");
+ outlen = (int)strlen(out);
fail_unless(outlen == list2[i].outlen, "wrong output length returned");
fail_unless(!memcmp(out, list2[i].out, list2[i].outlen),
"bad output data returned");
@@ -102,8 +107,5 @@ UNITTEST_START
curl_free(out);
}
-
- curl_easy_cleanup(hnd);
-
}
UNITTEST_STOP