aboutsummaryrefslogtreecommitdiff
path: root/src/microhttpd/test_postprocessor.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/microhttpd/test_postprocessor.c')
-rw-r--r--src/microhttpd/test_postprocessor.c38
1 files changed, 24 insertions, 14 deletions
diff --git a/src/microhttpd/test_postprocessor.c b/src/microhttpd/test_postprocessor.c
index 9a5977bc..ab68541b 100644
--- a/src/microhttpd/test_postprocessor.c
+++ b/src/microhttpd/test_postprocessor.c
@@ -87,14 +87,24 @@ struct expResult exp_results[] = {
87#define URL_ENC_END (URL_ENC_START + 4) 87#define URL_ENC_END (URL_ENC_START + 4)
88 {NULL, NULL, NULL, NULL, NULL}, 88 {NULL, NULL, NULL, NULL, NULL},
89#define FORM_DATA \ 89#define FORM_DATA \
90 "--AaB03x\r\ncontent-disposition: form-data; name=\"field1\"\r\n\r\nJoe Blow\r\n--AaB03x\r\ncontent-disposition: form-data; name=\"pics\"; filename=\"file1.txt\"\r\nContent-Type: text/plain\r\nContent-Transfer-Encoding: binary\r\n\r\nfiledata\r\n--AaB03x--\r\n" 90 "--AaB03x\r\ncontent-disposition: form-data; name=\"field1\"\r\n\r\n" \
91 "Joe Blow\r\n--AaB03x\r\ncontent-disposition: form-data; name=\"pics\";" \
92 " filename=\"file1.txt\"\r\nContent-Type: text/plain\r\n" \
93 "Content-Transfer-Encoding: binary\r\n\r\nfiledata\r\n--AaB03x--\r\n"
91#define FORM_START (URL_ENC_END + 1) 94#define FORM_START (URL_ENC_END + 1)
92 {"field1", NULL, NULL, NULL, "Joe Blow"}, 95 {"field1", NULL, NULL, NULL, "Joe Blow"},
93 {"pics", "file1.txt", "text/plain", "binary", "filedata"}, 96 {"pics", "file1.txt", "text/plain", "binary", "filedata"},
94#define FORM_END (FORM_START + 2) 97#define FORM_END (FORM_START + 2)
95 {NULL, NULL, NULL, NULL, NULL}, 98 {NULL, NULL, NULL, NULL, NULL},
96#define FORM_NESTED_DATA \ 99#define FORM_NESTED_DATA \
97 "--AaB03x\r\ncontent-disposition: form-data; name=\"field1\"\r\n\r\nJane Blow\r\n--AaB03x\r\ncontent-disposition: form-data; name=\"pics\"\r\nContent-type: multipart/mixed, boundary=BbC04y\r\n\r\n--BbC04y\r\nContent-disposition: attachment; filename=\"file1.txt\"\r\nContent-Type: text/plain\r\n\r\nfiledata1\r\n--BbC04y\r\nContent-disposition: attachment; filename=\"file2.gif\"\r\nContent-type: image/gif\r\nContent-Transfer-Encoding: binary\r\n\r\nfiledata2\r\n--BbC04y--\r\n--AaB03x--" 100 "--AaB03x\r\ncontent-disposition: form-data; name=\"field1\"\r\n\r\n" \
101 "Jane Blow\r\n--AaB03x\r\ncontent-disposition: form-data; name=\"pics\"\r\n" \
102 "Content-type: multipart/mixed, boundary=BbC04y\r\n\r\n--BbC04y\r\n" \
103 "Content-disposition: attachment; filename=\"file1.txt\"\r\n" \
104 "Content-Type: text/plain\r\n\r\nfiledata1\r\n--BbC04y\r\n" \
105 "Content-disposition: attachment; filename=\"file2.gif\"\r\n" \
106 "Content-type: image/gif\r\nContent-Transfer-Encoding: binary\r\n\r\n" \
107 "filedata2\r\n--BbC04y--\r\n--AaB03x--"
98#define FORM_NESTED_START (FORM_END + 1) 108#define FORM_NESTED_START (FORM_END + 1)
99 {"field1", NULL, NULL, NULL, "Jane Blow"}, 109 {"field1", NULL, NULL, NULL, "Jane Blow"},
100 {"pics", "file1.txt", "text/plain", NULL, "filedata1"}, 110 {"pics", "file1.txt", "text/plain", NULL, "filedata1"},
@@ -210,13 +220,13 @@ value_checker (void *cls,
210} 220}
211 221
212 222
213static int 223static unsigned int
214test_urlencoding_case (unsigned int want_start, 224test_urlencoding_case (unsigned int want_start,
215 unsigned int want_end, 225 unsigned int want_end,
216 const char *url_data) 226 const char *url_data)
217{ 227{
218 size_t step; 228 size_t step;
219 int errors = 0; 229 unsigned int errors = 0;
220 const size_t size = strlen (url_data); 230 const size_t size = strlen (url_data);
221 231
222 for (step = 1; size >= step; ++step) 232 for (step = 1; size >= step; ++step)
@@ -278,7 +288,7 @@ test_urlencoding_case (unsigned int want_start,
278} 288}
279 289
280 290
281static int 291static unsigned int
282test_urlencoding (void) 292test_urlencoding (void)
283{ 293{
284 unsigned int errorCount = 0; 294 unsigned int errorCount = 0;
@@ -357,7 +367,7 @@ test_urlencoding (void)
357} 367}
358 368
359 369
360static int 370static unsigned int
361test_multipart_garbage (void) 371test_multipart_garbage (void)
362{ 372{
363 struct MHD_Connection connection; 373 struct MHD_Connection connection;
@@ -425,7 +435,7 @@ test_multipart_garbage (void)
425} 435}
426 436
427 437
428static int 438static unsigned int
429test_multipart_splits (void) 439test_multipart_splits (void)
430{ 440{
431 struct MHD_Connection connection; 441 struct MHD_Connection connection;
@@ -487,7 +497,7 @@ test_multipart_splits (void)
487} 497}
488 498
489 499
490static int 500static unsigned int
491test_multipart (void) 501test_multipart (void)
492{ 502{
493 struct MHD_Connection connection; 503 struct MHD_Connection connection;
@@ -544,7 +554,7 @@ test_multipart (void)
544} 554}
545 555
546 556
547static int 557static unsigned int
548test_nested_multipart (void) 558test_nested_multipart (void)
549{ 559{
550 struct MHD_Connection connection; 560 struct MHD_Connection connection;
@@ -619,8 +629,8 @@ value_checker2 (void *cls,
619} 629}
620 630
621 631
622static int 632static unsigned int
623test_overflow () 633test_overflow (void)
624{ 634{
625 struct MHD_Connection connection; 635 struct MHD_Connection connection;
626 struct MHD_HTTP_Req_Header header; 636 struct MHD_HTTP_Req_Header header;
@@ -675,7 +685,7 @@ test_overflow ()
675} 685}
676 686
677 687
678static int 688static unsigned int
679test_empty_key (void) 689test_empty_key (void)
680{ 690{
681 const char form_data[] = "=abcdef"; 691 const char form_data[] = "=abcdef";
@@ -726,7 +736,7 @@ test_empty_key (void)
726} 736}
727 737
728 738
729static int 739static unsigned int
730test_double_value (void) 740test_double_value (void)
731{ 741{
732 const char form_data[] = URL_DATA "=abcdef"; 742 const char form_data[] = URL_DATA "=abcdef";
@@ -822,5 +832,5 @@ main (int argc, char *const *argv)
822 errorCount += test_overflow (); 832 errorCount += test_overflow ();
823 if (errorCount != 0) 833 if (errorCount != 0)
824 fprintf (stderr, "Error (code: %u)\n", errorCount); 834 fprintf (stderr, "Error (code: %u)\n", errorCount);
825 return errorCount != 0; /* 0 == pass */ 835 return (errorCount == 0) ? 0 : 1; /* 0 == pass */
826} 836}