Exemplo n.º 1
0
    def test_close_does_flush(self):
        """
        Tests that a close does flush
        """
        bitmap = cBitmap(16, "testccloseflush.mmap")
        for bit in xrange(16*8):
            bitmap[bit] = 1
        bitmap.close()
        bitmap = None

        bitmap = cBitmap(16, "testccloseflush.mmap")
        for bit in xrange(16*8):
            assert bitmap[bit] == 1
        bitmap.close()
Exemplo n.º 2
0
    def test_private_not_shared(self):
        """
        Tests that an open with private does not share data
        """
        bitmap = cBitmap(16, "testprivateshared.mmap", private=True)
        for bit in xrange(16*8):
            bitmap[bit] = 1

        bitmap2 = cBitmap(16, "testprivateshared.mmap", private=True)
        for bit in xrange(16*8):
            assert bitmap2[bit] == 0

        bitmap.close()
        bitmap2.close()
Exemplo n.º 3
0
    def test_private_noop_flush(self):
        """
        Tests that a close/flush with private is a noop.
        """
        bitmap = cBitmap(16, "testcclosenoopflush.mmap", private=True)
        for bit in xrange(16*8):
            bitmap[bit] = 1
        bitmap.flush()
        bitmap.close()
        bitmap = None

        bitmap = cBitmap(16, "testcclosenoopflush.mmap", private=True)
        for bit in xrange(16*8):
            assert bitmap[bit] == 0
        bitmap.close()
Exemplo n.º 4
0
    def test_flush(self):
        """
        Tests that a flushes flushes the contents
        """
        bitmap = cBitmap(16, "testcflush.mmap")
        for bit in xrange(16*8):
            bitmap[bit] = 1
        bitmap.flush()

        bitmap1 = cBitmap(16, "testcflush.mmap")
        for bit in xrange(16*8):
            assert bitmap1[bit] == 1

        bitmap.close()
        bitmap1.close()
Exemplo n.º 5
0
 def test_flushclose(self):
     """
     Tests that a flush and close does not cause issues
     """
     bitmap = cBitmap(16)
     bitmap.flush()
     bitmap.close()
Exemplo n.º 6
0
 def test_doubleclose(self):
     """
     Tests that a double close does not cause problems
     """
     bitmap = cBitmap(16)
     bitmap.close()
     bitmap.close()
Exemplo n.º 7
0
 def test_all_zero(self):
     """
     Tests that a BitMap starts out with all zeros.
     """
     bitmap = cBitmap(16)
     for bit in xrange(16 * 8):
         assert 0 == bitmap[bit]
Exemplo n.º 8
0
 def test_get_length(self):
     """
     Tests that the length of the BitMap is the same number
     of bytes as those used to create the BitMap. Handle the bit/byte
     conversion.
     """
     bitmap = cBitmap(16)
     assert 16*8 == len(bitmap)
Exemplo n.º 9
0
    def test_set_item(self):
        """
        Tests that a bit can be properly set and retrieved.
        """
        bitmap = cBitmap(16)

        assert 0 == bitmap[0]
        bitmap[0] = 1
        assert 1 == bitmap[0]
        for bit in xrange(1,16 * 8):
            assert 0 == bitmap[bit]
Exemplo n.º 10
0
    def test_setslice(self):
        """
        Tests that a slice can be properly set and retrieved
        """
        bitmap = cBitmap(16)

        # Set all the bits to 1
        for bit in xrange(16 * 8):
            bitmap[bit] = 1

        bitmap[0:4] = "test"
        assert bitmap[0:4] == "test"

        for bit in xrange(4*8,16 * 8):
            assert 1 == bitmap[bit]