File: test_overrides.py

package info (click to toggle)
pygccxml 3.0.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 8,444 kB
  • sloc: xml: 29,841; python: 13,914; cpp: 2,671; makefile: 163; ansic: 59
file content (43 lines) | stat: -rw-r--r-- 1,587 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# Copyright 2014-2020 Insight Software Consortium.
# Copyright 2004-2009 Roman Yakovenko.
# Distributed under the Boost Software License, Version 1.0.
# See http://www.boost.org/LICENSE_1_0.txt

import pytest
import platform

from . import autoconfig

from pygccxml import parser
from pygccxml import declarations


@pytest.fixture
def global_ns_fixture():
    config = autoconfig.cxx_parsers_cfg.config.clone()
    config.castxml_epic_version = 1
    if platform.system() == "Darwin":
        config.cflags = "-std=c++11 -Dat_quick_exit=atexit -Dquick_exit=exit"
        # https://fr.mathworks.com/matlabcentral/answers/2013982-clibgen-generatelibrarydefinition-error-the-global-scope-has-no-quick_exit-on-mac-m2#answer_1439856
        # https://github.com/jetbrains/kotlin/commit/d50f585911dedec5723213da8835707ac95e1c01
    else:
        config.cflags = "-std=c++11"
    decls = parser.parse(["test_overrides.hpp"], config)
    global_ns = declarations.get_global_namespace(decls)
    return global_ns


def test_overrides(global_ns_fixture):
    """
    Check that the override information is populated for the
    simple::goodbye function. It should contain the decl for the
    base::goodbye function.  Base::goodbye has no override so it
    will be none
    """
    base = global_ns_fixture.class_("base").member_function("goodbye")
    override_decl = global_ns_fixture.class_("simple")\
                                     .member_function("goodbye")

    assert base.overrides is None
    assert override_decl.overrides is not None
    assert override_decl.overrides == base