Skip to content
GitLab
Projects
Groups
Snippets
/
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
6b8bf7d0
Commit
6b8bf7d0
authored
Nov 01, 2012
by
Mukund Sivaraman
Browse files
[2369] Rename exception to UngetBeforeBeginning
parent
6847454e
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/lib/dns/master_lexer_inputsource.cc
View file @
6b8bf7d0
...
...
@@ -90,7 +90,8 @@ InputSource::ungetChar() {
if
(
at_eof_
)
{
at_eof_
=
false
;
}
else
if
(
buffer_pos_
==
0
)
{
isc_throw
(
UngetError
,
"Cannot skip before the start of buffer"
);
isc_throw
(
UngetBeforeBeginning
,
"Cannot skip before the start of buffer"
);
}
else
{
buffer_pos_
--
;
if
(
buffer_
[
buffer_pos_
]
==
'\n'
)
{
...
...
src/lib/dns/master_lexer_inputsource.h
View file @
6b8bf7d0
...
...
@@ -73,8 +73,8 @@ public:
/// \brief Exception thrown when ungetChar() is made to go before
/// the start of buffer.
struct
Unget
Error
:
public
OutOfRange
{
Unget
Error
(
const
char
*
file
,
size_t
line
,
const
char
*
what
)
:
struct
Unget
BeforeBeginning
:
public
OutOfRange
{
Unget
BeforeBeginning
(
const
char
*
file
,
size_t
line
,
const
char
*
what
)
:
OutOfRange
(
file
,
line
,
what
)
{}
};
...
...
@@ -85,6 +85,10 @@ public:
/// \brief Skips backward a single character in the input
/// source. The last-read character is unget.
///
/// \throws UngetBeforeBeginning if we go backwards past the start
/// of reading, or backwards past the last time compact() was
/// called.
void
ungetChar
();
/// Forgets everything read so far, and skips back to the position
...
...
src/lib/dns/tests/master_lexer_inputsource_unittest.cc
View file @
6b8bf7d0
...
...
@@ -102,7 +102,7 @@ TEST_F(InputSourceTest, getAndUngetChar) {
}
// Skipping past the start of buffer should throw.
EXPECT_THROW
(
source_
.
ungetChar
(),
InputSource
::
Unget
Error
);
EXPECT_THROW
(
source_
.
ungetChar
(),
InputSource
::
Unget
BeforeBeginning
);
}
// ungetAll() should skip back to the place where the InputSource
...
...
@@ -128,7 +128,7 @@ TEST_F(InputSourceTest, compact) {
source_
.
compact
();
// Ungetting here must throw.
EXPECT_THROW
(
source_
.
ungetChar
(),
InputSource
::
Unget
Error
);
EXPECT_THROW
(
source_
.
ungetChar
(),
InputSource
::
Unget
BeforeBeginning
);
for
(
size_t
i
=
0
;
i
<
str_length_
;
i
++
)
{
EXPECT_EQ
(
str_
[
i
],
source_
.
getChar
());
...
...
@@ -156,7 +156,7 @@ TEST_F(InputSourceTest, compact) {
source_
.
ungetChar
();
// Ungetting here must throw.
EXPECT_THROW
(
source_
.
ungetChar
(),
InputSource
::
Unget
Error
);
EXPECT_THROW
(
source_
.
ungetChar
(),
InputSource
::
Unget
BeforeBeginning
);
EXPECT_EQ
(
-
1
,
source_
.
getChar
());
EXPECT_TRUE
(
source_
.
atEOF
());
...
...
@@ -181,7 +181,7 @@ TEST_F(InputSourceTest, compactDuring) {
source_
.
compact
();
// Ungetting here must throw.
EXPECT_THROW
(
source_
.
ungetChar
(),
InputSource
::
Unget
Error
);
EXPECT_THROW
(
source_
.
ungetChar
(),
InputSource
::
Unget
BeforeBeginning
);
for
(
size_t
i
=
13
;
i
<
str_length_
;
i
++
)
{
EXPECT_EQ
(
str_
[
i
],
source_
.
getChar
());
...
...
@@ -201,7 +201,7 @@ TEST_F(InputSourceTest, compactDuring) {
source_
.
ungetAll
();
// Ungetting here must throw.
EXPECT_THROW
(
source_
.
ungetChar
(),
InputSource
::
Unget
Error
);
EXPECT_THROW
(
source_
.
ungetChar
(),
InputSource
::
Unget
BeforeBeginning
);
for
(
size_t
i
=
13
;
i
<
str_length_
;
i
++
)
{
EXPECT_EQ
(
str_
[
i
],
source_
.
getChar
());
...
...
@@ -263,7 +263,7 @@ TEST_F(InputSourceTest, lines) {
((
line
-
1
)
==
source_
.
getCurrentLine
())));
line
=
source_
.
getCurrentLine
();
}
},
InputSource
::
Unget
Error
);
},
InputSource
::
Unget
BeforeBeginning
);
// Now we are back to where we started.
EXPECT_EQ
(
1
,
source_
.
getCurrentLine
());
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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