コード例 #1
0
    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)
コード例 #2
0
    def test_get_capacity(self):
        '''
        Test that get_capacity method
        returns correct values
        '''
        random_size = random.randrange(1, 100)
        buffer = RingBuffer(random_size)
        for i in range(0, random.randrange(1, random_size)):
            buffer.push(i)

        buffer_capacity = buffer.get_capacity()
        self.assertEqual(buffer_capacity, random_size)
コード例 #3
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)