public void fix_map() { var bytes = new MsgPackFormatter() .BeginMap(2) .Key("0").Value(1) .Key("2").Value(3) .EndMap() .GetStore().Bytes; ; Assert.AreEqual(new Byte[] { 0x82, // map2 0xa1, 0x30, // "0" 0x01, // 1 0xa1, 0x32, // "2" 0x03 // 3 }, bytes.ToEnumerable()); var value = MsgPackParser.Parse(bytes); Assert.AreEqual(2, value.Count); Assert.AreEqual(1, value["0"].GetValue()); Assert.AreEqual(3, value["2"].GetValue()); }
public void nil() { { var bytes = new MsgPackFormatter().Null().GetStore().Bytes; Assert.AreEqual(new Byte[] { 0xC0 }, bytes.ToEnumerable()); var parsed = MsgPackParser.Parse(bytes); Assert.True(parsed.IsNull); } }
public void False() { var bytes = new MsgPackFormatter().Value(false).GetStore().Bytes; Assert.AreEqual(new Byte[] { 0xC2 }, bytes.ToEnumerable()); var value = MsgPackParser.Parse(bytes); var j = value.GetBoolean(); Assert.AreEqual(false, j); }
public void positive_fixnum() { for (Byte i = 0; i < 128; ++i) { var bytes = new MsgPackFormatter().Value(i).GetStore().Bytes; Assert.AreEqual(new Byte[] { i }, bytes.ToEnumerable()); var j = MsgPackParser.Parse(bytes).GetValue(); Assert.AreEqual(i, j); } }
public void int128Test() { int i = 128; var bytes = new MsgPackFormatter().Value(i).GetStore().Bytes; Assert.AreEqual(new Byte[] { 0xcc, 0x80, }, bytes.ToEnumerable()); var j = MsgPackParser.Parse(bytes).GetValue(); Assert.AreEqual(i, j); }
public void uint32() { { UInt32 i = 0xFFFF + 20; var bytes = new MsgPackFormatter().Value(i).GetStore().Bytes; Assert.AreEqual(new Byte[] { 0xce, 0x00, 0x01, 0x00, 0x13 }, bytes.ToEnumerable()); var j = MsgPackParser.Parse(bytes).GetValue(); Assert.AreEqual(i, j); } }
public void cast_large_type() { { Byte i = 0x7F + 20; var bytes = new MsgPackFormatter().Value(i).GetStore().Bytes; Assert.AreEqual(new Byte[] { 0xcc, 0x93, }, bytes.ToEnumerable()); var j = MsgPackParser.Parse(bytes).GetValue(); Assert.AreEqual(i, j); } }
public void int64() { { Int64 i = -2147483650; var bytes = new MsgPackFormatter().Value(i).GetStore().Bytes; Assert.AreEqual(new Byte[] { 0xd3, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xff, 0xff, 0xfe }, bytes.ToEnumerable()); var j = MsgPackParser.Parse(bytes).GetValue(); Assert.AreEqual(i, j); } }
public void int32() { { Int32 i = -35000; var bytes = new MsgPackFormatter().Value(i).GetStore().Bytes; Assert.AreEqual(new Byte[] { 0xd2, 0xff, 0xff, 0x77, 0x48 }, bytes.ToEnumerable()); var j = MsgPackParser.Parse(bytes).GetValue(); Assert.AreEqual(i, j); } }
public void int16() { { Int16 i = -150; var bytes = new MsgPackFormatter().Value(i).GetStore().Bytes; Assert.AreEqual(new Byte[] { 0xd1, 0xFF, 0x6a }, bytes.ToEnumerable()); var j = MsgPackParser.Parse(bytes).GetValue(); Assert.AreEqual(i, j); } }
public void int8() { { SByte i = -64; var bytes = new MsgPackFormatter().Value(i).GetStore().Bytes; Assert.AreEqual(new Byte[] { 0xd0, 0xc0, }, bytes.ToEnumerable()); var j = MsgPackParser.Parse(bytes).GetValue(); Assert.AreEqual(i, j); } }