csharp: add BoxingPacker tests

This commit is contained in:
Kazuki Oikawa 2011-04-10 01:06:26 +09:00
parent 8e923777b8
commit 05ac2603e6
3 changed files with 109 additions and 1 deletions

View file

@ -21,6 +21,14 @@ namespace msgpack
Pack (writer, o);
}
public byte[] Pack (object o)
{
using (MemoryStream ms = new MemoryStream ()) {
Pack (ms, o);
return ms.ToArray ();
}
}
void Pack (MsgPackWriter writer, object o)
{
if (o == null) {
@ -86,6 +94,18 @@ namespace msgpack
return Unpack (reader);
}
public object Unpack (byte[] buf, int offset, int size)
{
using (MemoryStream ms = new MemoryStream (buf, offset, size)) {
return Unpack (ms);
}
}
public object Unpack (byte[] buf)
{
return Unpack (buf, 0, buf.Length);
}
object Unpack (MsgPackReader reader)
{
if (!reader.Read ())