public void NeverUsedRead() { var e = Should.Throw <ArgumentOutOfRangeException>(() => MsgPackSpec.ReadToken(new [] { DataCodes.NeverUsed }.ToSingleSegment())); e.Message.ShouldBe($"Data code at sequence[0] is 0xc1 and it is invalid data code.{Environment.NewLine}Parameter name: sequence"); e.ParamName.ShouldBe("sequence"); }
public void EmptyRead() { var e = Should.Throw <ArgumentOutOfRangeException>(() => MsgPackSpec.ReadToken(System.Array.Empty <byte>().ToSingleSegment())); e.Message.ShouldBe($"EOF: Sequence is empty.{Environment.NewLine}Parameter name: sequence"); e.ParamName.ShouldBe("sequence"); }
public void EmptyRead() { var e = Should.Throw <ArgumentOutOfRangeException>(() => MsgPackSpec.ReadToken(System.Array.Empty <byte>())); e.Message.ShouldBe($"EOF: Buffer is empty.{Environment.NewLine}Parameter name: buffer"); e.ParamName.ShouldBe("buffer"); }
public void NonEmptyRead(byte[] data, int objectsCount) { var buffer = data.ToSingleSegment(); for (var i = 0; i < objectsCount; i++) { buffer = buffer.Slice(MsgPackSpec.ReadToken(buffer).Length); } buffer.IsEmpty.ShouldBeTrue(); }
public void NonEmptyRead(byte[] data, int objectsCount) { ReadOnlySpan <byte> buffer = data; for (var i = 0; i < objectsCount; i++) { buffer = buffer.Slice(MsgPackSpec.ReadToken(buffer).Length); } buffer.IsEmpty.ShouldBeTrue(); }
public void DeepStack(int depth) { var buffer = new byte[depth]; var span = buffer.AsSpan(); while (span.Length > 1) { span = span.Slice(MsgPackSpec.WriteFixArrayHeader(span, 1)); } MsgPackSpec.WritePositiveFixInt(span, 1); var token = MsgPackSpec.ReadToken(buffer.ToSingleSegment()); token.Length.ShouldBe(buffer.Length); }