Exemplo n.º 1
0
    def test_write_full_buffer(self):
        self.buffer = cechomesh.PyRingBufferIndex(32, 0, 31)

        self.assertTrue(self.buffer.write(1), [(31, 32)])
        self.assertEqual(self.buffer.begin(), 0)
        self.assertEqual(self.buffer.end(), 0)
        self.assertEqual(self.buffer.available(), 32)
        self.assertTrue(self.buffer.write(1), [(0, 1)])
        self.assertEqual(self.buffer.available(), 32)
Exemplo n.º 2
0
 def setUp(self):
     self.buffer = cechomesh.PyRingBufferIndex(32)
Exemplo n.º 3
0
 def test_read_wrap_underrun(self):
     self.buffer = cechomesh.PyRingBufferIndex(32, 28, 4)
     self.assertTrue(self.buffer.read(12), [(28, 32), (0, 4)])
     self.assertEqual(self.buffer.available(), 0)
Exemplo n.º 4
0
 def test_read_underrun(self):
     self.buffer = cechomesh.PyRingBufferIndex(32, 0, 8)
     self.assertTrue(self.buffer.read(10), [(0, 8)])
     self.assertEqual(self.buffer.available(), 0)
     self.assertEqual(self.buffer.begin(), 8)
     self.assertEqual(self.buffer.end(), 8)
Exemplo n.º 5
0
 def test_simple_read(self):
     self.buffer = cechomesh.PyRingBufferIndex(32, 0, 8)
     self.assertTrue(self.buffer.read(6), [(0, 6)])
     self.assertEqual(self.buffer.available(), 2)
Exemplo n.º 6
0
 def test_write_wrap(self):
     self.buffer = cechomesh.PyRingBufferIndex(32, 24, 8)
     self.assertEqual(self.buffer.available(), 16)
     self.assertTrue(self.buffer.write(12), [(24, 32), (0, 8)])
     self.assertEqual(self.buffer.available(), 28)
Exemplo n.º 7
0
 def test_write_overrun(self):
     self.buffer = cechomesh.PyRingBufferIndex(32, 0, 31)
     self.assertTrue(self.buffer.write(2), [(31, 32), (0, 1)])
     self.assertEqual(self.buffer.available(), 32)