mirror of https://gitlab.com/cppit/jucipp
4 changed files with 72 additions and 3 deletions
@ -0,0 +1,39 @@ |
|||||||
|
#include "test_suite.h" |
||||||
|
#include <iostream> |
||||||
|
|
||||||
|
int main() { |
||||||
|
auto &config = Config::get(); |
||||||
|
config.project.ctags_command = "ctags"; |
||||||
|
#ifdef _WIN32 |
||||||
|
std::string slash = "\\"; |
||||||
|
config.project.cmake.command = |
||||||
|
"cmake -G\"MSYS Makefiles\" -DCMAKE_INSTALL_PREFIX=/mingw64"; |
||||||
|
#else |
||||||
|
auto slash = "/"; |
||||||
|
config.project.cmake.command = "cmake"; |
||||||
|
#endif |
||||||
|
auto suite_name = "Ctags_tests"; |
||||||
|
|
||||||
|
{ |
||||||
|
auto doTest = [&](auto test) { |
||||||
|
auto test_suite = suite(suite_name); |
||||||
|
{ |
||||||
|
auto module = py::module::import("ctags_test"); |
||||||
|
test_suite.has_assertion = false; |
||||||
|
auto project_path = (test_suite.test_file_path / "cmake_project") |
||||||
|
.make_preferred() |
||||||
|
.string(); |
||||||
|
try { |
||||||
|
module.attr(test)(project_path, slash); |
||||||
|
test_suite.has_assertion = true; |
||||||
|
} |
||||||
|
catch(const std::exception &error) { |
||||||
|
std::cout << error.what(); |
||||||
|
} |
||||||
|
} |
||||||
|
}; |
||||||
|
|
||||||
|
doTest("get_location"); |
||||||
|
doTest("get_locations"); |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,27 @@ |
|||||||
|
from Jucipp import Ctags |
||||||
|
from jucipp_test import assert_equal |
||||||
|
|
||||||
|
def get_location(a, b): |
||||||
|
line = 'main main.cpp /^int main() { return 0; }$/;" line:1' |
||||||
|
location = Ctags.get_location(line, False) |
||||||
|
if location: |
||||||
|
assert_equal('main.cpp', location.file_path) |
||||||
|
assert_equal(0, location.line) |
||||||
|
assert_equal(4, location.index) |
||||||
|
assert_equal('main', location.symbol) |
||||||
|
assert_equal('', location.scope) |
||||||
|
assert_equal('int main() { return 0; }', location.source) |
||||||
|
else: |
||||||
|
raise ValueError('File path was empty') |
||||||
|
|
||||||
|
def get_locations(project_path, slash): |
||||||
|
path = project_path + slash + 'main.cpp' |
||||||
|
locations = Ctags.get_locations(project_path + slash + 'main.cpp', 'main', 'int ()') |
||||||
|
assert_equal(len(locations), 1) |
||||||
|
location = locations[0]; |
||||||
|
assert_equal(path, location.file_path) |
||||||
|
assert_equal(0, location.line) |
||||||
|
assert_equal(4, location.index) |
||||||
|
assert_equal('main', location.symbol) |
||||||
|
assert_equal('', location.scope) |
||||||
|
assert_equal('int main() { return 0; }', location.source) |
||||||
Loading…
Reference in new issue