Esempio n. 1
0
 public void PowerOf2CeilingOfNegativeShouldReturn1()
 {
     Assert.AreEqual(1, Base2Math.PowerOf2Ceiling((sbyte)-10), "sbyte");
     Assert.AreEqual(1, Base2Math.PowerOf2Ceiling((short)-10), "short");
     Assert.AreEqual(1, Base2Math.PowerOf2Ceiling((int)-10), "int");
     Assert.AreEqual(1, Base2Math.PowerOf2Ceiling((long)-10), "long");
 }
Esempio n. 2
0
 public void PowerOf2CeilingOfMaxValueShouldReturn0()
 {
     Assert.AreEqual(0, Base2Math.PowerOf2Ceiling(byte.MaxValue), "byte");
     Assert.AreEqual(0, Base2Math.PowerOf2Ceiling(sbyte.MaxValue), "sbyte");
     Assert.AreEqual(0, Base2Math.PowerOf2Ceiling(ushort.MaxValue), "ushort");
     Assert.AreEqual(0, Base2Math.PowerOf2Ceiling(short.MaxValue), "short");
     Assert.AreEqual(0, Base2Math.PowerOf2Ceiling(uint.MaxValue), "uint");
     Assert.AreEqual(0, Base2Math.PowerOf2Ceiling(int.MaxValue), "int");
     Assert.AreEqual(0, Base2Math.PowerOf2Ceiling(ulong.MaxValue), "ulong");
     Assert.AreEqual(0, Base2Math.PowerOf2Ceiling(long.MaxValue), "long");
     Assert.AreEqual(UInt128.Zero, Base2Math.PowerOf2Ceiling(UInt128.MaxValue), "UInt128");
 }
Esempio n. 3
0
 public void PowerOf2CeilingOf3ShouldReturn4()
 {
     Assert.AreEqual(4, Base2Math.PowerOf2Ceiling((byte)3), "byte");
     Assert.AreEqual(4, Base2Math.PowerOf2Ceiling((sbyte)3), "sbyte");
     Assert.AreEqual(4, Base2Math.PowerOf2Ceiling((ushort)3), "ushort");
     Assert.AreEqual(4, Base2Math.PowerOf2Ceiling((short)3), "short");
     Assert.AreEqual(4, Base2Math.PowerOf2Ceiling((uint)3), "uint");
     Assert.AreEqual(4, Base2Math.PowerOf2Ceiling((int)3), "int");
     Assert.AreEqual(4, Base2Math.PowerOf2Ceiling((ulong)3), "ulong");
     Assert.AreEqual(4, Base2Math.PowerOf2Ceiling((long)3), "long");
     Assert.AreEqual((UInt128)4, Base2Math.PowerOf2Ceiling((UInt128)3), "UInt128");
 }
Esempio n. 4
0
 public void PowerOf2CeilingOf0ShouldReturn1()
 {
     Assert.AreEqual(1, Base2Math.PowerOf2Ceiling((byte)0), "byte");
     Assert.AreEqual(1, Base2Math.PowerOf2Ceiling((sbyte)0), "sbyte");
     Assert.AreEqual(1, Base2Math.PowerOf2Ceiling((ushort)0), "ushort");
     Assert.AreEqual(1, Base2Math.PowerOf2Ceiling((short)0), "short");
     Assert.AreEqual(1, Base2Math.PowerOf2Ceiling((uint)0), "uint");
     Assert.AreEqual(1, Base2Math.PowerOf2Ceiling((int)0), "int");
     Assert.AreEqual(1, Base2Math.PowerOf2Ceiling((ulong)0), "ulong");
     Assert.AreEqual(1, Base2Math.PowerOf2Ceiling((long)0), "long");
     Assert.AreEqual((UInt128)1, Base2Math.PowerOf2Ceiling((UInt128)0), "UInt128");
 }
Esempio n. 5
0
        public void PowerOf2CeilingSignedByteShouldMatchWider()
        {
            sbyte v = sbyte.MinValue;

            while (true)
            {
                sbyte expected = Base2Math.PowerOf2Ceiling(v);
                Assert.AreEqual(expected, Base2Math.PowerOf2Ceiling((short)v), "short=>" + v);
                Assert.AreEqual(expected, Base2Math.PowerOf2Ceiling((int)v), "int=>" + v);
                Assert.AreEqual(expected, Base2Math.PowerOf2Ceiling((long)v), "long=>" + v);
                if (v == sbyte.MaxValue >> 1)
                {
                    break;
                }
                v++;
            }
        }