Skip to content
This repository was archived by the owner on Jun 25, 2020. It is now read-only.

Commit 1443b08

Browse files
committed
Added some more tests to source_clang_test, and fixed test error on OS X
1 parent df92539 commit 1443b08

3 files changed

Lines changed: 42 additions & 24 deletions

File tree

tests/clang_project/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
project(hello)
1+
project(test)

tests/clang_project/main.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
1-
#include <iostream>
2-
3-
int main() {
4-
std::cout << "hello world\n";
1+
class Test {
2+
public:
3+
void function();
4+
};
5+
6+
void Test::function() {}
7+
8+
int main() {
9+
Test test;
10+
test.function();
511
}

tests/source_clang_test.cc

Lines changed: 31 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@
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+
1822
int 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

Comments
 (0)