33#include " config.h"
44#include " filesystem.h"
55
6- std::string hello_world_error=R"( #include <iostream>
7-
8- int main() {
9- std::cout << "hello world\n"
6+ std::string main_error=R"( int main() {
7+ int number=2;
8+ number=3
109}
1110)" ;
1211
@@ -15,29 +14,42 @@ int main() {
1514// broadwayd&
1615// make test
1716
17+ void flush_events () {
18+ while (Gtk::Main::events_pending ())
19+ Gtk::Main::iteration (false );
20+ }
21+
1822int main () {
1923 auto app=Gtk::Application::create ();
2024 Gsv::init ();
2125
2226 Config::get ().project .default_build_path =" ./build" ;
2327 Source::ClangView *clang_view=new Source::ClangView (boost::filesystem::canonical (std::string (JUCI_TESTS_PATH )+" /clang_project/main.cpp" ),
2428 Gsv::LanguageManager::get_default ()->get_language (" cpp" ));
25- while (!clang_view->parsed ) {
26- while (Gtk::Main::events_pending ())
27- Gtk::Main::iteration (false );
28- }
29- g_assert (clang_view->diagnostics .size ()==0 );
30- clang_view->get_buffer ()->set_text (hello_world_error);
31- while (Gtk::Main::events_pending ())
32- Gtk::Main::iteration (false );
33- while (!clang_view->parsed ) {
34- while (Gtk::Main::events_pending ())
35- Gtk::Main::iteration (false );
36- }
37- g_assert (clang_view->diagnostics .size ()>0 );
29+ while (!clang_view->parsed )
30+ flush_events ();
31+ g_assert_cmpuint (clang_view->diagnostics .size (), ==, 0 );
32+
33+ clang_view->place_cursor_at_line_index (10 -1 , 8 -1 );
34+ flush_events ();
35+ auto location=clang_view->get_declaration_location ({clang_view});
36+ g_assert_cmpuint (location.line , ==, 3 );
37+ clang_view->place_cursor_at_line_index (location.line -1 , location.index -1 );
38+ flush_events ();
39+ location=clang_view->get_implementation_location ({clang_view});
40+ g_assert_cmpuint (location.line , ==, 6 );
41+ clang_view->place_cursor_at_line_index (location.line -1 , location.index -1 );
42+ flush_events ();
43+ location=clang_view->get_declaration_location ({clang_view});
44+ g_assert_cmpuint (location.line , ==, 3 );
45+
46+ clang_view->get_buffer ()->set_text (main_error);
47+ flush_events ();
48+ while (!clang_view->parsed )
49+ flush_events ();
50+ g_assert_cmpuint (clang_view->diagnostics .size (), >, 0 );
3851
3952 clang_view->async_delete ();
4053 clang_view->delete_thread .join ();
41- while (Gtk::Main::events_pending ())
42- Gtk::Main::iteration (false );
54+ flush_events ();
4355}
0 commit comments