def test_reservior_buffer_insert_all(self): buffer_size = 10 patient = rcfr.ReservoirBuffer(buffer_size) x_buffer = list(range(buffer_size)) patient.insert_all(x_buffer) assert patient.num_elements == buffer_size self.assertAllEqual(x_buffer, patient.buffer) assert patient.num_available_spaces() == 0 x_buffer = list(range(buffer_size, 2 * buffer_size)) patient.insert_all(x_buffer) assert patient.num_elements == buffer_size
def test_reservior_buffer_insert(self): buffer_size = 10 patient = rcfr.ReservoirBuffer(buffer_size) x_buffer = [] for i in range(buffer_size): patient.insert(i) x_buffer.append(i) assert patient.num_elements == len(x_buffer) self.assertAllEqual(x_buffer, patient.buffer) assert patient.num_available_spaces() == 0 for i in range(buffer_size): patient.insert(buffer_size + i) assert patient.num_elements == buffer_size