def test_create_destroy(self): from libcellml import When x = When() y = When() z = When(y) del(x, y, z)
def test_contains_when(self): from libcellml import Reset from libcellml import When w1 = When() w2 = When() r = Reset() r.addWhen(w1) self.assertTrue(r.containsWhen(w1)) self.assertFalse(r.containsWhen(w2))
def test_get_when(self): from libcellml import Error, When # WhenPtr getWhen() const; e = Error() self.assertIsNone(e.getWhen()) name = 'var' w = When() w.setId(name) e.setWhen(w) self.assertIsInstance(e.getWhen(), When) self.assertEqual(e.getWhen().getId(), name)
def test_remove_all_whens(self): from libcellml import Reset from libcellml import When w1 = When() w2 = When() w3 = When() r = Reset() r.addWhen(w1) r.addWhen(w2) r.addWhen(w3) self.assertEqual(3, r.whenCount()) r.removeAllWhens() self.assertEqual(0, r.whenCount())
def test_unset_order(self): from libcellml import When # unsetOrder() x = When() x.setOrder(-4) self.assertTrue(x.isOrderSet()) x.unsetOrder() self.assertFalse(x.isOrderSet())
def test_add_when(self): from libcellml import Reset from libcellml import When # addWhen() w = When() x = Reset() x.addWhen(w) self.assertEqual(1, x.whenCount())
def test_get_when(self): from libcellml import Reset from libcellml import When w = When() r = Reset() r.addWhen(w) self.assertEqual(None, r.getWhen(2)) self.assertEqual(None, r.getWhen(-4)) self.assertNotEqual(None, r.getWhen(0))
def test_is_order_set(self): from libcellml import When # bool isOrderSet() x = When() self.assertFalse(x.isOrderSet()) x.setOrder(2) self.assertTrue(x.isOrderSet())
def test_set_get_value(self): from libcellml import When x = When() self.assertEqual("", x.getValue()) x.setValue("A value MathML string.") self.assertEqual("A value MathML string.", x.getValue())
def test_set_get_condition(self): from libcellml import When x = When() self.assertEqual("", x.getCondition()) x.setCondition("A MathML string.") self.assertEqual("A MathML string.", x.getCondition())
def test_take_when(self): from libcellml import Reset from libcellml import When w = When() r = Reset() r.addWhen(w) self.assertEqual(1, r.whenCount()) self.assertEqual(None, r.takeWhen(2)) w_returned = r.takeWhen(0) self.assertNotEqual(None, w_returned) self.assertEqual(0, r.whenCount())
def test_remove_when(self): from libcellml import Reset from libcellml import When w = When() r = Reset() r.addWhen(w) self.assertEqual(1, r.whenCount()) self.assertTrue(r.removeWhen(0)) self.assertEqual(0, r.whenCount()) r.addWhen(w) self.assertTrue(r.removeWhen(w)) self.assertEqual(0, r.whenCount())
def test_replace_when(self): from libcellml import Reset from libcellml import When w1 = When() w1.setCondition("x=exp(y)") w2 = When() w2.setValue("a=2") r = Reset() r.addWhen(w1) self.assertFalse(r.replaceWhen(3, w2)) self.assertEqual("x=exp(y)", r.getWhen(0).getCondition()) self.assertEqual("", r.getWhen(0).getValue()) self.assertTrue(r.replaceWhen(0, w2)) self.assertEqual("", r.getWhen(0).getCondition()) self.assertEqual("a=2", r.getWhen(0).getValue())
def test_set_order(self): from libcellml import When x = When() x.setOrder(3) self.assertEqual(3, x.getOrder())
def test_set_when(self): from libcellml import Error, When # void setWhen(const WhenPtr &when); e = Error() e.setWhen(When())