public void TryRead_Fail_NullStreamTest() { bool b = StackInt.TryRead(null, out _, out StackInt actual, out string error); Assert.False(b); Assert.Equal("Stream can not be null.", error); Helper.ComparePrivateField(actual, "value", 0U); }
public void TryRead_StrictTest(byte[] data, int finalPos, uint expected) { FastStreamReader stream = new FastStreamReader(data); bool b = StackInt.TryRead(stream, true, out StackInt actual, out string error); Assert.True(b); Assert.Null(error); Helper.ComparePrivateField(stream, "position", finalPos); Helper.ComparePrivateField(actual, "value", expected); }
public void TryRead_FailStrictTest(byte[] data, int finalPos, string expError) { FastStreamReader stream = new FastStreamReader(data); bool b = StackInt.TryRead(stream, true, out StackInt actual, out string error); Assert.False(b); Assert.Equal(expError, error); Helper.ComparePrivateField(stream, "position", finalPos); Helper.ComparePrivateField(actual, "value", 0U); }
public void TryReadTest(byte[] data, bool expSuccess, byte[] expBytes, string expErr, int finalPos, uint expected) { var stream = new FastStreamReader(data); bool actSuccess = StackInt.TryRead(stream, out byte[] actBytes, out StackInt actual, out string error); Assert.Equal(expSuccess, actSuccess); Assert.Equal(expBytes, actBytes); Assert.Equal(expErr, error); Helper.ComparePrivateField(stream, "position", finalPos); Helper.ComparePrivateField(actual, "value", expected); }