diff options
author | mitsuhiko <devnull@localhost> | 2010-03-02 01:27:44 +0100 |
---|---|---|
committer | mitsuhiko <devnull@localhost> | 2010-03-02 01:27:44 +0100 |
commit | b52054154c9bf9ab90f041b514f6581f34e6cb5b (patch) | |
tree | 2329316df0abdb76096daa17b7f8199456a6ceff /tests/test_cpp_domain.py | |
parent | 7b7938b3c2cd86d6a15f64faf669971f65c78582 (diff) | |
download | sphinx-b52054154c9bf9ab90f041b514f6581f34e6cb5b.tar.gz |
Added first CPP test
Diffstat (limited to 'tests/test_cpp_domain.py')
-rw-r--r-- | tests/test_cpp_domain.py | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/test_cpp_domain.py b/tests/test_cpp_domain.py new file mode 100644 index 00000000..48de51c1 --- /dev/null +++ b/tests/test_cpp_domain.py @@ -0,0 +1,42 @@ +# -*- 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(): + """Tests the type definition parsing""" + 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' |