def test_initialize_params(self): ''' Test that buffer init params are returned correctly ''' random_size = random.randrange(1, 100) buffer = RingBuffer(random_size) self.assertEqual(buffer.get_capacity(), random_size) self.assertFalse(buffer.is_full()) self.assertTrue(buffer.is_empty()) self.assertEqual(buffer.get_buffer_fill(), 0)
def test_clear(self): ''' Test that clear() method clears the buffer properly ''' random_size = random.randrange(1, 100) buffer = RingBuffer(random_size) for i in range(0, random.randrange(1, random_size)): buffer.push(i) buffer.clear() self.assertTrue(buffer.is_empty()) self.assertFalse(buffer.is_full()) self.assertEqual(buffer.get_capacity(), random_size) self.assertEqual(buffer.get_buffer_fill(), 0)