holopy3/Assets/UniGLTF/UniJSON/Editor/Tests/MsgPack/StringTest.cs

33 lines
835 B
C#
Raw Normal View History

2021-01-28 12:07:52 +00:00
using NUnit.Framework;
using System;
using System.Linq;
namespace UniJSON.MsgPack
{
[TestFixture]
public class StringTest
{
[Test]
public void str()
{
var bytes = new MsgPackFormatter().Value("文字列").GetStore().Bytes;
var v = MsgPackParser.Parse(bytes).GetValue();
Assert.AreEqual("文字列", v);
}
[Test]
public void fix_str()
{
for (int i = 1; i < 32; ++i)
{
var str = String.Join("", Enumerable.Range(0, i).Select(_ => "0").ToArray());
var bytes = new MsgPackFormatter().Value(str).GetStore().Bytes;
var value = MsgPackParser.Parse(bytes);
Assert.AreEqual(i, ((String)value.GetValue()).Length);
}
}
}
}