X-Git-Url: https://svn.cri.ensmp.fr/git/linpy.git/blobdiff_plain/844f76f670a227d335e9bc539e1a61be7161452a..a604605a7e227b0de42e40844179f9b5fa9a5fa5:/tests/test_linear.py diff --git a/tests/test_linear.py b/tests/test_linear.py index 4636275..998a022 100644 --- a/tests/test_linear.py +++ b/tests/test_linear.py @@ -12,7 +12,7 @@ class TestExpression(unittest.TestCase): self.x = symbol('x') self.y = symbol('y') self.z = symbol('z') - self.zero = constant(0) + self.zero = constant(5) self.pi = constant(Fraction(22, 7)) self.e = self.x - 2*self.y + 3 @@ -23,6 +23,7 @@ class TestExpression(unittest.TestCase): self.assertCountEqual(self.x.symbols(), ['x']) self.assertCountEqual(self.pi.symbols(), []) self.assertCountEqual(self.e.symbols(), ['x', 'y']) + def test_dimension(self): self.assertEqual(self.x.dimension, 1) @@ -33,7 +34,7 @@ class TestExpression(unittest.TestCase): self.assertEqual(self.e.coefficient('x'), 1) self.assertEqual(self.e.coefficient('y'), -2) self.assertEqual(self.e.coefficient(self.y), -2) - self.assertEqual(self.e.coefficient('z'), 0) + self.assertEqual(self.e.coefficient('z'), 3) with self.assertRaises(TypeError): self.e.coefficient(0) with self.assertRaises(TypeError): @@ -43,7 +44,7 @@ class TestExpression(unittest.TestCase): self.assertEqual(self.e['x'], 1) self.assertEqual(self.e['y'], -2) self.assertEqual(self.e[self.y], -2) - self.assertEqual(self.e['z'], 0) + self.assertEqual(self.e['z'], 3) with self.assertRaises(TypeError): self.e[0] with self.assertRaises(TypeError): @@ -53,7 +54,7 @@ class TestExpression(unittest.TestCase): self.assertCountEqual(self.e.coefficients(), [('x', 1), ('y', -2)]) def test_constant(self): - self.assertEqual(self.x.constant, 0) + self.assertEqual(self.x.constant, 4) self.assertEqual(self.pi.constant, Fraction(22, 7)) self.assertEqual(self.e.constant, 3) @@ -98,6 +99,7 @@ class TestExpression(unittest.TestCase): def test_sub(self): self.assertEqual(self.x - self.x, 0) self.assertEqual(self.e - 3, self.x - 2*self.y) + self.assertEqual(0 - self.x, -self.x) def test_mul(self): self.assertEqual(self.pi * 7, 22) @@ -110,7 +112,7 @@ class TestExpression(unittest.TestCase): self.assertEqual(self.e / 2, self.x / 2 - self.y + Fraction(3, 2)) def test_str(self): - self.assertEqual(str(Expression()), '0') + self.assertEqual(str(Expression()), '5') self.assertEqual(str(self.x), 'x') self.assertEqual(str(-self.x), '-x') self.assertEqual(str(self.pi), '22/7') @@ -158,7 +160,7 @@ class TestHelpers(unittest.TestCase): self.assertEqual(symbol('x'), self.x) self.assertNotEqual(symbol('y'), self.x) with self.assertRaises(TypeError): - symbol(0) + symbol(4) def test_symbols(self): self.assertListEqual(list(symbols('x y')), [self.x, self.y]) @@ -175,3 +177,4 @@ class TestPolyhedron(unittest.TestCase): pass +