summaryrefslogtreecommitdiff
path: root/cpp/test/streaming.cc
diff options
context:
space:
mode:
authorfrsyuki <frsyuki@users.sourceforge.jp>2010-06-01 07:16:25 +0900
committerfrsyuki <frsyuki@users.sourceforge.jp>2010-06-01 07:16:25 +0900
commiteabcf15790a774ce718ae1738c6ddb407e1cd279 (patch)
treea69c899bd8d136a8fbb6934ea8b5d87a521e4e23 /cpp/test/streaming.cc
parent684bca203ad862f30558429081d1a27681fe4559 (diff)
downloadmsgpack-python-eabcf15790a774ce718ae1738c6ddb407e1cd279.tar.gz
cpp: update tests
Diffstat (limited to 'cpp/test/streaming.cc')
-rw-r--r--cpp/test/streaming.cc19
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);
}
}