From 6056f939103624d21092a5e4a4d8ffaf9204c191 Mon Sep 17 00:00:00 2001 From: frsyuki Date: Tue, 1 Jun 2010 05:15:36 +0900 Subject: cpp: add cases.mpac test --- cpp/test/cases.cc | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 cpp/test/cases.cc (limited to 'cpp/test/cases.cc') diff --git a/cpp/test/cases.cc b/cpp/test/cases.cc new file mode 100644 index 0000000..b408876 --- /dev/null +++ b/cpp/test/cases.cc @@ -0,0 +1,36 @@ +#include +#include +#include + +static void feed_file(msgpack::unpacker& pac, const char* path) +{ + std::ifstream fin(path); + while(true) { + pac.reserve_buffer(32*1024); + fin.read(pac.buffer(), pac.buffer_capacity()); + if(fin.bad()) { + throw std::runtime_error("read failed"); + } + pac.buffer_consumed(fin.gcount()); + if(fin.fail()) { + break; + } + } +} + +TEST(cases, format) +{ + msgpack::unpacker pac; + msgpack::unpacker pac_compact; + + feed_file(pac, "cases.mpac"); + feed_file(pac_compact, "cases_compact.mpac"); + + msgpack::unpacked result; + while(pac.next(&result)) { + msgpack::unpacked result_compact; + EXPECT_TRUE( pac_compact.next(&result_compact) ); + EXPECT_EQ(result_compact.get(), result.get()); + } +} + -- cgit v1.2.1