[pypy-commit] pypy reflex-support: (roel aaij, wlav) add test files for std streams

wlav noreply at buildbot.pypy.org
Tue Aug 16 21:24:13 CEST 2011


Author: Wim Lavrijsen <WLavrijsen at lbl.gov>
Branch: reflex-support
Changeset: r46552:00bfdffeee0d
Date: 2011-08-16 12:30 -0700
http://bitbucket.org/pypy/pypy/changeset/00bfdffeee0d/

Log:	(roel aaij, wlav) add test files for std streams

diff --git a/pypy/module/cppyy/test/std_streams.cxx b/pypy/module/cppyy/test/std_streams.cxx
new file mode 100644
--- /dev/null
+++ b/pypy/module/cppyy/test/std_streams.cxx
@@ -0,0 +1,3 @@
+#include "std_streams.h"
+
+template class std::basic_ios<char,std::char_traits<char> >;
diff --git a/pypy/module/cppyy/test/std_streams.h b/pypy/module/cppyy/test/std_streams.h
new file mode 100644
--- /dev/null
+++ b/pypy/module/cppyy/test/std_streams.h
@@ -0,0 +1,9 @@
+#ifndef STD_STREAMS_H 
+#define STD_STREAMS_H 1
+
+#include <ios>
+#include <iostream>
+
+extern template class std::basic_ios<char,std::char_traits<char> >;
+
+#endif // STD_STREAMS_H
diff --git a/pypy/module/cppyy/test/std_streams.xml b/pypy/module/cppyy/test/std_streams.xml
new file mode 100644
--- /dev/null
+++ b/pypy/module/cppyy/test/std_streams.xml
@@ -0,0 +1,7 @@
+<lcgdict>
+
+  <class name = "std::ostream"/>
+  <class name = "std::ios_base"/>
+  <class name = "std::basic_ios<char,std::char_traits<char> >"/>
+
+</lcgdict>
diff --git a/pypy/module/cppyy/test/test_streams.py b/pypy/module/cppyy/test/test_streams.py
new file mode 100644
--- /dev/null
+++ b/pypy/module/cppyy/test/test_streams.py
@@ -0,0 +1,36 @@
+import py, os, sys
+from pypy.conftest import gettestobjspace
+
+
+currpath = py.path.local(__file__).dirpath()
+test_dct = str(currpath.join("std_streamsDict.so"))
+
+space = gettestobjspace(usemodules=['cppyy'])
+
+def setup_module(mod):
+    if sys.platform == 'win32':
+        py.test.skip("win32 not supported so far")
+    err = os.system("cd '%s' && make std_streamsDict.so" % currpath)
+    if err:
+        raise OSError("'make' failed (see stderr)")
+
+class AppTestSTDStreams:
+    def setup_class(cls):
+        cls.space = space
+        env = os.environ
+        cls.w_N = space.wrap(13)
+        cls.w_test_dct  = space.wrap(test_dct)
+        cls.w_datatypes = cls.space.appexec([], """():
+            import cppyy
+            return cppyy.load_reflection_info(%r)""" % (test_dct, ))
+
+    def test01_std_ostream(self):
+        """Test access to an std::vector<int>"""
+
+        import cppyy
+
+        assert cppyy.gbl.std is cppyy.gbl.std
+        assert cppyy.gbl.std.ostream is cppyy.gbl.std.ostream
+
+        assert callable(cppyy.gbl.std.ostream)
+


More information about the pypy-commit mailing list