예제 #1
0
class TestByteMap(unittest.TestCase):

    def setUp(self):
        self.tbm = ByteMap(15, 'a')

    def test_classify(self):
        b = Chunk(5, 10, 'b')

        overlaps = self.tbm.classify(b)

        self.assertTrue('a' in overlaps[0])
        self.assertTrue('b' not in overlaps[0])
        self.assertTrue('a' in overlaps[1])
        self.assertTrue('b' in overlaps[1])
        self.assertTrue('a' in overlaps[2])
        self.assertTrue('b' not in overlaps[2])

    def test_missing(self):
        b = Chunk(5, 10, 'b')

        needed = self.tbm.missing(b)
        self.assertEqual(len(needed), 2)

        for c in needed:
            self.assertTrue('a' in c)
            self.assertTrue('b' not in c)

    def test_add(self):
        b = Chunk(5, 10, 'b')

        self.tbm.add(b)
        tbm_chunks = self.tbm.chunks
        self.assertEqual(len(tbm_chunks), 3) 
        
        self.assertTrue('a' in tbm_chunks[0])
        self.assertTrue('b' not in tbm_chunks[0])
        self.assertTrue('a' in tbm_chunks[1])
        self.assertTrue('b' in tbm_chunks[1])
        self.assertTrue('a' in tbm_chunks[2])
        self.assertTrue('b' not in tbm_chunks[2])
예제 #2
0
 def setUp(self):
     self.tbm = ByteMap(15, 'a')