Example #1
0
    def test_create_destroy(self):
        from libcellml import When

        x = When()
        y = When()
        z = When(y)
        del(x, y, z)
Example #2
0
    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))
Example #3
0
    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)
Example #4
0
    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())
Example #5
0
    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())
Example #6
0
    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())
Example #7
0
    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))
Example #8
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())
Example #9
0
    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())
Example #10
0
    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())
Example #11
0
    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())
Example #12
0
    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())
Example #13
0
    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())
Example #14
0
    def test_set_order(self):
        from libcellml import When

        x = When()
        x.setOrder(3)
        self.assertEqual(3, x.getOrder())
Example #15
0
    def test_set_when(self):
        from libcellml import Error, When

        # void setWhen(const WhenPtr &when);
        e = Error()
        e.setWhen(When())