diff options
| author | Georg Brandl <georg@python.org> | 2010-03-16 08:54:03 +0100 |
|---|---|---|
| committer | Georg Brandl <georg@python.org> | 2010-03-16 08:54:03 +0100 |
| commit | 37967d05b70e34c2426f2c31209d0cdc5edd054e (patch) | |
| tree | c83e36a9e3d0474784a3bcfadedb642e99830d70 /tests/test_cpp_domain.py | |
| parent | b13cba2bb0ad964de0c38c136b713572a0234bdc (diff) | |
| parent | fc031d02297ccf1a6224fca0b0322236f310147d (diff) | |
| download | sphinx-37967d05b70e34c2426f2c31209d0cdc5edd054e.tar.gz | |
merge with trunk
Diffstat (limited to 'tests/test_cpp_domain.py')
| -rw-r--r-- | tests/test_cpp_domain.py | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/tests/test_cpp_domain.py b/tests/test_cpp_domain.py new file mode 100644 index 00000000..b12e57af --- /dev/null +++ b/tests/test_cpp_domain.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +""" + test_cpp_domain + ~~~~~~~~~~~~~~~ + + Tests the C++ Domain + + :copyright: Copyright 2007-2010 by the Sphinx team, see AUTHORS. + :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' + + 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 + + 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' + + +def test_operators(): + x = parse('function', 'void operator new [ ] ()') + assert unicode(x) == 'void operator new[]()' |
