public void NegativeZero() {
			SignedInt positive0 = new SignedInt(new byte[] { 0x00 });
			SignedInt negative0 = new SignedInt(new byte[] { 0x80 });

			Assert.AreEqual(0, positive0.Value);
			Assert.AreEqual(0, negative0.Value);
			Assert.AreEqual(negative0.ToByteArray(), positive0.ToByteArray());
		}
示例#2
0
        public void NegativeZero()
        {
            SignedInt positive0 = new SignedInt(new byte[] { 0x00 });
            SignedInt negative0 = new SignedInt(new byte[] { 0x80 });

            Assert.AreEqual(0, positive0.Value);
            Assert.AreEqual(0, negative0.Value);
            Assert.AreEqual(negative0.ToByteArray(), positive0.ToByteArray());
        }
示例#3
0
 public static void compare(SignedInt obj1, SignedInt obj2)
 {
     for (int i = 0; i < obj1.list1.Count; i++)
     {
         //System.Console.Write("Ser = " + obj1.list1[i] + ", Deser = " + obj2.list1[i] + "\n");
         Assert.AreEqual(obj1.list1[i], obj2.list1[i]);
     }
     for (int i = 0; i < obj1.list2.Count; i++)
     {
         //System.Console.Write("Ser = " + obj1.list2[i] + ", Deser = " + obj2.list2[i] + "\n");
         Assert.AreEqual(obj1.list2[i], obj2.list2[i]);
     }
 }
示例#4
0
        public static void Main(String[] args)
        {
            System.Console.Write("Test Signed Int  \n");
            SignedInt ser = buildObj();
            serialize(ser);
            byte[] res = deserialize();

            SignedInt deser = new SignedInt();
            deser.deserialize(new MemoryStream(res));

            compare(ser, deser);

            //System.Console.Read();
        }
示例#5
0
        public static SignedInt buildObj()
        {
            SignedInt obj = new SignedInt();
            obj.list1.Add(-1);
            obj.list1.Add(-2);
            obj.list1.Add(-3);
            obj.list1.Add(int.MaxValue);
            obj.list1.Add(int.MinValue);

            obj.list2.Add(-1);
            obj.list2.Add(-2);
            obj.list2.Add(-3);
            obj.list2.Add( (long) Math.Pow(2, 53) -1 );
            obj.list2.Add( (long) (Math.Pow(2, 53) - Math.Pow(2, 54)) );
            return obj;
        }