Browse Source

Added some more tests to source_clang_test, and fixed test error on OS X

merge-requests/365/head
eidheim 10 years ago
parent
commit
1443b08e50
  1. 2
      tests/clang_project/CMakeLists.txt
  2. 14
      tests/clang_project/main.cpp
  3. 50
      tests/source_clang_test.cc

2
tests/clang_project/CMakeLists.txt

@ -1 +1 @@
project(hello) project(test)

14
tests/clang_project/main.cpp

@ -1,5 +1,11 @@
#include <iostream> class Test {
public:
int main() { void function();
std::cout << "hello world\n"; };
void Test::function() {}
int main() {
Test test;
test.function();
} }

50
tests/source_clang_test.cc

@ -3,10 +3,9 @@
#include "config.h" #include "config.h"
#include "filesystem.h" #include "filesystem.h"
std::string hello_world_error=R"(#include <iostream> std::string main_error=R"(int main() {
int number=2;
int main() { number=3
std::cout << "hello world\n"
} }
)"; )";
@ -15,6 +14,11 @@ int main() {
//broadwayd& //broadwayd&
//make test //make test
void flush_events() {
while(Gtk::Main::events_pending())
Gtk::Main::iteration(false);
}
int main() { int main() {
auto app=Gtk::Application::create(); auto app=Gtk::Application::create();
Gsv::init(); Gsv::init();
@ -22,22 +26,30 @@ int main() {
Config::get().project.default_build_path="./build"; Config::get().project.default_build_path="./build";
Source::ClangView *clang_view=new Source::ClangView(boost::filesystem::canonical(std::string(JUCI_TESTS_PATH)+"/clang_project/main.cpp"), Source::ClangView *clang_view=new Source::ClangView(boost::filesystem::canonical(std::string(JUCI_TESTS_PATH)+"/clang_project/main.cpp"),
Gsv::LanguageManager::get_default()->get_language("cpp")); Gsv::LanguageManager::get_default()->get_language("cpp"));
while(!clang_view->parsed) { while(!clang_view->parsed)
while(Gtk::Main::events_pending()) flush_events();
Gtk::Main::iteration(false); g_assert_cmpuint(clang_view->diagnostics.size(), ==, 0);
}
g_assert(clang_view->diagnostics.size()==0); clang_view->place_cursor_at_line_index(10-1, 8-1);
clang_view->get_buffer()->set_text(hello_world_error); flush_events();
while(Gtk::Main::events_pending()) auto location=clang_view->get_declaration_location({clang_view});
Gtk::Main::iteration(false); g_assert_cmpuint(location.line, ==, 3);
while(!clang_view->parsed) { clang_view->place_cursor_at_line_index(location.line-1, location.index-1);
while(Gtk::Main::events_pending()) flush_events();
Gtk::Main::iteration(false); location=clang_view->get_implementation_location({clang_view});
} g_assert_cmpuint(location.line, ==, 6);
g_assert(clang_view->diagnostics.size()>0); clang_view->place_cursor_at_line_index(location.line-1, location.index-1);
flush_events();
location=clang_view->get_declaration_location({clang_view});
g_assert_cmpuint(location.line, ==, 3);
clang_view->get_buffer()->set_text(main_error);
flush_events();
while(!clang_view->parsed)
flush_events();
g_assert_cmpuint(clang_view->diagnostics.size(), >, 0);
clang_view->async_delete(); clang_view->async_delete();
clang_view->delete_thread.join(); clang_view->delete_thread.join();
while(Gtk::Main::events_pending()) flush_events();
Gtk::Main::iteration(false);
} }

Loading…
Cancel
Save