Ejemplo n.º 1
0
 def test_initialization(self):
     p = m.Vector2dList()
     self.assertEqual(len(p), 0)
     p = m.Vector2dList([[1, 1]])
     self.assertEqual(len(p), 1)
     with self.assertRaises(RuntimeError):
         p = m.Vector2dList([1, 2, 3])
Ejemplo n.º 2
0
 def test_is_subscribable(self):
     p = m.Vector2dList([[1, 2], [3, 4]])
     self.assertEqual(len(p), 2)
     npt.assert_almost_equal(p[0], [1, 2])
     npt.assert_almost_equal(p[1], [3, 4])
     p[0] = [0, 0]
     npt.assert_almost_equal(p[0], [0, 0])
Ejemplo n.º 3
0
 def test_is_extendable(self):
     p = m.Vector2dList()
     p.append([1, 2])
     p.extend([[3, 4], [5, 6]])
     self.assertEqual(len(p), 3)
     npt.assert_almost_equal(p[0], [1, 2])
     npt.assert_almost_equal(p[1], [3, 4])
     npt.assert_almost_equal(p[2], [5, 6])
Ejemplo n.º 4
0
 def test_is_popable(self):
     p = m.Vector2dList([[0, 0], [1, 1], [2, 2]])
     npt.assert_almost_equal(p.pop(), [2, 2])
     self.assertEqual(len(p), 2)
     npt.assert_almost_equal(p.pop(1), [1, 1])
     self.assertEqual(len(p), 1)
     npt.assert_almost_equal(p.pop(0), [0, 0])
     self.assertEqual(len(p), 0)
     with self.assertRaises(IndexError):
         p.pop()
Ejemplo n.º 5
0
 def test_is_iterable(self):
     p = m.Vector2dList([[0, 0], [1, 1], [2, 2]])
     for i, v in p:
         npt.assert_almost_equal(v, [i, i])
Ejemplo n.º 6
0
 def test_is_clearable(self):
     p = m.Vector2dList([[1, 1]])
     self.assertEqual(len(p), 1)
     p.clear()
     self.assertEqual(len(p), 0)