public void UInt16_Overflow_Failure_UpperBound() { var stream = new MemoryStream(); var writer = new BinaryWriter(stream); ulong upper = ushort.MaxValue; writer.WriteVar(upper + 1); writer.Flush(); stream.Position = 0; var reader = new BinaryReader(stream); ushort result = reader.ReadVarUInt16(); Assert.IsTrue(false, "This ought to be unreachable."); }
private void TestValue_SInt32(params int[] values) { var stream = new MemoryStream(); var writer = new BinaryWriter(stream); for (int i = 0; i < values.Length; i += 2) { int value = values[i]; int size = values[i + 1]; long pos = stream.Position; writer.WriteVar(value); writer.Flush(); long newPos = stream.Position; Assert.AreEqual(size, newPos - pos, "Size mismatch for {0}", value); } stream.Position = 0; var reader = new BinaryReader(stream); for (int i = 0; i < values.Length; i += 2) { int value = values[i]; int result = reader.ReadVarInt32(); Assert.AreEqual(value, result); } }
public void SInt32_Overflow_Failure_LowerBound() { var stream = new MemoryStream(); var writer = new BinaryWriter(stream); long lower = int.MinValue; writer.WriteVar(lower - 1); writer.Flush(); stream.Position = 0; var reader = new BinaryReader(stream); int result = reader.ReadVarInt32(); Assert.IsTrue(false, "This ought to be unreachable."); }
public void SInt16_Overflow_Failure_LowerBound() { var stream = new MemoryStream(); var writer = new BinaryWriter(stream); writer.WriteVar(-32769); writer.Flush(); stream.Position = 0; var reader = new BinaryReader(stream); short result = reader.ReadVarInt16(); Assert.IsTrue(false, "This ought to be unreachable."); }