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
84e26ccd
Commit
84e26ccd
authored
Jul 29, 2012
by
Sergey Lyubka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More tests for mg_fetch()
parent
e6bb39a2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
2 deletions
+8
-2
unit_test.c
test/unit_test.c
+8
-2
No files found.
test/unit_test.c
View file @
84e26ccd
...
...
@@ -133,7 +133,8 @@ static void *event_handler(enum mg_event event,
const
struct
mg_request_info
*
request_info
)
{
if
(
event
==
MG_NEW_REQUEST
&&
!
strcmp
(
request_info
->
uri
,
"/data"
))
{
mg_printf
(
conn
,
"HTTP/1.1 200 OK
\r\n
"
"Content-Length: %d
\r\n\r\n
"
"Content-Length: %d
\r\n
"
"Content-Type: text/plain
\r\n\r\n
"
"%s"
,
(
int
)
strlen
(
fetch_data
),
fetch_data
);
return
""
;
}
else
if
(
event
==
MG_EVENT_LOG
)
{
...
...
@@ -170,9 +171,14 @@ static void test_mg_fetch(void) {
// Successful fetch
ASSERT
((
fp
=
mg_fetch
(
ctx
,
"http://localhost:33796/data"
,
tmp_file
,
&
ri
))
!=
NULL
);
ASSERT
(
ri
.
num_headers
==
2
);
printf
(
"%s: [%s]
\n
"
,
__func__
,
ri
.
request_method
);
ASSERT
(
!
strcmp
(
ri
.
request_method
,
"HTTP/1.1"
));
ASSERT
(
!
strcmp
(
ri
.
uri
,
"200"
));
ASSERT
(
!
strcmp
(
ri
.
http_version
,
"OK"
));
ASSERT
((
length
=
ftell
(
fp
))
==
(
int
)
strlen
(
fetch_data
));
fseek
(
fp
,
0
,
SEEK_SET
);
ASSERT
(
fread
(
buf
,
1
,
length
,
fp
)
==
length
);
ASSERT
(
fread
(
buf
,
1
,
length
,
fp
)
==
(
size_t
)
length
);
ASSERT
(
memcmp
(
buf
,
fetch_data
,
length
)
==
0
);
remove
(
tmp_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