Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
nghttp2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
nghttp2
Commits
0000d3e7
Commit
0000d3e7
authored
Jul 23, 2013
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add test for nghttp2_nv_array_from_cstr
parent
b7ff05c4
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
47 additions
and
1 deletion
+47
-1
lib/nghttp2_frame.c
lib/nghttp2_frame.c
+2
-1
tests/main.c
tests/main.c
+2
-0
tests/nghttp2_frame_test.c
tests/nghttp2_frame_test.c
+42
-0
tests/nghttp2_frame_test.h
tests/nghttp2_frame_test.h
+1
-0
No files found.
lib/nghttp2_frame.c
View file @
0000d3e7
...
...
@@ -697,7 +697,8 @@ ssize_t nghttp2_nv_array_from_cstr(nghttp2_nv **nva_ptr, const char **nv)
buflen
+=
len
;
}
nvlen
=
i
/
2
;
if
(
nvlen
==
0
)
{
/* If all name/value pair is 0-length, remove them */
if
(
nvlen
==
0
||
buflen
==
0
)
{
*
nva_ptr
=
NULL
;
return
0
;
}
...
...
tests/main.c
View file @
0000d3e7
...
...
@@ -187,6 +187,8 @@ int main(int argc, char* argv[])
test_nghttp2_frame_pack_goaway
)
||
!
CU_add_test
(
pSuite
,
"frame_pack_window_update"
,
test_nghttp2_frame_pack_window_update
)
||
!
CU_add_test
(
pSuite
,
"nv_array_from_cstr"
,
test_nghttp2_nv_array_from_cstr
)
||
!
CU_add_test
(
pSuite
,
"hd_deflate"
,
test_nghttp2_hd_deflate
)
||
!
CU_add_test
(
pSuite
,
"hd_inflate_indname_inc"
,
test_nghttp2_hd_inflate_indname_inc
)
||
...
...
tests/nghttp2_frame_test.c
View file @
0000d3e7
...
...
@@ -334,3 +334,45 @@ void test_nghttp2_frame_pack_window_update(void)
nghttp2_frame_window_update_free
(
&
oframe
);
nghttp2_frame_window_update_free
(
&
frame
);
}
void
test_nghttp2_nv_array_from_cstr
(
void
)
{
const
char
*
empty
[]
=
{
NULL
};
const
char
*
emptynv
[]
=
{
""
,
""
,
""
,
""
,
NULL
};
const
char
*
nv
[]
=
{
"alpha"
,
"bravo"
,
"charlie"
,
"delta"
,
NULL
};
const
char
*
bignv
[]
=
{
"echo"
,
NULL
,
NULL
};
size_t
bigvallen
=
64
*
1024
;
char
*
bigval
=
malloc
(
bigvallen
+
1
);
nghttp2_nv
*
nva
;
ssize_t
rv
;
memset
(
bigval
,
'0'
,
bigvallen
);
bigval
[
bigvallen
]
=
'\0'
;
bignv
[
1
]
=
bigval
;
rv
=
nghttp2_nv_array_from_cstr
(
&
nva
,
empty
);
CU_ASSERT
(
0
==
rv
);
CU_ASSERT
(
NULL
==
nva
);
rv
=
nghttp2_nv_array_from_cstr
(
&
nva
,
emptynv
);
CU_ASSERT
(
0
==
rv
);
CU_ASSERT
(
NULL
==
nva
);
rv
=
nghttp2_nv_array_from_cstr
(
&
nva
,
nv
);
CU_ASSERT
(
2
==
rv
);
CU_ASSERT
(
nva
[
0
].
namelen
==
5
);
CU_ASSERT
(
0
==
memcmp
(
"alpha"
,
nva
[
0
].
name
,
5
));
CU_ASSERT
(
nva
[
0
].
valuelen
=
5
);
CU_ASSERT
(
0
==
memcmp
(
"bravo"
,
nva
[
0
].
value
,
5
));
CU_ASSERT
(
nva
[
1
].
namelen
==
7
);
CU_ASSERT
(
0
==
memcmp
(
"charlie"
,
nva
[
1
].
name
,
7
));
CU_ASSERT
(
nva
[
1
].
valuelen
==
5
);
CU_ASSERT
(
0
==
memcmp
(
"delta"
,
nva
[
1
].
value
,
5
));
nghttp2_nv_array_del
(
nva
);
rv
=
nghttp2_nv_array_from_cstr
(
&
nva
,
bignv
);
CU_ASSERT
(
NGHTTP2_ERR_INVALID_ARGUMENT
==
rv
);
free
(
bigval
);
}
tests/nghttp2_frame_test.h
View file @
0000d3e7
...
...
@@ -36,5 +36,6 @@ void test_nghttp2_frame_pack_settings(void);
void
test_nghttp2_frame_pack_ping
(
void
);
void
test_nghttp2_frame_pack_goaway
(
void
);
void
test_nghttp2_frame_pack_window_update
(
void
);
void
test_nghttp2_nv_array_from_cstr
(
void
);
#endif
/* NGHTTP2_FRAME_TEST_H */
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