Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Kea
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
416
Issues
416
List
Boards
Labels
Service Desk
Milestones
Merge Requests
66
Merge Requests
66
Operations
Operations
Incidents
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
ISC Open Source Projects
Kea
Commits
aef276b9
Commit
aef276b9
authored
Dec 10, 2016
by
Francis Dupont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[5036] Optional exception display and case sensitive JSON unit tests
parent
b7837f89
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
4 deletions
+18
-4
src/bin/dhcp6/tests/dhcp6_test_utils.h
src/bin/dhcp6/tests/dhcp6_test_utils.h
+10
-4
src/bin/dhcp6/tests/parser_unittest.cc
src/bin/dhcp6/tests/parser_unittest.cc
+8
-0
No files found.
src/bin/dhcp6/tests/dhcp6_test_utils.h
View file @
aef276b9
...
@@ -656,16 +656,19 @@ parseJSON(const std::string& in)
...
@@ -656,16 +656,19 @@ parseJSON(const std::string& in)
/// needed. This format is used by most of the tests.
/// needed. This format is used by most of the tests.
///
///
/// @param in string to be parsed
/// @param in string to be parsed
/// @param verbose display the exception message when it fails
/// @return ElementPtr structure representing parsed JSON
/// @return ElementPtr structure representing parsed JSON
inline
isc
::
data
::
ConstElementPtr
inline
isc
::
data
::
ConstElementPtr
parseDHCP6
(
const
std
::
string
&
in
)
parseDHCP6
(
const
std
::
string
&
in
,
bool
verbose
=
false
)
{
{
try
{
try
{
isc
::
dhcp
::
Parser6Context
ctx
;
isc
::
dhcp
::
Parser6Context
ctx
;
return
(
ctx
.
parseString
(
in
,
isc
::
dhcp
::
Parser6Context
::
SUBPARSER_DHCP6
));
return
(
ctx
.
parseString
(
in
,
isc
::
dhcp
::
Parser6Context
::
SUBPARSER_DHCP6
));
}
}
catch
(
const
std
::
exception
&
ex
)
{
catch
(
const
std
::
exception
&
ex
)
{
std
::
cout
<<
"EXCEPTION: "
<<
ex
.
what
()
<<
std
::
endl
;
if
(
verbose
)
{
std
::
cout
<<
"EXCEPTION: "
<<
ex
.
what
()
<<
std
::
endl
;
}
throw
;
throw
;
}
}
}
}
...
@@ -675,16 +678,19 @@ parseDHCP6(const std::string& in)
...
@@ -675,16 +678,19 @@ parseDHCP6(const std::string& in)
/// This function parses specified text as JSON that defines option definitions.
/// This function parses specified text as JSON that defines option definitions.
///
///
/// @param in string to be parsed
/// @param in string to be parsed
/// @param verbose display the exception message when it fails
/// @return ElementPtr structure representing parsed JSON
/// @return ElementPtr structure representing parsed JSON
inline
isc
::
data
::
ConstElementPtr
inline
isc
::
data
::
ConstElementPtr
parseOPTION_DEF
(
const
std
::
string
&
in
)
parseOPTION_DEF
(
const
std
::
string
&
in
,
bool
verbose
=
false
)
{
{
try
{
try
{
isc
::
dhcp
::
Parser6Context
ctx
;
isc
::
dhcp
::
Parser6Context
ctx
;
return
(
ctx
.
parseString
(
in
,
isc
::
dhcp
::
Parser6Context
::
PARSER_OPTION_DEF
));
return
(
ctx
.
parseString
(
in
,
isc
::
dhcp
::
Parser6Context
::
PARSER_OPTION_DEF
));
}
}
catch
(
const
std
::
exception
&
ex
)
{
catch
(
const
std
::
exception
&
ex
)
{
std
::
cout
<<
"EXCEPTION: "
<<
ex
.
what
()
<<
std
::
endl
;
if
(
verbose
)
{
std
::
cout
<<
"EXCEPTION: "
<<
ex
.
what
()
<<
std
::
endl
;
}
throw
;
throw
;
}
}
}
}
...
...
src/bin/dhcp6/tests/parser_unittest.cc
View file @
aef276b9
...
@@ -326,6 +326,14 @@ TEST(ParserTest, errors) {
...
@@ -326,6 +326,14 @@ TEST(ParserTest, errors) {
Parser6Context
::
PARSER_JSON
,
Parser6Context
::
PARSER_JSON
,
"Can't open include file /foo/bar"
);
"Can't open include file /foo/bar"
);
// case sensitivity
testError
(
"{
\"
foo
\"
: True }"
,
Parser6Context
::
PARSER_JSON
,
"<string>:1.10: Invalid character: T"
);
testError
(
"{
\"
foo
\"
: NULL }"
,
Parser6Context
::
PARSER_JSON
,
"<string>:1.10: Invalid character: N"
);
// numbers
// numbers
testError
(
"123"
,
testError
(
"123"
,
Parser6Context
::
PARSER_DHCP6
,
Parser6Context
::
PARSER_DHCP6
,
...
...
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