12
12
#include " xeus-cpp/xmanager.hpp"
13
13
#include " xeus-cpp/xutils.hpp"
14
14
#include " xeus-cpp/xoptions.hpp"
15
+ #include " xeus-cpp/xeus_cpp_config.hpp"
15
16
16
17
#include " ../src/xparser.hpp"
17
18
#include " ../src/xsystem.hpp"
18
19
#include " ../src/xmagics/os.hpp"
20
+ #include " ../src/xinspect.hpp"
19
21
20
- #include < iostream>
21
22
23
+ #include < iostream>
24
+ #include < pugixml.hpp>
22
25
#include < fstream>
23
26
#if defined(__GNUC__) && !defined(XEUS_CPP_EMSCRIPTEN_WASM_BUILD)
24
27
#include < sys/wait.h>
@@ -718,6 +721,20 @@ TEST_SUITE("xmagics_apply"){
718
721
REQUIRE (redirect.getCaptured () == " UsageError: %%test is a cell magic, but the cell body is empty.\n "
719
722
" If you only intend to display %%test help, please use a double line break to fill in the cell body.\n " );
720
723
}
724
+ TEST_CASE (" cell magic with empty cell body" ) {
725
+ xcpp::xmagics_manager manager;
726
+
727
+ std::stringstream ss;
728
+ auto cerr_buff = std::cerr.rdbuf ();
729
+ std::cerr.rdbuf (ss.rdbuf ());
730
+
731
+ manager.apply (" test" , " line" , " " );
732
+
733
+ std::cerr.rdbuf (cerr_buff);
734
+ REQUIRE (ss.str () == " UsageError: %%test is a cell magic, but the cell body is empty.\n "
735
+ " If you only intend to display %%test help, please use a double line break to fill in the cell body.\n " );
736
+
737
+ }
721
738
}
722
739
723
740
#if defined(__GNUC__) && !defined(XEUS_CPP_EMSCRIPTEN_WASM_BUILD)
@@ -765,4 +782,58 @@ TEST_SUITE("complete_request")
765
782
}
766
783
REQUIRE (found == 2 );
767
784
}
785
+ }
786
+
787
+ TEST_SUITE (" xinspect" ){
788
+ TEST_CASE (" class_member_predicate_get_filename" ){
789
+ xcpp::class_member_predicate cmp;
790
+ cmp.class_name = " TestClass" ;
791
+ cmp.kind = " public" ;
792
+ cmp.child_value = " testMethod" ;
793
+
794
+ pugi::xml_document doc;
795
+ pugi::xml_node node = doc.append_child (" node" );
796
+ node.append_attribute (" kind" ) = " class" ;
797
+ pugi::xml_node name = node.append_child (" name" );
798
+ name.append_child (pugi::node_pcdata).set_value (" TestClass" );
799
+ pugi::xml_node child = node.append_child (" node" );
800
+ child.append_attribute (" kind" ) = " public" ;
801
+ pugi::xml_node child_name = child.append_child (" name" );
802
+ child_name.append_child (pugi::node_pcdata).set_value (" testMethod" );
803
+ pugi::xml_node anchorfile = child.append_child (" anchorfile" );
804
+ anchorfile.append_child (pugi::node_pcdata).set_value (" testfile.cpp" );
805
+
806
+ REQUIRE (cmp.get_filename (node) == " testfile.cpp" );
807
+
808
+ cmp.child_value = " nonexistentMethod" ;
809
+ REQUIRE (cmp.get_filename (node) == " " );
810
+ }
811
+
812
+ TEST_CASE (" class_member_predicate_operator" ){
813
+ xcpp::class_member_predicate cmp;
814
+ cmp.class_name = " TestClass" ;
815
+ cmp.kind = " public" ;
816
+ cmp.child_value = " testMethod" ;
817
+
818
+ pugi::xml_document doc;
819
+ pugi::xml_node node = doc.append_child (" node" );
820
+ node.append_attribute (" kind" ) = " class" ;
821
+ pugi::xml_node name = node.append_child (" name" );
822
+ name.append_child (pugi::node_pcdata).set_value (" TestClass" );
823
+ pugi::xml_node child = node.append_child (" node" );
824
+ child.append_attribute (" kind" ) = " public" ;
825
+ pugi::xml_node child_name = child.append_child (" name" );
826
+ child_name.append_child (pugi::node_pcdata).set_value (" testMethod" );
827
+
828
+
829
+ REQUIRE (cmp (node) == true );
830
+ node.attribute (" kind" ).set_value (" struct" );
831
+ REQUIRE (cmp (node) == true );
832
+ cmp.class_name = " NonexistentClass" ;
833
+ REQUIRE (cmp (node) == false );
834
+ cmp.kind = " private" ;
835
+ REQUIRE (cmp (node) == false );
836
+ cmp.child_value = " nonexistentMethod" ;
837
+ REQUIRE (cmp (node) == false );
838
+ }
768
839
}
0 commit comments