def test_reset(self): """ Tests the reset function. """ la = LongArray(5) la.reset() self.assertEqual(la.length, 0) self.assertEqual(la.alloc, 5) self.assertEqual(len(la.get_npy_array()), 0)
def test_reset_works_after_set_view(self): # Given src = LongArray() src.extend(numpy.arange(5)) view = LongArray() view.set_view(src, 1, 3) # When. view.reset() view.extend(numpy.arange(3) * 10) # Then. self.assertEqual(view.length, 3) expect = (numpy.arange(3) * 10).tolist() self.assertListEqual(view.get_npy_array().tolist(), expect)