コード例 #1
0
ファイル: test_doc_features.py プロジェクト: bellenot/root
    def test_array(self):
        import cppyy
        from cppyy.gbl import Concrete
        from array import array

        c = Concrete()
        c.array_method(array('d', [1., 2., 3., 4.]), 4)
        raises(IndexError, c.m_data.__getitem__, 4)
コード例 #2
0
ファイル: test_doc_features.py プロジェクト: zuysal/root
    def test_array(self):
        import cppyy
        from cppyy.gbl import Concrete
        from array import array

        c = Concrete()
        c.array_method(array('d', [1., 2., 3., 4.]), 4)
        raises(IndexError, c.m_data.__getitem__, 4)
コード例 #3
0
    def test_default_arguments(self):
        import cppyy
        from cppyy.gbl import Concrete

        c = Concrete()
        assert c.m_int == 42
        c = Concrete(13)
        assert c.m_int == 13
コード例 #4
0
ファイル: test_doc_features.py プロジェクト: zuysal/root
    def test_ref(self):
        import cppyy
        from cppyy.gbl import Concrete
        from ctypes import c_uint

        c = Concrete()
        u = c_uint(0)
        c.uint_ref_assign(u, 42)
        assert u.value == 42
コード例 #5
0
ファイル: test_doc_features.py プロジェクト: bellenot/root
    def test_ref(self):
        import cppyy
        from cppyy.gbl import Concrete
        from ctypes import c_uint

        c = Concrete()
        u = c_uint(0)
        c.uint_ref_assign(u, 42)
        assert u.value == 42
コード例 #6
0
ファイル: test_doc_features.py プロジェクト: zuysal/root
    def test_casting(self):
        import cppyy
        from cppyy.gbl import Abstract, Concrete

        c = Concrete()
        assert 'Abstract' in Concrete.show_autocast.__doc__
        d = c.show_autocast()
        assert type(d) == cppyy.gbl.Concrete

        from cppyy import addressof, bind_object
        e = bind_object(addressof(d), Abstract)
        assert type(e) == cppyy.gbl.Abstract
コード例 #7
0
ファイル: test_doc_features.py プロジェクト: bellenot/root
    def test_casting(self):
        import cppyy
        from cppyy.gbl import Abstract, Concrete

        c = Concrete()
        assert 'Abstract' in Concrete.show_autocast.__doc__
        d = c.show_autocast()
        assert type(d) == cppyy.gbl.Concrete

        from cppyy import addressof, bind_object
        e = bind_object(addressof(d), Abstract)
        assert type(e) == cppyy.gbl.Abstract
コード例 #8
0
ファイル: test_doc_features.py プロジェクト: zuysal/root
    def test_static_data_members(self):
        import cppyy
        from cppyy.gbl import Concrete

        assert Concrete.s_int == 321
        Concrete().s_int = 123
        assert Concrete.s_int == 123
コード例 #9
0
ファイル: test_doc_features.py プロジェクト: zuysal/root
    def test_data_members(self):
        import cppyy
        from cppyy.gbl import Concrete

        c = Concrete()
        assert c.m_int == 42
        raises(TypeError, setattr, c, 'm_const_int', 71)
コード例 #10
0
ファイル: test_doc_features.py プロジェクト: zuysal/root
    def test_abstract_class(self):
        import cppyy
        from cppyy.gbl import Abstract, Concrete

        raises(TypeError, Abstract)
        assert issubclass(Concrete, Abstract)
        c = Concrete()
        assert isinstance(c, Abstract)
コード例 #11
0
ファイル: test_doc_features.py プロジェクト: zhufengGNSS/root
    def test_keyword_arguments(self):
        import cppyy
        from cppyy.gbl import Concrete

        c = Concrete(n=17)
        assert c.m_int == 17

        caught = False
        try:
            c = Concrete(m=18)  # unknown keyword
        except TypeError as e:
            assert 'unexpected keyword argument' in str(e)
            caught = True
        assert caught == True

        kwds = {'n': 18}
        c = Concrete(**kwds)
        assert c.m_int == 18
コード例 #12
0
ファイル: test_doc_features.py プロジェクト: zuysal/root
    def test_operator_conversions(self):
        import cppyy
        from cppyy.gbl import Concrete

        assert str(Concrete()) == 'Hello operator const char*!'
コード例 #13
0
ファイル: test_doc_features.py プロジェクト: zuysal/root
    def test_memory(self):
        import cppyy
        from cppyy.gbl import Concrete

        c = Concrete()
        assert c.__python_owns__ == True