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
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
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
Adam Osuchowski
Kea
Commits
a904a3e1
Commit
a904a3e1
authored
Dec 28, 2016
by
Tomek Mrugalski
🛰
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[5021] SimpleParser unit-tests now use bison parser.
parent
498f9616
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
37 additions
and
34 deletions
+37
-34
src/bin/dhcp4/parser_context.cc
src/bin/dhcp4/parser_context.cc
+3
-3
src/bin/dhcp4/parser_context.h
src/bin/dhcp4/parser_context.h
+5
-5
src/bin/dhcp4/tests/dhcp4_test_utils.h
src/bin/dhcp4/tests/dhcp4_test_utils.h
+3
-3
src/bin/dhcp4/tests/simple_parser4_unittest.cc
src/bin/dhcp4/tests/simple_parser4_unittest.cc
+8
-7
src/bin/dhcp6/parser_context.cc
src/bin/dhcp6/parser_context.cc
+3
-3
src/bin/dhcp6/parser_context.h
src/bin/dhcp6/parser_context.h
+5
-5
src/bin/dhcp6/tests/dhcp6_test_utils.h
src/bin/dhcp6/tests/dhcp6_test_utils.h
+3
-3
src/bin/dhcp6/tests/simple_parser6_unittest.cc
src/bin/dhcp6/tests/simple_parser6_unittest.cc
+7
-5
No files found.
src/bin/dhcp4/parser_context.cc
View file @
a904a3e1
...
...
@@ -24,14 +24,14 @@ Parser4Context::~Parser4Context()
{
}
isc
::
data
::
Const
ElementPtr
isc
::
data
::
ElementPtr
Parser4Context
::
parseString
(
const
std
::
string
&
str
,
ParserType
parser_type
)
{
scanStringBegin
(
str
,
parser_type
);
return
(
parseCommon
());
}
isc
::
data
::
Const
ElementPtr
isc
::
data
::
ElementPtr
Parser4Context
::
parseFile
(
const
std
::
string
&
filename
,
ParserType
parser_type
)
{
FILE
*
f
=
fopen
(
filename
.
c_str
(),
"r"
);
if
(
!
f
)
{
...
...
@@ -41,7 +41,7 @@ Parser4Context::parseFile(const std::string& filename, ParserType parser_type) {
return
(
parseCommon
());
}
isc
::
data
::
Const
ElementPtr
isc
::
data
::
ElementPtr
Parser4Context
::
parseCommon
()
{
isc
::
dhcp
::
Dhcp4Parser
parser
(
*
this
);
// Uncomment this to get detailed parser logs.
...
...
src/bin/dhcp4/parser_context.h
View file @
a904a3e1
...
...
@@ -123,8 +123,8 @@ public:
/// @param str string to be parsed
/// @param parser_type specifies expected content (usually DHCP4 or generic JSON)
/// @return Element structure representing parsed text.
isc
::
data
::
Const
ElementPtr
parseString
(
const
std
::
string
&
str
,
ParserType
parser_type
);
isc
::
data
::
ElementPtr
parseString
(
const
std
::
string
&
str
,
ParserType
parser_type
);
/// @brief Run the parser on the file specified.
///
...
...
@@ -136,8 +136,8 @@ public:
/// @param filename file to be parsed
/// @param parser_type specifies expected content (usually DHCP4 or generic JSON)
/// @return Element structure representing parsed text.
isc
::
data
::
Const
ElementPtr
parseFile
(
const
std
::
string
&
filename
,
ParserType
parser_type
);
isc
::
data
::
ElementPtr
parseFile
(
const
std
::
string
&
filename
,
ParserType
parser_type
);
/// @brief Error handler
///
...
...
@@ -312,7 +312,7 @@ public:
/// @brief Common part of parseXXX
///
/// @return Element structure representing parsed text.
isc
::
data
::
Const
ElementPtr
parseCommon
();
isc
::
data
::
ElementPtr
parseCommon
();
};
};
// end of isc::eval namespace
...
...
src/bin/dhcp4/tests/dhcp4_test_utils.h
View file @
a904a3e1
...
...
@@ -483,7 +483,7 @@ public:
///
/// @param in string to be parsed
/// @return ElementPtr structure representing parsed JSON
inline
isc
::
data
::
Const
ElementPtr
inline
isc
::
data
::
ElementPtr
parseJSON
(
const
std
::
string
&
in
)
{
isc
::
dhcp
::
Parser4Context
ctx
;
...
...
@@ -498,7 +498,7 @@ parseJSON(const std::string& in)
/// @param in string to be parsed
/// @param verbose display the exception message when it fails
/// @return ElementPtr structure representing parsed JSON
inline
isc
::
data
::
Const
ElementPtr
inline
isc
::
data
::
ElementPtr
parseDHCP4
(
const
std
::
string
&
in
,
bool
verbose
=
false
)
{
try
{
...
...
@@ -520,7 +520,7 @@ parseDHCP4(const std::string& in, bool verbose = false)
/// @param in string to be parsed
/// @param verbose display the exception message when it fails
/// @return ElementPtr structure representing parsed JSON
inline
isc
::
data
::
Const
ElementPtr
inline
isc
::
data
::
ElementPtr
parseOPTION_DEF
(
const
std
::
string
&
in
,
bool
verbose
=
false
)
{
try
{
...
...
src/bin/dhcp4/tests/simple_parser4_unittest.cc
View file @
a904a3e1
...
...
@@ -7,6 +7,7 @@
#include <config.h>
#include <gtest/gtest.h>
#include <dhcp4/simple_parser4.h>
#include <dhcp4/tests/dhcp4_test_utils.h>
#include <cc/data.h>
using
namespace
isc
::
data
;
...
...
@@ -44,7 +45,7 @@ public:
// This test checks if global defaults are properly set for DHCPv4.
TEST_F
(
SimpleParser4Test
,
globalDefaults4
)
{
ElementPtr
empty
=
Element
::
from
JSON
(
"{ }"
);
ElementPtr
empty
=
parse
JSON
(
"{ }"
);
size_t
num
=
0
;
EXPECT_NO_THROW
(
num
=
SimpleParser4
::
setAllDefaults
(
empty
));
...
...
@@ -65,12 +66,12 @@ TEST_F(SimpleParser4Test, globalDefaults4) {
// This test checks if the parameters can be inherited from the global
// scope to the subnet scope.
TEST_F
(
SimpleParser4Test
,
inheritGlobalToSubnet4
)
{
ElementPtr
global
=
Element
::
from
JSON
(
"{
\"
renew-timer
\"
: 1,"
"
\"
rebind-timer
\"
: 2,"
"
\"
preferred-lifetime
\"
: 3,"
"
\"
valid-lifetime
\"
: 4"
"}"
);
ElementPtr
subnet
=
Element
::
from
JSON
(
"{
\"
renew-timer
\"
: 100 }"
);
ElementPtr
global
=
parse
JSON
(
"{
\"
renew-timer
\"
: 1,"
"
\"
rebind-timer
\"
: 2,"
"
\"
preferred-lifetime
\"
: 3,"
"
\"
valid-lifetime
\"
: 4"
"}"
);
ElementPtr
subnet
=
parse
JSON
(
"{
\"
renew-timer
\"
: 100 }"
);
// we should inherit 3 parameters. Renew-timer should remain intact,
// as it was already defined in the subnet scope.
...
...
src/bin/dhcp6/parser_context.cc
View file @
a904a3e1
...
...
@@ -24,14 +24,14 @@ Parser6Context::~Parser6Context()
{
}
isc
::
data
::
Const
ElementPtr
isc
::
data
::
ElementPtr
Parser6Context
::
parseString
(
const
std
::
string
&
str
,
ParserType
parser_type
)
{
scanStringBegin
(
str
,
parser_type
);
return
(
parseCommon
());
}
isc
::
data
::
Const
ElementPtr
isc
::
data
::
ElementPtr
Parser6Context
::
parseFile
(
const
std
::
string
&
filename
,
ParserType
parser_type
)
{
FILE
*
f
=
fopen
(
filename
.
c_str
(),
"r"
);
if
(
!
f
)
{
...
...
@@ -41,7 +41,7 @@ Parser6Context::parseFile(const std::string& filename, ParserType parser_type) {
return
(
parseCommon
());
}
isc
::
data
::
Const
ElementPtr
isc
::
data
::
ElementPtr
Parser6Context
::
parseCommon
()
{
isc
::
dhcp
::
Dhcp6Parser
parser
(
*
this
);
// Uncomment this to get detailed parser logs.
...
...
src/bin/dhcp6/parser_context.h
View file @
a904a3e1
...
...
@@ -126,8 +126,8 @@ public:
/// @param str string to be parsed
/// @param parser_type specifies expected content (usually DHCP6 or generic JSON)
/// @return Element structure representing parsed text.
isc
::
data
::
Const
ElementPtr
parseString
(
const
std
::
string
&
str
,
ParserType
parser_type
);
isc
::
data
::
ElementPtr
parseString
(
const
std
::
string
&
str
,
ParserType
parser_type
);
/// @brief Run the parser on the file specified.
///
...
...
@@ -139,8 +139,8 @@ public:
/// @param filename file to be parsed
/// @param parser_type specifies expected content (usually DHCP6 or generic JSON)
/// @return Element structure representing parsed text.
isc
::
data
::
Const
ElementPtr
parseFile
(
const
std
::
string
&
filename
,
ParserType
parser_type
);
isc
::
data
::
ElementPtr
parseFile
(
const
std
::
string
&
filename
,
ParserType
parser_type
);
/// @brief Error handler
///
...
...
@@ -321,7 +321,7 @@ public:
/// @brief Common part of parseXXX
///
/// @return Element structure representing parsed text.
isc
::
data
::
Const
ElementPtr
parseCommon
();
isc
::
data
::
ElementPtr
parseCommon
();
};
};
// end of isc::eval namespace
...
...
src/bin/dhcp6/tests/dhcp6_test_utils.h
View file @
a904a3e1
...
...
@@ -643,7 +643,7 @@ public:
///
/// @param in string to be parsed
/// @return ElementPtr structure representing parsed JSON
inline
isc
::
data
::
Const
ElementPtr
inline
isc
::
data
::
ElementPtr
parseJSON
(
const
std
::
string
&
in
)
{
isc
::
dhcp
::
Parser6Context
ctx
;
...
...
@@ -658,7 +658,7 @@ parseJSON(const std::string& in)
/// @param in string to be parsed
/// @param verbose display the exception message when it fails
/// @return ElementPtr structure representing parsed JSON
inline
isc
::
data
::
Const
ElementPtr
inline
isc
::
data
::
ElementPtr
parseDHCP6
(
const
std
::
string
&
in
,
bool
verbose
=
false
)
{
try
{
...
...
@@ -680,7 +680,7 @@ parseDHCP6(const std::string& in, bool verbose = false)
/// @param in string to be parsed
/// @param verbose display the exception message when it fails
/// @return ElementPtr structure representing parsed JSON
inline
isc
::
data
::
Const
ElementPtr
inline
isc
::
data
::
ElementPtr
parseOPTION_DEF
(
const
std
::
string
&
in
,
bool
verbose
=
false
)
{
try
{
...
...
src/bin/dhcp6/tests/simple_parser6_unittest.cc
View file @
a904a3e1
...
...
@@ -5,13 +5,15 @@
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
#include <config.h>
#include <cc/data.h>
#include <dhcp6/simple_parser6.h>
#include <gtest/gtest.h>
#include <dhcp6/simple_parser6.h>
#include <dhcp6/tests/dhcp6_test_utils.h>
#include <cc/data.h>
using
namespace
isc
;
using
namespace
isc
::
data
;
using
namespace
isc
::
dhcp
;
using
namespace
isc
::
dhcp
::
test
;
namespace
{
...
...
@@ -44,7 +46,7 @@ public:
// This test checks if global defaults are properly set for DHCPv6.
TEST_F
(
SimpleParser6Test
,
globalDefaults6
)
{
ElementPtr
empty
=
Element
::
from
JSON
(
"{ }"
);
ElementPtr
empty
=
parse
JSON
(
"{ }"
);
size_t
num
=
0
;
EXPECT_NO_THROW
(
num
=
SimpleParser6
::
setAllDefaults
(
empty
));
...
...
@@ -61,12 +63,12 @@ TEST_F(SimpleParser6Test, globalDefaults6) {
// This test checks if the parameters can be inherited from the global
// scope to the subnet scope.
TEST_F
(
SimpleParser6Test
,
inheritGlobalToSubnet6
)
{
ElementPtr
global
=
Element
::
from
JSON
(
"{
\"
renew-timer
\"
: 1,"
ElementPtr
global
=
parse
JSON
(
"{
\"
renew-timer
\"
: 1,"
"
\"
rebind-timer
\"
: 2,"
"
\"
preferred-lifetime
\"
: 3,"
"
\"
valid-lifetime
\"
: 4"
"}"
);
ElementPtr
subnet
=
Element
::
from
JSON
(
"{
\"
renew-timer
\"
: 100 }"
);
ElementPtr
subnet
=
parse
JSON
(
"{
\"
renew-timer
\"
: 100 }"
);
// we should inherit 3 parameters. Renew-timer should remain intact,
// as it was already defined in the subnet scope.
...
...
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