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_tags_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
22
+ #include < pugixml.hpp>
20
23
#include < fstream>
21
24
#if defined(__GNUC__) && !defined(XEUS_CPP_EMSCRIPTEN_WASM_BUILD)
22
25
#include < sys/wait.h>
@@ -626,6 +629,22 @@ TEST_SUITE("xmagics_apply"){
626
629
manager.apply (" %dummy" , kernel_res);
627
630
REQUIRE (kernel_res[" status" ] == " error" );
628
631
}
632
+
633
+ TEST_CASE (" cell magic with empty cell body" ) {
634
+ xcpp::xmagics_manager manager;
635
+
636
+ std::stringstream ss;
637
+ auto cerr_buff = std::cerr.rdbuf ();
638
+ std::cerr.rdbuf (ss.rdbuf ());
639
+
640
+ manager.apply (" test" , " line" , " " );
641
+
642
+ std::cerr.rdbuf (cerr_buff);
643
+ REQUIRE (ss.str () == " UsageError: %%test is a cell magic, but the cell body is empty.\n "
644
+ " If you only intend to display %%test help, please use a double line break to fill in the cell body.\n " );
645
+
646
+ }
647
+
629
648
}
630
649
631
650
#if defined(__GNUC__) && !defined(XEUS_CPP_EMSCRIPTEN_WASM_BUILD)
@@ -673,4 +692,58 @@ TEST_SUITE("complete_request")
673
692
}
674
693
REQUIRE (found == 2 );
675
694
}
695
+ }
696
+
697
+ TEST_SUITE (" xinspect" ){
698
+ TEST_CASE (" class_member_predicate_get_filename" ){
699
+ xcpp::class_member_predicate cmp;
700
+ cmp.class_name = " TestClass" ;
701
+ cmp.kind = " public" ;
702
+ cmp.child_value = " testMethod" ;
703
+
704
+ pugi::xml_document doc;
705
+ pugi::xml_node node = doc.append_child (" node" );
706
+ node.append_attribute (" kind" ) = " class" ;
707
+ pugi::xml_node name = node.append_child (" name" );
708
+ name.append_child (pugi::node_pcdata).set_value (" TestClass" );
709
+ pugi::xml_node child = node.append_child (" node" );
710
+ child.append_attribute (" kind" ) = " public" ;
711
+ pugi::xml_node child_name = child.append_child (" name" );
712
+ child_name.append_child (pugi::node_pcdata).set_value (" testMethod" );
713
+ pugi::xml_node anchorfile = child.append_child (" anchorfile" );
714
+ anchorfile.append_child (pugi::node_pcdata).set_value (" testfile.cpp" );
715
+
716
+ REQUIRE (cmp.get_filename (node) == " testfile.cpp" );
717
+
718
+ cmp.child_value = " nonexistentMethod" ;
719
+ REQUIRE (cmp.get_filename (node) == " " );
720
+ }
721
+
722
+ TEST_CASE (" class_member_predicate_operator" ){
723
+ xcpp::class_member_predicate cmp;
724
+ cmp.class_name = " TestClass" ;
725
+ cmp.kind = " public" ;
726
+ cmp.child_value = " testMethod" ;
727
+
728
+ pugi::xml_document doc;
729
+ pugi::xml_node node = doc.append_child (" node" );
730
+ node.append_attribute (" kind" ) = " class" ;
731
+ pugi::xml_node name = node.append_child (" name" );
732
+ name.append_child (pugi::node_pcdata).set_value (" TestClass" );
733
+ pugi::xml_node child = node.append_child (" node" );
734
+ child.append_attribute (" kind" ) = " public" ;
735
+ pugi::xml_node child_name = child.append_child (" name" );
736
+ child_name.append_child (pugi::node_pcdata).set_value (" testMethod" );
737
+
738
+
739
+ REQUIRE (cmp (node) == true );
740
+ node.attribute (" kind" ).set_value (" struct" );
741
+ REQUIRE (cmp (node) == true );
742
+ cmp.class_name = " NonexistentClass" ;
743
+ REQUIRE (cmp (node) == false );
744
+ cmp.kind = " private" ;
745
+ REQUIRE (cmp (node) == false );
746
+ cmp.child_value = " nonexistentMethod" ;
747
+ REQUIRE (cmp (node) == false );
748
+ }
676
749
}
0 commit comments