Commit 9c485347 authored by Sergey Lyubka's avatar Sergey Lyubka

Added stub for test_mg_upload()

parent 81e21a3a
...@@ -175,12 +175,19 @@ static void *event_handler(enum mg_event event, struct mg_connection *conn) { ...@@ -175,12 +175,19 @@ static void *event_handler(enum mg_event event, struct mg_connection *conn) {
return NULL; return NULL;
} }
static void test_mg_fetch(void) { static const char *OPTIONS[] = {
static const char *options[] = {
"document_root", ".", "document_root", ".",
"listening_ports", LISTENING_ADDR, "listening_ports", LISTENING_ADDR,
NULL, NULL,
}; };
static void test_mg_upload(void) {
struct mg_context *ctx;
ASSERT((ctx = mg_start(event_handler, NULL, OPTIONS)) != NULL);
mg_stop(ctx);
}
static void test_mg_fetch(void) {
char buf[2000], buf2[2000]; char buf[2000], buf2[2000];
int n, length; int n, length;
struct mg_context *ctx; struct mg_context *ctx;
...@@ -189,7 +196,7 @@ static void test_mg_fetch(void) { ...@@ -189,7 +196,7 @@ static void test_mg_fetch(void) {
struct file file; struct file file;
FILE *fp; FILE *fp;
ASSERT((ctx = mg_start(event_handler, NULL, options)) != NULL); ASSERT((ctx = mg_start(event_handler, NULL, OPTIONS)) != NULL);
// Failed fetch, pass invalid URL // Failed fetch, pass invalid URL
ASSERT(mg_fetch(ctx, "localhost", tmp_file, buf, sizeof(buf), &ri) == NULL); ASSERT(mg_fetch(ctx, "localhost", tmp_file, buf, sizeof(buf), &ri) == NULL);
...@@ -369,10 +376,9 @@ static void *user_data_tester(enum mg_event event, struct mg_connection *conn) { ...@@ -369,10 +376,9 @@ static void *user_data_tester(enum mg_event event, struct mg_connection *conn) {
} }
static void test_user_data(void) { static void test_user_data(void) {
static const char *options[] = {"listening_ports", LISTENING_ADDR, NULL};
struct mg_context *ctx; struct mg_context *ctx;
ASSERT((ctx = mg_start(user_data_tester, (void *) 123, options)) != NULL); ASSERT((ctx = mg_start(user_data_tester, (void *) 123, OPTIONS)) != NULL);
ASSERT(ctx->user_data == (void *) 123); ASSERT(ctx->user_data == (void *) 123);
call_user(fc(ctx), MG_NEW_REQUEST); call_user(fc(ctx), MG_NEW_REQUEST);
mg_stop(ctx); mg_stop(ctx);
...@@ -380,8 +386,7 @@ static void test_user_data(void) { ...@@ -380,8 +386,7 @@ static void test_user_data(void) {
static void test_mg_stat(void) { static void test_mg_stat(void) {
static struct mg_context ctx; static struct mg_context ctx;
struct file file; struct file file = STRUCT_FILE_INITIALIZER;
memset(&file, 'A', sizeof(file));
ASSERT(!mg_stat(fc(&ctx), " does not exist ", &file)); ASSERT(!mg_stat(fc(&ctx), " does not exist ", &file));
} }
...@@ -415,6 +420,7 @@ int __cdecl main(void) { ...@@ -415,6 +420,7 @@ int __cdecl main(void) {
test_next_option(); test_next_option();
test_user_data(); test_user_data();
test_mg_stat(); test_mg_stat();
test_mg_upload();
#ifdef USE_LUA #ifdef USE_LUA
test_lua(); test_lua();
#endif #endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment