mirror of
https://github.com/cesanta/mongoose.git
synced 2026-12-05 22:08:23 +00:00
Added stub for test_mg_upload()
This commit is contained in:
1 parent
81e21a3a0b
commit
9c4853471c
1 file changed
+16
-10
+16
-10
@@ -175,12 +175,19 @@ static void *event_handler(enum mg_event event, struct mg_connection *conn) {
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const char *OPTIONS[] = {
|
||||||
|
"document_root", ".",
|
||||||
|
"listening_ports", LISTENING_ADDR,
|
||||||
|
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) {
|
static void test_mg_fetch(void) {
|
||||||
static const char *options[] = {
|
|
||||||
"document_root", ".",
|
|
||||||
"listening_ports", LISTENING_ADDR,
|
|
||||||
NULL,
|
|
||||||
};
|
|
||||||
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) {
|
|||||||
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) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
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) {
|
|||||||
|
|
||||||
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) {
|
|||||||
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
|
||||||
|
|||||||
Reference in new issue
Block a user