2010-03-01 18:27:44 -06:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
"""
|
|
|
|
test_cpp_domain
|
|
|
|
~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
Tests the C++ Domain
|
|
|
|
|
2011-01-04 03:00:51 -06:00
|
|
|
:copyright: Copyright 2007-2011 by the Sphinx team, see AUTHORS.
|
2010-03-01 18:27:44 -06:00
|
|
|
:license: BSD, see LICENSE for details.
|
|
|
|
"""
|
|
|
|
|
|
|
|
from util import *
|
|
|
|
|
|
|
|
from sphinx.domains.cpp import DefinitionParser
|
|
|
|
|
|
|
|
|
|
|
|
def parse(name, string):
|
|
|
|
return getattr(DefinitionParser(string), 'parse_' + name)()
|
|
|
|
|
|
|
|
|
|
|
|
def test_type_definitions():
|
|
|
|
rv = parse('member_object', ' const std::string & name = 42')
|
|
|
|
assert unicode(rv) == 'const std::string& name = 42'
|
|
|
|
|
|
|
|
rv = parse('member_object', ' const std::string & name leftover')
|
|
|
|
assert unicode(rv) == 'const std::string& name'
|
|
|
|
|
2011-09-22 03:23:46 -05:00
|
|
|
x = 'void operator()(const boost::array<VertexID, 2>& v) const'
|
|
|
|
assert unicode(parse('function', x)) == x
|
|
|
|
|
2010-03-01 18:27:44 -06:00
|
|
|
rv = parse('member_object', 'const std::vector< unsigned int, long> &name')
|
|
|
|
assert unicode(rv) == 'const std::vector<unsigned int, long>& name'
|
|
|
|
|
|
|
|
x = 'std::vector<std::pair<std::string, int>>& module::test(register ' \
|
|
|
|
'foo, bar, std::string baz="foobar, blah, bleh") const = 0'
|
|
|
|
assert unicode(parse('function', x)) == x
|
|
|
|
|
|
|
|
x = 'module::myclass::operator std::vector<std::string>()'
|
|
|
|
assert unicode(parse('function', x)) == x
|
2010-03-30 11:57:56 -05:00
|
|
|
x = 'explicit module::myclass::foo::foo()'
|
|
|
|
assert unicode(parse('function', x)) == x
|
2010-03-01 18:27:44 -06:00
|
|
|
|
2011-04-19 21:22:33 -05:00
|
|
|
x = 'int printf(const char* fmt, ...)'
|
|
|
|
assert unicode(parse('function', x)) == x
|
|
|
|
|
2010-03-01 18:27:44 -06:00
|
|
|
x = 'std::vector<std::pair<std::string, long long>> module::blah'
|
|
|
|
assert unicode(parse('type_object', x)) == x
|
|
|
|
|
|
|
|
assert unicode(parse('type_object', 'long long int foo')) == 'long long foo'
|
2010-03-02 06:10:44 -06:00
|
|
|
|
2011-09-22 03:33:15 -05:00
|
|
|
x = 'MyClass::MyClass(MyClass::MyClass&&)'
|
|
|
|
assert unicode(parse('function', x)) == x
|
|
|
|
|
2011-09-22 03:43:24 -05:00
|
|
|
x = 'constexpr int get_value()'
|
|
|
|
assert unicode(parse('function', x)) == x
|
|
|
|
|
2011-09-22 04:15:46 -05:00
|
|
|
x = 'int get_value() const noexcept'
|
|
|
|
assert unicode(parse('function', x)) == x
|
|
|
|
|
2011-09-22 03:33:15 -05:00
|
|
|
|
2010-03-02 06:10:44 -06:00
|
|
|
def test_operators():
|
|
|
|
x = parse('function', 'void operator new [ ] ()')
|
|
|
|
assert unicode(x) == 'void operator new[]()'
|
2010-03-30 11:57:56 -05:00
|
|
|
|
|
|
|
x = parse('function', 'void operator delete ()')
|
|
|
|
assert unicode(x) == 'void operator delete()'
|
|
|
|
|
|
|
|
for op in '*-+=/%!':
|
|
|
|
x = parse('function', 'void operator %s ()' % op)
|
|
|
|
assert unicode(x) == 'void operator%s()' % op
|