public void From_bytes() { Assert.That(VariableLengthQuantity.FromBytes(new[] { 0x7fu }), Is.EqualTo(new[] { 0x7fu })); Assert.That(VariableLengthQuantity.FromBytes(new[] { 0xc0u, 0x00u }), Is.EqualTo(new[] { 0x2000u })); Assert.That(VariableLengthQuantity.FromBytes(new[] { 0xffu, 0xffu, 0x7fu }), Is.EqualTo(new[] { 0x1fffffu })); Assert.That(VariableLengthQuantity.FromBytes(new[] { 0x81u, 0x80u, 0x80u, 0x00u }), Is.EqualTo(new[] { 0x200000u })); Assert.That(VariableLengthQuantity.FromBytes(new[] { 0x8fu, 0xffu, 0xffu, 0xffu, 0x7fu }), Is.EqualTo(new[] { 0xffffffffu })); }
public void Chained_execution_is_identity() { var test = new[] { 0xf2u, 0xf6u, 0x96u, 0x9cu, 0x3bu, 0x39u, 0x2eu, 0x30u, 0xb3u, 0x24u }; Assert.That(VariableLengthQuantity.FromBytes(VariableLengthQuantity.ToBytes(test)), Is.EquivalentTo(test)); }
public void Overflow() { Assert.That(() => VariableLengthQuantity.FromBytes(new[] { 0xffu, 0xffu, 0xffu, 0xffu, 0x7fu }), Throws.Exception); }
public void Incomplete_byte_sequence() { Assert.That(() => VariableLengthQuantity.FromBytes(new[] { 0xffu }), Throws.Exception); }
public void From_bytes_multiple_values() { Assert.That(VariableLengthQuantity.FromBytes(new[] { 0xc0u, 0x00u, 0xc8u, 0xe8u, 0x56u, 0xffu, 0xffu, 0xffu, 0x7fu, 0x00u, 0xffu, 0x7fu, 0x81u, 0x80u, 0x00u }), Is.EqualTo(new[] { 0x2000u, 0x123456u, 0x0fffffffu, 0x00u, 0x3fffu, 0x4000u })); }
public void Overflow() { Assert.Throws <InvalidOperationException>(() => VariableLengthQuantity.FromBytes(new[] { 0xffu, 0xffu, 0xffu, 0xffu, 0x7fu })); }
public void Incomplete_byte_sequence() { Assert.Throws <InvalidOperationException>(() => VariableLengthQuantity.FromBytes(new[] { 0xffu })); }