Beispiel #1
0
    def test_bitlen_neg(self):
        # Not meant to be called with other values than int or long
        self.failUnlessRaises(AttributeError, ar._bitlen, 0.0)

        self.assertEqual(ar._bitlen(-1), 1)
        self.assertEqual(ar._bitlen(-0b1), 1)
        self.assertEqual(ar._bitlen(-0), 0)
        self.assertEqual(ar._bitlen(-0b0), 0)

        self.failUnlessEqual(ar._bitlen(-8), 4)
        self.failUnlessEqual(ar._bitlen(-8L), 4)
    def test_bitlen_pos(self):
	self.failUnlessEqual(ar._bitlen(0b1), 1)
	self.failUnlessEqual(ar._bitlen(0b0), 0) #this might be confusing

        self.failUnlessEqual(ar._bitlen(0b1111), 4) 
	self.failUnlessEqual(ar._bitlen(0b1000), 4)
	self.failUnlessEqual(ar._bitlen(8),4)
	self.failUnlessEqual(ar._bitlen(8L),4)

	self.failUnlessEqual(ar._bitlen(0b10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000010100001),284)
        self.failUnlessEqual(ar._bitlen(15541351137805832567355695254588151253139254712417116170014499277911234281641667989665L),284)
    def test_bitlen_neg(self): 
        # Not meant to be called with other values than int or long
	self.failUnlessRaises(AttributeError, ar._bitlen, 0.0) 
	
	self.assertEqual(ar._bitlen(-1),1)
	self.assertEqual(ar._bitlen(-0b1),1)
	self.assertEqual(ar._bitlen(-0),0)
	self.assertEqual(ar._bitlen(-0b0),0)
	
	self.failUnlessEqual(ar._bitlen(-8),4)
	self.failUnlessEqual(ar._bitlen(-8L),4)
Beispiel #4
0
    def test_bitlen_pos(self):
        self.failUnlessEqual(ar._bitlen(0b1), 1)
        self.failUnlessEqual(ar._bitlen(0b0), 0)  #this might be confusing

        self.failUnlessEqual(ar._bitlen(0b1111), 4)
        self.failUnlessEqual(ar._bitlen(0b1000), 4)
        self.failUnlessEqual(ar._bitlen(8), 4)
        self.failUnlessEqual(ar._bitlen(8L), 4)

        self.failUnlessEqual(
            ar._bitlen(
                0b10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000010100001
            ), 284)
        self.failUnlessEqual(
            ar._bitlen(
                15541351137805832567355695254588151253139254712417116170014499277911234281641667989665L
            ), 284)