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
2c8d3ac2
Commit
2c8d3ac2
authored
Oct 29, 2012
by
Mukund Sivaraman
Browse files
[2369] Check saveLine() + ungetAll()
parent
a6093a8e
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/lib/dns/tests/inputsource_unittest.cc
View file @
2c8d3ac2
...
...
@@ -168,4 +168,36 @@ TEST_F(InputSourceTest, lines) {
EXPECT_EQ
(
1
,
source_
.
getCurrentLine
());
}
// ungetAll() after saveLine() should skip back to the last-saved place.
TEST_F
(
InputSourceTest
,
saveLine
)
{
// First, skip to line 2.
while
(
!
source_
.
atEOF
()
&&
(
source_
.
getCurrentLine
()
!=
2
))
{
source_
.
getChar
();
}
EXPECT_FALSE
(
source_
.
atEOF
());
size_t
line
=
source_
.
getCurrentLine
();
EXPECT_EQ
(
2
,
line
);
// Now, save the line.
source_
.
saveLine
();
// Now, go to EOF
while
(
!
source_
.
atEOF
())
{
source_
.
getChar
();
}
line
=
source_
.
getCurrentLine
();
// Now, we are at EOF.
EXPECT_TRUE
(
source_
.
atEOF
());
EXPECT_EQ
(
4
,
line
);
// Now, ungetAll() and check where it goes back.
source_
.
ungetAll
();
// Now we are back to where we last-saved.
EXPECT_EQ
(
2
,
source_
.
getCurrentLine
());
EXPECT_FALSE
(
source_
.
atEOF
());
}
}
// end namespace
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