char_array_buffer should implement also seekpos()
This commit is contained in:
parent
5db45d9fa3
commit
fe268b0e71
2 changed files with 26 additions and 0 deletions
|
@ -68,6 +68,13 @@ private:
|
||||||
return end_ - current_;
|
return end_ - current_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pos_type seekpos(pos_type off,
|
||||||
|
std::ios_base::openmode /*which*/)
|
||||||
|
{
|
||||||
|
current_ = std::min(begin_ + off, end_);
|
||||||
|
return pos_type(off_type(current_ - begin_));
|
||||||
|
}
|
||||||
|
|
||||||
pos_type seekoff(off_type off, std::ios_base::seekdir dir,
|
pos_type seekoff(off_type off, std::ios_base::seekdir dir,
|
||||||
std::ios_base::openmode which = std::ios_base::in | std::ios_base::out )
|
std::ios_base::openmode which = std::ios_base::in | std::ios_base::out )
|
||||||
{
|
{
|
||||||
|
|
19
test/unit/util/char_array_buffer.cpp
Normal file
19
test/unit/util/char_array_buffer.cpp
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
#include "catch.hpp"
|
||||||
|
|
||||||
|
#include <mapnik/util/char_array_buffer.hpp>
|
||||||
|
#include <istream>
|
||||||
|
|
||||||
|
TEST_CASE("char_array_buffer") {
|
||||||
|
|
||||||
|
SECTION("std::istream seekg, tellg") {
|
||||||
|
|
||||||
|
const std::size_t buffer_size = 66;
|
||||||
|
char buffer[buffer_size];
|
||||||
|
mapnik::util::char_array_buffer array_buff(buffer, buffer_size);
|
||||||
|
std::istream stream(&array_buff);
|
||||||
|
|
||||||
|
CHECK(stream.seekg(0).tellg() == 0);
|
||||||
|
CHECK(stream.seekg(buffer_size).tellg() == buffer_size);
|
||||||
|
CHECK(stream.seekg(70).tellg() == buffer_size);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue