Browse Source

Add unit tests

bel2125 5 năm trước cách đây
mục cha
commit
5f712d31ac
2 tập tin đã thay đổi với 26 bổ sung8 xóa
  1. 18 0
      unittest/private.c
  2. 8 8
      unittest/public_server.c

+ 18 - 0
unittest/private.c

@@ -350,6 +350,10 @@ START_TEST(test_remove_dot_segments)
 	             {".file.ext", ".file.ext"},
 	             {"..file.ext", "..file.ext"},
 	             {"file", "file"},
+	             {"/x/../", "/"},
+	             {"/x/../../", "/"},
+	             {"/x/.././", "/"},
+	             {"/./x/.././", "/"},
 
 	             /* Windows specific */
 	             {"\\file.ext", "/file.ext"},
@@ -357,6 +361,20 @@ START_TEST(test_remove_dot_segments)
 	             {"/file.", "/file"},
 	             {"/path\\to.\\.\\file.", "/path/to/file"},
 
+	             /* Multiple dots and slashes */
+	             {"\\//\\\\x", "/x"},
+	             {"//", "/"},
+	             {"/./", "/"},
+	             {"/../", "/"},
+	             {"/.../", "/"},
+	             {"/..../", "/"},
+	             {"/...../", "/"},
+	             {"/...../", "/"},
+	             {"/...//", "/"},
+	             {"/..././", "/"},
+	             {"/.../../", "/"},
+	             {"/.../.../", "/"},
+
 	             {NULL, NULL}};
 
 	mark_point();

+ 8 - 8
unittest/public_server.c

@@ -4671,14 +4671,14 @@ minimal_http_https_client_impl(const char *server,
 	ck_assert(client_ri != NULL);
 
 	/* Check for status code 200 OK or 30? moved */
-	if ((client_ri->status_code != 200) && (client_ri->status_code / 10 != 30)) {
-		ck_abort_msg(
-		    "Request to %s://%s:%u/%s: Status %u",
-		    use_ssl ? "HTTPS" : "HTTP",
-		    server,
-		    port,
-			uri,
-			client_ri->status_code);
+	if ((client_ri->status_code != 200)
+	    && (client_ri->status_code / 10 != 30)) {
+		ck_abort_msg("Request to %s://%s:%u/%s: Status %u",
+		             use_ssl ? "HTTPS" : "HTTP",
+		             server,
+		             port,
+		             uri,
+		             client_ri->status_code);
 	}
 
 	data_read = 0;