mirror of https://gitlab.com/cppit/libclangmm
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
763 B
31 lines
763 B
|
11 years ago
|
#include "clangmm.h"
|
||
|
|
#include <string>
|
||
|
8 years ago
|
#include <cassert>
|
||
|
11 years ago
|
|
||
|
8 years ago
|
int main() {
|
||
|
|
std::string tests_path=LIBCLANGMM_TESTS_PATH;
|
||
|
|
std::string path(tests_path+"/case/main.cpp");
|
||
|
11 years ago
|
|
||
|
9 years ago
|
clangmm::Index index(0, 0);
|
||
|
|
clangmm::TranslationUnit tu(index, path, {});
|
||
|
11 years ago
|
|
||
|
10 years ago
|
std::string buffer="#include <string>\n"
|
||
|
|
"int main(int argc, char *argv[]) {\n"
|
||
|
|
"std::string str;\n"
|
||
|
|
"str.\n"
|
||
|
|
"return 0\n"
|
||
|
|
"}";
|
||
|
11 years ago
|
|
||
|
8 years ago
|
tu.reparse(buffer);
|
||
|
10 years ago
|
auto results=tu.get_code_completions(buffer, 4, 5);
|
||
|
11 years ago
|
|
||
|
11 years ago
|
bool substr_found=false;
|
||
|
11 years ago
|
for(unsigned c=0;c<results.size();c++) {
|
||
|
11 years ago
|
if(results.get(c).get_chunks()[1].chunk=="substr") {
|
||
|
11 years ago
|
substr_found=true;
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
}
|
||
|
8 years ago
|
assert(substr_found);
|
||
|
11 years ago
|
}
|