Esempio n. 1
0
    def test_interface_type(self):
        from libcellml import Variable

        # std::string interfaceType()
        v = Variable()
        self.assertEqual(v.interfaceType(), '')
        v.setInterfaceType(Variable.InterfaceType.NONE)
        self.assertEqual(v.interfaceType(), 'none')
        v.setInterfaceType(Variable.InterfaceType.PRIVATE)
        self.assertEqual(v.interfaceType(), 'private')
        v.setInterfaceType(Variable.InterfaceType.PUBLIC)
        self.assertEqual(v.interfaceType(), 'public')
        v.setInterfaceType(Variable.InterfaceType.PUBLIC_AND_PRIVATE)
        self.assertEqual(v.interfaceType(), 'public_and_private')
Esempio n. 2
0
    def test_minimum_interface_type(self):
        from libcellml import Variable

        v_public = Variable()
        v_public.setName("v_public")
        v_public.setInterfaceType("public")

        v_private = Variable()
        v_public.setName("v_private")
        v_private.setInterfaceType("private")

        v_public_and_private = Variable()
        v_public_and_private.setName("v_public_and_private")
        v_public_and_private.setInterfaceType("public_and_private")

        v_none = Variable()
        v_none.setName("v_none")
        v_none.setInterfaceType("none")

        v_empty = Variable()
        v_empty.setName("v_empty")

        # Stored public_and_private meets all requirements.
        self.assertTrue(
            v_public_and_private.permitsInterfaceType(
                Variable.InterfaceType.NONE))
        self.assertTrue(
            v_public_and_private.permitsInterfaceType(
                Variable.InterfaceType.PRIVATE))
        self.assertTrue(
            v_public_and_private.permitsInterfaceType(
                Variable.InterfaceType.PUBLIC))
        self.assertTrue(
            v_public_and_private.permitsInterfaceType(
                Variable.InterfaceType.PUBLIC_AND_PRIVATE))

        # Stored private meets private and none requirements.
        self.assertTrue(
            v_private.permitsInterfaceType(Variable.InterfaceType.NONE))
        self.assertTrue(
            v_private.permitsInterfaceType(Variable.InterfaceType.PRIVATE))
        self.assertFalse(
            v_private.permitsInterfaceType(Variable.InterfaceType.PUBLIC))
        self.assertFalse(
            v_private.permitsInterfaceType(
                Variable.InterfaceType.PUBLIC_AND_PRIVATE))

        # Stored public meets public and none requirements.
        self.assertTrue(
            v_public.permitsInterfaceType(Variable.InterfaceType.NONE))
        self.assertFalse(
            v_public.permitsInterfaceType(Variable.InterfaceType.PRIVATE))
        self.assertTrue(
            v_public.permitsInterfaceType(Variable.InterfaceType.PUBLIC))
        self.assertFalse(
            v_public.permitsInterfaceType(
                Variable.InterfaceType.PUBLIC_AND_PRIVATE))

        # Stored none meets none requirements.
        self.assertTrue(
            v_none.permitsInterfaceType(Variable.InterfaceType.NONE))
        self.assertFalse(
            v_none.permitsInterfaceType(Variable.InterfaceType.PRIVATE))
        self.assertFalse(
            v_none.permitsInterfaceType(Variable.InterfaceType.PUBLIC))
        self.assertFalse(
            v_none.permitsInterfaceType(
                Variable.InterfaceType.PUBLIC_AND_PRIVATE))

        # Stored empty meets none requirements.
        self.assertTrue(
            v_empty.permitsInterfaceType(Variable.InterfaceType.NONE))
        self.assertFalse(
            v_empty.permitsInterfaceType(Variable.InterfaceType.PRIVATE))
        self.assertFalse(
            v_empty.permitsInterfaceType(Variable.InterfaceType.PUBLIC))
        self.assertFalse(
            v_empty.permitsInterfaceType(
                Variable.InterfaceType.PUBLIC_AND_PRIVATE))
Esempio n. 3
0
    def test_set_interface_type(self):
        from libcellml import Variable

        # void setInterfaceType(const std::string &interfaceType)
        v = Variable()
        v.setInterfaceType('special type')

        # void setInterfaceType(InterfaceType interfaceType)
        v = Variable()
        v.setInterfaceType(Variable.InterfaceType.NONE)
        v.setInterfaceType(Variable.InterfaceType.PRIVATE)
        self.assertEqual("private", v.interfaceType())
        v.removeInterfaceType()
        self.assertEqual("", v.interfaceType())
        v.setInterfaceType(Variable.InterfaceType.PUBLIC)
        v.setInterfaceType(Variable.InterfaceType.PUBLIC_AND_PRIVATE)
        self.assertTrue(
            v.hasInterfaceType(Variable.InterfaceType.PUBLIC_AND_PRIVATE))
        self.assertRaises(RuntimeError, v.setInterfaceType,
                          Variable.InterfaceType.NONE - 1)
        self.assertRaises(RuntimeError, v.setInterfaceType,
                          Variable.InterfaceType.PUBLIC_AND_PRIVATE + 1)
        del v

        # void setInterfaceType(const std::string &interfaceType)
        v = Variable()
        v.setInterfaceType('not an interface type')
        del v
Esempio n. 4
0
    def test_set_interface_type(self):
        from libcellml import Variable

        # void setInterfaceType(const std::string &interfaceType)
        v = Variable()
        v.setInterfaceType('special type')

        # void setInterfaceType(InterfaceType interfaceType)
        v = Variable()
        v.setInterfaceType(Variable.InterfaceType.NONE)
        v.setInterfaceType(Variable.InterfaceType.PRIVATE)
        v.setInterfaceType(Variable.InterfaceType.PUBLIC)
        v.setInterfaceType(Variable.InterfaceType.PUBLIC_AND_PRIVATE)
        self.assertRaises(RuntimeError, v.setInterfaceType,
                          Variable.InterfaceType.NONE - 1)
        self.assertRaises(RuntimeError, v.setInterfaceType,
                          Variable.InterfaceType.PUBLIC_AND_PRIVATE + 1)
        del (v)

        # void setInterfaceType(const std::string &interfaceType)
        v = Variable()
        v.setInterfaceType('not an interface type')
        del (v)