Exemplo n.º 1
0
        public void TestOne()
        {
            Assert.AreEqual(1, CountBits.CountOnes(1));

            Assert.AreEqual(1, CountBits.CountOnesUsingBitShift(1));

            Assert.AreEqual(0, CountBits.CountOnes(0));
            Assert.AreEqual(0, CountBits.CountZeroes(1));
            Assert.AreEqual(1, CountBits.CountZeroes(0));

            Assert.AreEqual(8, CountBits.CountOnes(10000000));
            Assert.AreEqual(16, CountBits.CountZeroes(10000000));

            Assert.AreEqual(6, CountBits.CountOnes(9741));

            Assert.AreEqual(31, CountBits.CountOnes(int.MaxValue));

            Assert.AreEqual(31, CountBits.CountOnesUsingBitShift(int.MaxValue));
        }
Exemplo n.º 2
0
 public void TestProp()
 {
     Assert.AreEqual(2, CountBits.CountOnes(3));
     Assert.AreEqual(3, CountBits.CountOnes(7));
     Assert.AreEqual(1, CountBits.CountOnes(4));
 }