@@ -69,102 +69,69 @@ def test_continuation(self) -> None:
6969
7070
7171if platform .system () != 'Windows' :
72- # class XCppTests(jupyter_kernel_test.KernelTests):
73-
74- # kernel_name = 'xcpp20'
75-
76- # # language_info.name in a kernel_info_reply should match this
77- # language_name = 'C++'
78-
79- # # Code that should write the exact string `hello, world` to STDOUT
80- # code_hello_world = '#include <iostream>\nstd::cout << "hello, world" << std::endl;'
81-
82- # # Code that should cause (any) text to be written to STDERR
83- # code_stderr = '#include <iostream>\nstd::cerr << "oops" << std::endl;'
84-
85- # # Pager: code that should display something (anything) in the pager
86- # code_page_something = "?std::vector"
87-
88- # # Exception throwing
89- # # TODO: Remove 'if' when test work on MacOS/arm64. Throw Exceptions make
90- # # kernel/test non-workable.
91- # ###code_generate_error = 'throw std::runtime_error("Unknown exception");' if platform.system() != "Darwin" or platform.processor() != 'arm' else ''
92-
93- # # Samples of code which generate a result value (ie, some text
94- # # displayed as Out[n])
95- # #code_execute_result = [
96- # # {
97- # # 'code': '6 * 7',
98- # # 'result': '42'
99- # # }
100- # #]
101-
102- # # Samples of code which should generate a rich display output, and
103- # # the expected MIME type
104- # code_display_data = [
105- # {
106- # 'code': '#include <string>\n#include "xcpp/xdisplay.hpp"\nstd::string test("foobar");\nxcpp::display(test);',
107- # 'mime': 'text/plain'
108- # },
109- # {
110- # 'code': """
111- # #include <string>
112- # #include <fstream>
113- # #include "nlohmann/json.hpp"
114- # #include "xeus/xbase64.hpp"
115- # namespace im {
116- # struct image {
117- # inline image(const std::string& filename) {
118- # std::ifstream fin(filename, std::ios::binary);
119- # m_buffer << fin.rdbuf();
120- # }
121- # std::stringstream m_buffer;
122- # };
123- # nlohmann::json mime_bundle_repr(const image& i) {
124- # auto bundle = nlohmann::json::object();
125- # bundle["image/png"] = xeus::base64encode(i.m_buffer.str());
126- # return bundle;
127- # }
128- # }
129- # #include "xcpp/xdisplay.hpp"
130- # im::image marie("../notebooks/images/marie.png");
131- # xcpp::display(marie);""",
132- # 'mime': 'image/png'
133- # }
134- # ]
135-
136- class XCppTests_debug (jupyter_kernel_test .KernelTests ):
72+ class XCppTests (jupyter_kernel_test .KernelTests ):
13773
13874 kernel_name = 'xcpp20'
13975
14076 # language_info.name in a kernel_info_reply should match this
14177 language_name = 'C++'
14278
143- code_err = """
144- #include <iostream>
145- std::cerr << "oops" << std::endl;
146- """
147-
148- code_stdout = """
149- #include <iostream>
150- std::cout << "oops_std" << std::endl;
151- """
152-
153- def test_xcpp_err (self ):
154- self .flush_channels ()
155- reply , output_msgs = self .execute_helper (code = self .code_err )
156- print (output_msgs )
157- self .assertEqual (output_msgs [0 ]['msg_type' ], 'stream' )
158- self .assertEqual (output_msgs [0 ]['content' ]['name' ], 'stderr' )
159- self .assertEqual (output_msgs [0 ]['content' ]['text' ], 'oops\n ' )
160-
161- def test_xcpp_stdout (self ):
162- self .flush_channels ()
163- reply , output_msgs = self .execute_helper (code = self .code_stdout )
164- print (output_msgs )
165- self .assertEqual (output_msgs [0 ]['msg_type' ], 'stream' )
166- self .assertEqual (output_msgs [0 ]['content' ]['name' ], 'stdout' )
167- self .assertEqual (output_msgs [0 ]['content' ]['text' ], 'oops_std\n ' )
79+ # Code that should write the exact string `hello, world` to STDOUT
80+ code_hello_world = '#include <iostream>\n std::cout << "hello, world";'
81+
82+ # Code that should cause (any) text to be written to STDERR
83+ code_stderr = '#include <iostream>\n std::cerr << "oops";'
84+
85+ # Pager: code that should display something (anything) in the pager
86+ code_page_something = "?std::vector"
87+
88+ # Exception throwing
89+ # TODO: Remove 'if' when test work on MacOS/arm64. Throw Exceptions make
90+ # kernel/test non-workable.
91+ ###code_generate_error = 'throw std::runtime_error("Unknown exception");' if platform.system() != "Darwin" or platform.processor() != 'arm' else ''
92+
93+ # Samples of code which generate a result value (ie, some text
94+ # displayed as Out[n])
95+ #code_execute_result = [
96+ # {
97+ # 'code': '6 * 7',
98+ # 'result': '42'
99+ # }
100+ #]
101+
102+ # Samples of code which should generate a rich display output, and
103+ # the expected MIME type
104+ code_display_data = [
105+ {
106+ 'code' : '#include <string>\n #include "xcpp/xdisplay.hpp"\n std::string test("foobar");\n xcpp::display(test);' ,
107+ 'mime' : 'text/plain'
108+ },
109+ {
110+ 'code' : """
111+ #include <string>
112+ #include <fstream>
113+ #include "nlohmann/json.hpp"
114+ #include "xeus/xbase64.hpp"
115+ namespace im {
116+ struct image {
117+ inline image(const std::string& filename) {
118+ std::ifstream fin(filename, std::ios::binary);
119+ m_buffer << fin.rdbuf();
120+ }
121+ std::stringstream m_buffer;
122+ };
123+ nlohmann::json mime_bundle_repr(const image& i) {
124+ auto bundle = nlohmann::json::object();
125+ bundle["image/png"] = xeus::base64encode(i.m_buffer.str());
126+ return bundle;
127+ }
128+ }
129+ #include "xcpp/xdisplay.hpp"
130+ im::image marie("../notebooks/images/marie.png");
131+ xcpp::display(marie);""" ,
132+ 'mime' : 'image/png'
133+ }
134+ ]
168135
169136 # Tests for Notebooks
170137 class XCppNotebookTests (unittest .TestCase ):
0 commit comments