mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Added first CPP test
This commit is contained in:
@@ -110,6 +110,20 @@ class DefExpr(object):
|
||||
def __unicode__(self):
|
||||
raise NotImplementedError()
|
||||
|
||||
def __eq__(self, other):
|
||||
if type(self) is not type(other):
|
||||
return False
|
||||
try:
|
||||
for key, value in self.__dict__.iteritems():
|
||||
if value != getattr(other, value):
|
||||
return False
|
||||
except AttributeError:
|
||||
return False
|
||||
return True
|
||||
|
||||
def __ne__(self, other):
|
||||
return not self.__eq__(other)
|
||||
|
||||
def clone(self):
|
||||
"""Close a definition expression node"""
|
||||
return deepcopy(self)
|
||||
|
||||
42
tests/test_cpp_domain.py
Normal file
42
tests/test_cpp_domain.py
Normal file
@@ -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'
|
||||
Reference in New Issue
Block a user