public void MaxUInt32TwiceToBytes() { Integer256 value = new Integer256(); var newvalue = value.Add(UInt32.MaxValue).Add(UInt32.MaxValue); var result = newvalue.ToBytes(); AreEqual(result, new byte[] { 0x01, 0xff, 0xff, 0xff, 0xfe }); }
public void AddOneToOne() { var one = new Integer256().Add(1); var value = one.Add(one); var result = value.ToBytes(); AreEqual(result, new byte[] { 0x02 }); }
public void MaxUInt32PlusOneToBytes() { Integer256 value = new Integer256(); var newvalue = value.Add(UInt32.MaxValue).Add(1); var result = newvalue.ToBytes(); AreEqual(result, new byte[] { 0x01, 0x00, 0x00, 0x00, 0x00 }); }
public void EqualsAndHash() { var zero = new Integer256(); var one1 = new Integer256().Add(1); var one2 = new Integer256().Add(1); var minusone = one1.Negate(); Assert.IsFalse(zero.Equals(null)); Assert.IsFalse(zero.Equals("Foo")); Assert.IsFalse(zero.Equals(0)); Assert.IsFalse(zero.Equals(one1)); Assert.IsFalse(zero.Equals(minusone)); Assert.IsFalse(one1.Equals(minusone)); Assert.IsTrue(zero.Equals(zero)); Assert.IsTrue(one1.Equals(one2)); Assert.IsTrue(one2.Equals(one1)); Assert.AreEqual(one1.GetHashCode(), one2.GetHashCode()); }
private static void PushDupPop(uint times) { IList<Byte> bytes = new List<byte>(); for (int k = 0; k < times; k++) { bytes.Add((byte)Bytecodes.Push1); bytes.Add((byte)k); } bytes.Add((byte)(Bytecodes.Dup1 + (int)times - 1)); Machine machine = new Machine(); machine.Execute(bytes.ToArray()); Integer256 value = new Integer256(times); Assert.AreEqual(Integer256.Zero, machine.Stack.Pop()); for (int k = 0; k < times; k++) { value = value.Subtract(Integer256.One); Assert.AreEqual(value, machine.Stack.Pop()); } Assert.AreEqual(0, machine.Stack.Size); }
public void NegateOne() { Integer256 value = new Integer256().Add(1).Negate(); var result = value.ToBytes(); AreEqual(result, new byte[] { }, true); }
public void ZeroToBytes() { Integer256 value = new Integer256(); var result = value.ToBytes(); AreEqual(result, new byte[] { }); }
public void SubtractOneFromZero() { var zero = new Integer256(); var value = zero.Subtract(new Integer256().Add(1)); var result = value.ToBytes(); AreEqual(result, new byte[] { }, true); }
public void SubtractOneFromOne() { var one = new Integer256().Add(1); var value = one.Subtract(one); var result = value.ToBytes(); AreEqual(result, new byte[] { }); }
public void OneToBytes() { Integer256 value = new Integer256(); var newvalue = value.Add(1); var result = newvalue.ToBytes(); AreEqual(result, new byte[] { 0x01 }); }