@@ -30,19 +30,55 @@ int main() {
3030 flush_events ();
3131 g_assert_cmpuint (clang_view->diagnostics .size (), ==, 0 );
3232
33- clang_view->place_cursor_at_line_index (10 -1 , 8 -1 );
33+ // test get_declaration and get_implementation
34+ clang_view->place_cursor_at_line_index (14 -1 , 8 -1 );
3435 flush_events ();
3536 auto location=clang_view->get_declaration_location ({clang_view});
36- g_assert_cmpuint (location.line , ==, 3 );
37+ g_assert_cmpuint (location.line , ==, 5 );
38+
3739 clang_view->place_cursor_at_line_index (location.line -1 , location.index -1 );
3840 flush_events ();
3941 location=clang_view->get_implementation_location ({clang_view});
40- g_assert_cmpuint (location.line , ==, 6 );
42+ g_assert_cmpuint (location.line , ==, 10 );
43+
4144 clang_view->place_cursor_at_line_index (location.line -1 , location.index -1 );
4245 flush_events ();
4346 location=clang_view->get_declaration_location ({clang_view});
44- g_assert_cmpuint (location.line , ==, 3 );
47+ g_assert_cmpuint (location.line , ==, 5 );
48+
49+ // test get_usages and get_methods
50+ auto locations=clang_view->get_usages ({clang_view});
51+ flush_events ();
52+ g_assert_cmpuint (locations.size (), >, 0 );
53+
54+ locations=clang_view->get_methods ();
55+ flush_events ();
56+ g_assert_cmpuint (locations.size (), >, 0 );
57+
58+ // Test rename class (error if not constructor and destructor is renamed as well)
59+ auto saved_main=clang_view->get_buffer ()->get_text ();
60+ clang_view->place_cursor_at_line_index (1 -1 , 7 -1 );
61+ flush_events ();
62+ auto token=clang_view->get_token (clang_view->get_buffer ()->get_insert ()->get_iter ());
63+ g_assert_cmpstr (token.c_str (), ==, " TestClass" );
64+ location=clang_view->get_declaration_location ({clang_view});
65+ g_assert_cmpuint (location.line , ==, 1 );
66+ clang_view->rename_similar_tokens ({clang_view}, " RenamedTestClass" );
67+ flush_events ();
68+ while (!clang_view->parsed )
69+ flush_events ();
70+ flush_events ();
71+ auto iter=clang_view->get_buffer ()->get_insert ()->get_iter ();
72+ iter.backward_char ();
73+ token=clang_view->get_token (iter);
74+ g_assert_cmpstr (token.c_str (), ==, " RenamedTestClass" );
75+ flush_events ();
76+ g_assert_cmpuint (clang_view->diagnostics .size (), ==, 0 );
77+ clang_view->get_buffer ()->set_text (saved_main);
78+ flush_events ();
79+ clang_view->save ({clang_view});
4580
81+ // test error
4682 clang_view->get_buffer ()->set_text (main_error);
4783 flush_events ();
4884 while (!clang_view->parsed )
0 commit comments