Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ISC Open Source Projects
Kea
Commits
d5218636
Commit
d5218636
authored
Nov 29, 2012
by
JINMEI Tatuya
Browse files
[2506] supported NUMBER in getNextToken() with expected type
parent
f70d131f
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/lib/dns/master_lexer.cc
View file @
d5218636
...
...
@@ -192,14 +192,26 @@ MasterLexer::getNextToken(Options options) {
return
(
impl_
->
token_
);
}
const
MasterToken
&
MasterLexer
::
getNextToken
(
MasterToken
::
Type
expect
,
bool
eol_ok
)
{
Options
options
=
NONE
;
if
(
expect
==
MasterToken
::
QSTRING
)
{
options
=
options
|
QSTRING
;
namespace
{
inline
MasterLexer
::
Options
optionsForTokenType
(
MasterToken
::
Type
expect
)
{
switch
(
expect
)
{
case
MasterToken
::
STRING
:
return
(
MasterLexer
::
NONE
);
case
MasterToken
::
QSTRING
:
return
(
MasterLexer
::
QSTRING
);
case
MasterToken
::
NUMBER
:
return
(
MasterLexer
::
NUMBER
);
default:
assert
(
false
);
}
}
}
getNextToken
(
options
);
// the result should be set in impl_->token_
const
MasterToken
&
MasterLexer
::
getNextToken
(
MasterToken
::
Type
expect
,
bool
eol_ok
)
{
// the result should be set in impl_->token_
getNextToken
(
optionsForTokenType
(
expect
));
const
bool
is_eol_like
=
(
impl_
->
token_
.
getType
()
==
MasterToken
::
END_OF_LINE
||
...
...
src/lib/dns/tests/master_lexer_unittest.cc
View file @
d5218636
...
...
@@ -356,4 +356,25 @@ TEST_F(MasterLexerTest, getNextTokenQString) {
eofCheck
(
lexer
,
MasterToken
::
QSTRING
);
}
TEST_F
(
MasterLexerTest
,
getNextTokenNumber
)
{
ss
<<
"3600
\n
"
;
ss
<<
"
\n
"
;
ss
<<
"86400"
;
lexer
.
pushSource
(
ss
);
// Expecting a number string and get one.
EXPECT_EQ
(
3600
,
lexer
.
getNextToken
(
MasterToken
::
NUMBER
).
getNumber
());
eolCheck
(
lexer
,
MasterToken
::
NUMBER
);
// Skip the 2nd '\n'
EXPECT_EQ
(
MasterToken
::
END_OF_LINE
,
lexer
.
getNextToken
().
getType
());
// Unless we specify NUMBER, decimal number string should be recognized
// as a string.
EXPECT_EQ
(
"86400"
,
lexer
.
getNextToken
(
MasterToken
::
STRING
).
getString
());
eofCheck
(
lexer
,
MasterToken
::
NUMBER
);
}
}
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