diff options
| author | UENISHI Kota <kuenishi+github@gmail.com> | 2010-06-03 00:14:19 +0900 |
|---|---|---|
| committer | UENISHI Kota <kuenishi+github@gmail.com> | 2010-06-03 00:14:19 +0900 |
| commit | 8ecaf7ad4ce4185e81fae775332282ed551fa886 (patch) | |
| tree | 68b7fb5c875f5620033ac8fa4e046bfdd51f78d0 /cpp/test/streaming.cc | |
| parent | 49f3872d047624b1995b8c60edec8bad35429fd3 (diff) | |
| parent | d4049fe593ae4465e7a258d138c2166571a0f1a7 (diff) | |
| download | msgpack-python-8ecaf7ad4ce4185e81fae775332282ed551fa886.tar.gz | |
Merge branch 'master' of ssh://github.com/msgpack/msgpack
Diffstat (limited to 'cpp/test/streaming.cc')
| -rw-r--r-- | cpp/test/streaming.cc | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/cpp/test/streaming.cc b/cpp/test/streaming.cc index c01b8be..e80c671 100644 --- a/cpp/test/streaming.cc +++ b/cpp/test/streaming.cc @@ -2,28 +2,33 @@ #include <gtest/gtest.h> #include <sstream> - TEST(streaming, basic) { - std::ostringstream stream; - msgpack::packer<std::ostream> pk(&stream); + msgpack::sbuffer buffer; + msgpack::packer<msgpack::sbuffer> pk(&buffer); pk.pack(1); pk.pack(2); pk.pack(3); - std::istringstream input(stream.str()); + const char* input = buffer.data(); + const char* const eof = input + buffer.size(); msgpack::unpacker pac; + msgpack::unpacked result; int count = 0; while(count < 3) { pac.reserve_buffer(32*1024); - size_t len = input.readsome(pac.buffer(), pac.buffer_capacity()); + // read buffer into pac.buffer() upto + // pac.buffer_capacity() bytes. + size_t len = 1; + memcpy(pac.buffer(), input, len); + input += len; + pac.buffer_consumed(len); - msgpack::unpacked result; while(pac.next(&result)) { msgpack::object obj = result.get(); switch(count++) { @@ -38,6 +43,8 @@ TEST(streaming, basic) return; } } + + EXPECT_TRUE(input < eof); } } |
