cpp: msgpack::unpack returns void

This commit is contained in:
frsyuki 2010-06-01 07:13:47 +09:00
parent 5a92c861e3
commit d42ecccf6f
2 changed files with 7 additions and 11 deletions
cpp

@ -160,7 +160,7 @@ private:
};
static bool unpack(unpacked* result,
static void unpack(unpacked* result,
const char* data, size_t len, size_t* offset = NULL);
@ -312,7 +312,7 @@ inline void unpacker::remove_nonparsed_buffer()
}
inline bool unpack(unpacked* result,
inline void unpack(unpacked* result,
const char* data, size_t len, size_t* offset)
{
msgpack::object obj;
@ -326,12 +326,12 @@ inline bool unpack(unpacked* result,
case UNPACK_SUCCESS:
result->get() = obj;
result->zone() = z;
return false;
return;
case UNPACK_EXTRA_BYTES:
result->get() = obj;
result->zone() = z;
return true;
return;
case UNPACK_CONTINUE:
throw unpack_error("insufficient bytes");

@ -77,21 +77,17 @@ TEST(unpack, sequence)
msgpack::pack(sbuf, 2);
msgpack::pack(sbuf, 3);
bool cont;
size_t offset = 0;
msgpack::unpacked msg;
cont = msgpack::unpack(&msg, sbuf.data(), sbuf.size(), &offset);
EXPECT_TRUE(cont);
msgpack::unpack(&msg, sbuf.data(), sbuf.size(), &offset);
EXPECT_EQ(1, msg.get().as<int>());
cont = msgpack::unpack(&msg, sbuf.data(), sbuf.size(), &offset);
EXPECT_TRUE(cont);
msgpack::unpack(&msg, sbuf.data(), sbuf.size(), &offset);
EXPECT_EQ(2, msg.get().as<int>());
cont = msgpack::unpack(&msg, sbuf.data(), sbuf.size(), &offset);
EXPECT_FALSE(cont);
msgpack::unpack(&msg, sbuf.data(), sbuf.size(), &offset);
EXPECT_EQ(3, msg.get().as<int>());
}