Ejemplo n.º 1
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())
Ejemplo n.º 2
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))
Ejemplo n.º 3
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))
Ejemplo n.º 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())
Ejemplo n.º 5
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())
Ejemplo n.º 6
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())
Ejemplo n.º 7
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())