浏览代码

Unit test for set_request_handler (incomplete)

bel 10 年之前
父节点
当前提交
b2bdb79200
共有 1 个文件被更改,包括 26 次插入0 次删除
  1. 26 0
      test/unit_test.c

+ 26 - 0
test/unit_test.c

@@ -879,6 +879,31 @@ static void test_request_replies(void) {
 #endif
 }
 
+static int request_test_handler(struct mg_connection *conn, void *cbdata)
+{
+    ASSERT(0);
+}
+
+
+static void test_request_handlers(void) {
+
+    /* TODO */
+    struct mg_context *ctx;
+    char uri[64];
+    int i;
+    
+    ctx = mg_start(NULL, NULL, OPTIONS);
+    ASSERT(ctx != NULL);
+
+    for (i=0;i<1000;i++) {
+        sprintf(uri, "U%u", i);
+        mg_set_request_handler(ctx, uri, request_test_handler, NULL);
+    }
+
+    mg_stop(ctx);
+
+}
+
 static int api_callback(struct mg_connection *conn) {
     struct mg_request_info *ri = mg_get_request_info(conn);
     char post_data[100] = "";
@@ -1115,6 +1140,7 @@ int __cdecl main(void) {
     test_mg_upload();
     test_request_replies();
     test_api_calls();
+    test_request_handlers();
 
 #if defined(USE_LUA)
     test_lua();