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. 10
      tests/clang_project/main.cpp
  3. 50
      tests/source_clang_test.cc

2
tests/clang_project/CMakeLists.txt

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

10
tests/clang_project/main.cpp

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

50
tests/source_clang_test.cc

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

Loading…
Cancel
Save