Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
mongoose
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
esp
mongoose
Commits
d8596fae
Commit
d8596fae
authored
Aug 19, 2013
by
Sergey Lyubka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed unit test
parent
85209ac4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
11 deletions
+11
-11
unit_test.c
test/unit_test.c
+11
-11
No files found.
test/unit_test.c
View file @
d8596fae
...
...
@@ -223,7 +223,7 @@ static void upload_cb(struct mg_connection *conn, const char *path) {
if
(
atoi
(
ri
->
query_string
)
==
1
)
{
ASSERT
(
!
strcmp
(
path
,
"./upload_test.txt"
));
ASSERT
((
p1
=
read_file
(
"m
ongoose
.c"
,
&
len1
))
!=
NULL
);
ASSERT
((
p1
=
read_file
(
"m
ain
.c"
,
&
len1
))
!=
NULL
);
ASSERT
((
p2
=
read_file
(
path
,
&
len2
))
!=
NULL
);
ASSERT
(
len1
==
len2
);
ASSERT
(
memcmp
(
p1
,
p2
,
len1
)
==
0
);
...
...
@@ -231,14 +231,14 @@ static void upload_cb(struct mg_connection *conn, const char *path) {
remove
(
upload_filename
);
}
else
if
(
atoi
(
ri
->
query_string
)
==
2
)
{
if
(
!
strcmp
(
path
,
"./upload_test.txt"
))
{
ASSERT
((
p1
=
read_file
(
"
mongoose
.h"
,
&
len1
))
!=
NULL
);
ASSERT
((
p1
=
read_file
(
"
lua_5.2.1
.h"
,
&
len1
))
!=
NULL
);
ASSERT
((
p2
=
read_file
(
path
,
&
len2
))
!=
NULL
);
ASSERT
(
len1
==
len2
);
ASSERT
(
memcmp
(
p1
,
p2
,
len1
)
==
0
);
free
(
p1
),
free
(
p2
);
remove
(
upload_filename
);
}
else
if
(
!
strcmp
(
path
,
"./upload_test2.txt"
))
{
ASSERT
((
p1
=
read_file
(
"
README.md
"
,
&
len1
))
!=
NULL
);
ASSERT
((
p1
=
read_file
(
"
mod_lua.c
"
,
&
len1
))
!=
NULL
);
ASSERT
((
p2
=
read_file
(
path
,
&
len2
))
!=
NULL
);
ASSERT
(
len1
==
len2
);
ASSERT
(
memcmp
(
p1
,
p2
,
len1
)
==
0
);
...
...
@@ -282,14 +282,14 @@ static int log_message_cb(const struct mg_connection *conn, const char *msg) {
static
const
struct
mg_callbacks
CALLBACKS
=
{
&
begin_request_handler_cb
,
NULL
,
&
log_message_cb
,
NULL
,
NULL
,
NULL
,
NULL
,
&
open_file_cb
,
NULL
,
&
upload_cb
,
NULL
&
open_file_cb
,
NULL
,
&
upload_cb
};
static
const
char
*
OPTIONS
[]
=
{
"document_root"
,
"."
,
"listening_ports"
,
LISTENING_ADDR
,
"enable_keep_alive"
,
"yes"
,
"ssl_certificate"
,
"
build/
ssl_cert.pem"
,
"ssl_certificate"
,
"ssl_cert.pem"
,
NULL
,
};
...
...
@@ -328,12 +328,12 @@ static void test_mg_download(void) {
"GET / HTTP/1.0
\r\n\r\n
"
))
!=
NULL
);
mg_close_connection
(
conn
);
// Fetch m
ongoose
.c, should succeed
// Fetch m
ain
.c, should succeed
ASSERT
((
conn
=
mg_download
(
"localhost"
,
port
,
1
,
ebuf
,
sizeof
(
ebuf
),
"%s"
,
"GET /m
ongoose
.c HTTP/1.0
\r\n\r\n
"
))
!=
NULL
);
"GET /m
ain
.c HTTP/1.0
\r\n\r\n
"
))
!=
NULL
);
ASSERT
(
!
strcmp
(
conn
->
request_info
.
uri
,
"200"
));
ASSERT
((
p1
=
read_conn
(
conn
,
&
len1
))
!=
NULL
);
ASSERT
((
p2
=
read_file
(
"m
ongoose
.c"
,
&
len2
))
!=
NULL
);
ASSERT
((
p2
=
read_file
(
"m
ain
.c"
,
&
len2
))
!=
NULL
);
ASSERT
(
len1
==
len2
);
ASSERT
(
memcmp
(
p1
,
p2
,
len1
)
==
0
);
free
(
p1
),
free
(
p2
);
...
...
@@ -395,7 +395,7 @@ static void test_mg_upload(void) {
ASSERT
((
ctx
=
mg_start
(
&
CALLBACKS
,
NULL
,
OPTIONS
))
!=
NULL
);
// Upload one file
ASSERT
((
file_data
=
read_file
(
"m
ongoose
.c"
,
&
file_len
))
!=
NULL
);
ASSERT
((
file_data
=
read_file
(
"m
ain
.c"
,
&
file_len
))
!=
NULL
);
post_data
=
NULL
;
post_data_len
=
alloc_printf
(
&
post_data
,
0
,
"--%s
\r\n
"
...
...
@@ -421,8 +421,8 @@ static void test_mg_upload(void) {
mg_close_connection
(
conn
);
// Upload two files
ASSERT
((
file_data
=
read_file
(
"
mongoose
.h"
,
&
file_len
))
!=
NULL
);
ASSERT
((
file2_data
=
read_file
(
"
README.md
"
,
&
file2_len
))
!=
NULL
);
ASSERT
((
file_data
=
read_file
(
"
lua_5.2.1
.h"
,
&
file_len
))
!=
NULL
);
ASSERT
((
file2_data
=
read_file
(
"
mod_lua.c
"
,
&
file2_len
))
!=
NULL
);
post_data
=
NULL
;
post_data_len
=
alloc_printf
(
&
post_data
,
0
,
// First file
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment