コード例 #1
0
    def test_bool_or_when_source_empty(self):
        '''
        The bool_or method should return false when called on an empty
        BitPack.
        '''
        bp = BitPack(base64.encodestring(b'\x00\x01\x02'))
        empty_pack = BitPack()

        self.assertFalse(empty_pack.bool_or(bp))
        self.assertFalse(empty_pack.bool_or(bp, 1))
コード例 #2
0
    def test_bool_or_with_empty_pack(self):
        '''
        The bool_or method should return true when called with an empty
        BitPack as a parameter.
        '''
        bp = BitPack(base64.encodestring(b'\x00\x01\x02'))
        empty_pack = BitPack()

        self.assertTrue(bp.bool_or(empty_pack))
        self.assertTrue(bp.bool_or(empty_pack, 1))
コード例 #3
0
    def test_bool_or_happy_path_all_zeros(self):
        '''
        The bool_or method should return false when both BitPacks
        contain only zero bits.
        '''
        bp_all_zeros_1 = BitPack(base64.encodestring(b'\x00\x00\x00'))
        bp_all_zeros_2 = BitPack(base64.encodestring(b'\x00\x00\x00'))

        self.assertFalse(bp_all_zeros_1.bool_or(bp_all_zeros_2))
        self.assertFalse(bp_all_zeros_2.bool_or(bp_all_zeros_1))
コード例 #4
0
    def test_bool_or_happy_path_with_one(self):
        '''
        The bool_or method should return true when either BitPack
        contains a one bit.
        '''
        bp_all_zeros = BitPack(base64.encodestring(b'\x00\x00\x00'))
        bp1 = BitPack(base64.encodestring(b'\x00\x01\x02'))

        self.assertTrue(bp_all_zeros.bool_or(bp1))
        self.assertTrue(bp1.bool_or(bp_all_zeros))
コード例 #5
0
    def test_bool_or_when_reading_past_data_boundary(self):
        '''
        The bool_or method should return false if the operation would
        require reading past the data boundary.
        '''
        bp1 = BitPack(base64.encodestring(b'\x00\x01\x02'))
        bp2 = BitPack(base64.encodestring(b'\x00\x01\x02\x04'))
        bp3 = BitPack(base64.encodestring(b'\x00\x01\x02'))

        self.assertFalse(bp1.bool_or(bp2))
        self.assertFalse(bp1.bool_or(bp3, 1))
コード例 #6
0
    def test_bool_or_empty_pack_parameter_precendence(self):
        '''
        Returning true for an empty parameter should take precendence
        over returning false for calling bool_or on an empty BitPack.
        '''
        bp1 = BitPack()
        bp2 = BitPack()

        self.assertTrue(bp1.bool_or(bp2))
コード例 #7
0
    def test_bool_or_contains_one_bit_by_offset(self):
        '''
        The bool_or method should return true when a one bit is
        contained by offset.
        '''
        bp1 = BitPack(base64.encodestring(b'\x00\x00\x01\x00'))
        bp2 = BitPack(base64.encodestring(b'\x00\x00'))

        self.assertTrue(bp1.bool_or(bp2, 1))