def test_array_append(self): s = FloatArray([1, 2, 3]) s.append(4) s.append(10) self.assertEqual(s.byte_length(), 20) self.assertListEqual(s.values(), [1, 2, 3, 4, 10]) s.free()
def test_use_array_after_free_error(self): s = FloatArray() s.free() with self.assertRaises(GaugedUseAfterFreeError): len(s) with self.assertRaises(GaugedUseAfterFreeError): s.values() with self.assertRaises(GaugedUseAfterFreeError): s.values() with self.assertRaises(GaugedUseAfterFreeError): s.append(1) with self.assertRaises(GaugedUseAfterFreeError): s.byte_length() with self.assertRaises(GaugedUseAfterFreeError): s.buffer() with self.assertRaises(GaugedUseAfterFreeError): s.clear()
def test_array_clear(self): s = FloatArray([1, 2, 3]) self.assertEqual(s.byte_length(), 12) s.clear() self.assertEqual(s.byte_length(), 0) s.free()
def test_array_instantiation_from_list(self): s = FloatArray([1, 2, 3]) self.assertEqual(s.byte_length(), 12) self.assertEqual(len(s), 3) self.assertListEqual(s.values(), [1, 2, 3]) s.free()
def test_array_empty_array(self): s = FloatArray() self.assertEqual(s.byte_length(), 0) self.assertEqual(len(s), 0) self.assertListEqual(s.values(), []) s.free()