public void StringTest_Part() { var a = "身无彩凤双飞翼,心有灵犀一点通。"; var b = new String('笑', 20); var c = new String('风', 130); var d = new String('电', 40000); var idx = 0; var writer = new MessagePackWriter(16); writer.WriteString(a, ref idx); idx.Is(Encoding.UTF8.GetByteCount(a) + 2); var reader = new MessagePackReader(writer.ToArray(idx)); reader.ReadString().Is(a); writer = new MessagePackWriter(16); idx = 0; writer.WriteStringWithCache(a, ref idx); idx.Is(Encoding.UTF8.GetByteCount(a) + 2); reader = new MessagePackReader(writer.ToArray(idx)); reader.ReadStringWithCache().Is(a); writer = new MessagePackWriter(16); idx = 0; writer.WriteString(b, ref idx); idx.Is(Encoding.UTF8.GetByteCount(b) + 2); reader = new MessagePackReader(writer.ToArray(idx)); reader.ReadString().Is(b); writer = new MessagePackWriter(16); idx = 0; writer.WriteStringWithCache(b, ref idx); idx.Is(Encoding.UTF8.GetByteCount(b) + 2); reader = new MessagePackReader(writer.ToArray(idx)); reader.ReadStringWithCache().Is(b); writer = new MessagePackWriter(16); idx = 0; writer.WriteString(c, ref idx); idx.Is(Encoding.UTF8.GetByteCount(c) + 3); reader = new MessagePackReader(writer.ToArray(idx)); reader.ReadString().Is(c); writer = new MessagePackWriter(16); idx = 0; writer.WriteString(d, ref idx); idx.Is(Encoding.UTF8.GetByteCount(d) + 5); reader = new MessagePackReader(writer.ToArray(idx)); reader.ReadString().Is(d); }