Exemple #1
0
 public override void addKnownField(string name, StringType @string, Annotation annotation)
 {
     switch (name)
     {
     case "number":
         unchecked { new f0(I64.get(), this); }
         return;
     }
 }
Exemple #2
0
        public void Oct()
        {
            Assert.AreEqual("377", Conversion.Oct(System.Byte.MaxValue));
            Assert.AreEqual("0", Conversion.Oct(System.Byte.MinValue));
            Assert.AreEqual("77777", Conversion.Oct(System.Int16.MaxValue));
            Assert.AreEqual("100000", Conversion.Oct(System.Int16.MinValue));
            Assert.AreEqual("17777777777", Conversion.Oct(System.Int32.MaxValue));
            Assert.AreEqual("20000000000", Conversion.Oct(System.Int32.MinValue));
            Assert.AreEqual("777777777777777777777", Conversion.Oct(System.Int64.MaxValue));
            //Assert.AreEqual( "1000000000000000000000", Conversion.Oct(System.Int64.MinValue));

            System.Byte   UI8;
            System.Int16  I16;
            System.Int32  I32;
            System.Int64  I64;
            System.Object O;
            System.String S;

            UI8 = 15;
            Assert.AreEqual("17", Conversion.Oct(UI8));

            I16 = System.Byte.MaxValue;
            Assert.AreEqual("377", Conversion.Oct(I16));

            I16 = (System.Int16)((I16 + 1) * -1);
            Assert.AreEqual("177400", Conversion.Oct(I16));

            I16 = -2;
            Assert.AreEqual("177776", Conversion.Oct(I16));

            I32 = System.UInt16.MaxValue;
            Assert.AreEqual("177777", Conversion.Oct(I32));

            I32 = (I32 + 1) * -1;
            Assert.AreEqual("37777600000", Conversion.Oct(I32));

            I32 = -2;
            Assert.AreEqual("37777777776", Conversion.Oct(I32));

            I64 = System.UInt32.MaxValue;
            Assert.AreEqual("37777777777", Conversion.Oct(I64));

            I64 = (I64 + 1) * -1;
            Assert.AreEqual("1777777777740000000000", Conversion.Oct(I64));

            I64 = -2;
            Assert.AreEqual("1777777777777777777776", Conversion.Oct(I64));

            I16 = System.Byte.MaxValue;
            S   = I16.ToString();
            Assert.AreEqual("377", Conversion.Oct(S));

            I16 = (System.Int16)((I16 + 1) * -1);
            S   = I16.ToString();
            Assert.AreEqual("37777777400", Conversion.Oct(S));

            I16 = -2;
            S   = I16.ToString();
            Assert.AreEqual("37777777776", Conversion.Oct(S));

            I32 = System.UInt16.MaxValue;
            S   = I32.ToString();
            Assert.AreEqual("177777", Conversion.Oct(S));

            I32 = (I32 + 1) * -1;
            S   = I32.ToString();
            Assert.AreEqual("37777600000", Conversion.Oct(S));

            I32 = -2;
            S   = I32.ToString();
            Assert.AreEqual("37777777776", Conversion.Oct(S));

            I64 = System.UInt32.MaxValue;
            S   = I64.ToString();
            Assert.AreEqual("37777777777", Conversion.Oct(S));

            I64 = (I64 + 1) * -1;
            S   = I64.ToString();
            Assert.AreEqual("1777777777740000000000", Conversion.Oct(S));

            UI8 = System.Byte.MaxValue;
            O   = UI8;
            Assert.AreEqual("377", Conversion.Oct(O));

            I16 = System.Byte.MaxValue;
            O   = I16;
            Assert.AreEqual("377", Conversion.Oct(O));

            I16 = (System.Int16)((I16 + 1) * -1);
            O   = I16;
            Assert.AreEqual("177400", Conversion.Oct(O));

            I16 = -2;
            O   = I16;
            Assert.AreEqual("177776", Conversion.Oct(O));

            I32 = System.UInt16.MaxValue;
            O   = I32;
            Assert.AreEqual("177777", Conversion.Oct(O));

            I32 = (I32 + 1) * -1;
            O   = I32;
            Assert.AreEqual("37777600000", Conversion.Oct(O));

            I32 = -2;
            O   = I32;
            Assert.AreEqual("37777777776", Conversion.Oct(O));

            I64 = System.UInt32.MaxValue;
            O   = I64;
            Assert.AreEqual("37777777777", Conversion.Oct(O));

            I64 = (I64 + 1) * -1;
            O   = I64;
            Assert.AreEqual("1777777777740000000000", Conversion.Oct(O));

            I64 = -2;
            O   = I64;

            // FIXME: MS doesn't pass this test
            // Assert.AreEqual( "1777777777777777777776", Conversion.Oct(O));

            O = typeof(int);

            bool caughtException = false;

            try
            {
                Conversion.Oct(O);
            }
            catch (Exception e)
            {
                Assert.AreEqual(typeof(ArgumentException), e.GetType());
                caughtException = true;
            }

            Assert.AreEqual(true, caughtException);

            caughtException = false;

            try
            {
                Conversion.Oct(null);
            }
            catch (Exception e)
            {
                Assert.AreEqual(typeof(ArgumentNullException), e.GetType());
                caughtException = true;
            }

            Assert.AreEqual(true, caughtException);
        }