add more test_io_http_stream_parse_chunk_header_invalid tests

Thu, 15 Aug 2024 22:42:35 +0200

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Thu, 15 Aug 2024 22:42:35 +0200
changeset 550
77241b3ba544
parent 549
b26bec196a2e
child 551
97039494764b

add more test_io_http_stream_parse_chunk_header_invalid tests

src/server/test/io.c file | annotate | diff | comparison | revisions
--- a/src/server/test/io.c	Thu Aug 15 22:38:03 2024 +0200
+++ b/src/server/test/io.c	Thu Aug 15 22:42:35 2024 +0200
@@ -179,6 +179,12 @@
     size_t len2 = strlen(str2);
     char *str3 = strdup("\r\n\r\n123\r\n");
     size_t len3 = strlen(str3);
+    char *str4 = strdup("\r\n\r\nx123\r\n");
+    size_t len4 = strlen(str3);
+    char *str5 = strdup("\r\n\r\n1 2 3\r\n");
+    size_t len5 = strlen(str3);
+    char *str6 = strdup("\r\n\r\n1 23\r\n");
+    size_t len6 = strlen(str3);
     
     UCX_TEST_BEGIN;
     
@@ -199,11 +205,29 @@
     UCX_TEST_ASSERT(ret == -1, "ret != -1 (test 3a)");
     ret = http_stream_parse_chunk_header(str3, len3, FALSE, &chunklen);
     UCX_TEST_ASSERT(ret == -1, "ret != -1 (test 3b)");
+    
+    ret = http_stream_parse_chunk_header(str4, len4, TRUE, &chunklen);
+    UCX_TEST_ASSERT(ret == -1, "ret != -1 (test 4a)");
+    ret = http_stream_parse_chunk_header(str4, len4, FALSE, &chunklen);
+    UCX_TEST_ASSERT(ret == -1, "ret != -1 (test 4b)");
+    
+    ret = http_stream_parse_chunk_header(str5, len5, TRUE, &chunklen);
+    UCX_TEST_ASSERT(ret == -1, "ret != -1 (test 5a)");
+    ret = http_stream_parse_chunk_header(str5, len5, FALSE, &chunklen);
+    UCX_TEST_ASSERT(ret == -1, "ret != -1 (test 5b)");
+    
+    ret = http_stream_parse_chunk_header(str6, len6, TRUE, &chunklen);
+    UCX_TEST_ASSERT(ret == -1, "ret != -1 (test 6a)");
+    ret = http_stream_parse_chunk_header(str6, len6, FALSE, &chunklen);
+    UCX_TEST_ASSERT(ret == -1, "ret != -1 (test 6b)");
             
     UCX_TEST_END;
     free(str);
     free(str2);
     free(str3);
+    free(str4);
+    free(str5);
+    free(str6);
 }
 
 UCX_TEST(test_io_http_stream_parse_chunk_header_zero) {

mercurial