Exemple #1
0
    def test_add(self):
        '''An non-full ring buffer should contain everything inserted into it
        ''' 
        rb = RingBuffer(3)

        rb.add(1)
        self.assertListEqual(rb.toList(), [1])
        rb.add(2)
        rb.add(3)
        self.assertListEqual(rb.toList(), [1,2,3])
Exemple #2
0
    def test_add_full(self):
        '''A full ring buffer should remove the oldest element after a new add
        '''
        rb = RingBuffer(3)

        rb.add(1)
        rb.add(2)
        rb.add(3)
        rb.add(4)
        self.assertListEqual(rb.toList(),[2,3,4])