Skip to content

Commit 6929f36

Browse files
committed
Add test to demonstrate error with find_noncopyable_vars (#71)
The test is not run by the test suite for the moment.
1 parent 1ef0590 commit 6929f36

File tree

2 files changed

+65
-0
lines changed

2 files changed

+65
-0
lines changed

unittests/data/test_stream.hpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright 2014-2016 Insight Software Consortium.
2+
// Copyright 2004-2008 Roman Yakovenko.
3+
// Distributed under the Boost Software License, Version 1.0.
4+
// See http://www.boost.org/LICENSE_1_0.txt
5+
6+
#include <sstream>
7+
8+
namespace Test2 {
9+
10+
class FileStreamDataStream {
11+
public:
12+
FileStreamDataStream(const std::istream* s) {}
13+
14+
protected:
15+
std::istream* mInStream;
16+
};
17+
}
18+

unittests/test_stream.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Copyright 2014-2016 Insight Software Consortium.
2+
# Copyright 2004-2009 Roman Yakovenko.
3+
# Distributed under the Boost Software License, Version 1.0.
4+
# See http://www.boost.org/LICENSE_1_0.txt
5+
6+
import unittest
7+
import parser_test_case
8+
9+
from pygccxml import parser
10+
from pygccxml import declarations
11+
12+
13+
class Test(parser_test_case.parser_test_case_t):
14+
15+
def __init__(self, *args):
16+
parser_test_case.parser_test_case_t.__init__(self, *args)
17+
self.header = "test_stream.hpp"
18+
self.config.cflags = "-std=c++11"
19+
20+
def test_stream_non_copyable(self):
21+
"""
22+
Test find_noncopyable_vars
23+
24+
See #71
25+
26+
find_noncopyable_vars is throwing:
27+
RuntimeError: maximum recursion depth exceeded while
28+
calling a Python object
29+
"""
30+
decls = parser.parse([self.header], self.config)
31+
global_ns = declarations.get_global_namespace(decls)
32+
33+
test_ns = global_ns.namespace('Test2')
34+
cls = test_ns.class_('FileStreamDataStream')
35+
declarations.type_traits_classes.find_noncopyable_vars(cls)
36+
37+
def create_suite():
38+
suite = unittest.TestSuite()
39+
suite.addTest(unittest.makeSuite(Test))
40+
return suite
41+
42+
43+
def run_suite():
44+
unittest.TextTestRunner(verbosity=2).run(create_suite())
45+
46+
if __name__ == "__main__":
47+
run_suite()

0 commit comments

Comments
 (0)