MCPcopy Create free account
hub / github.com/Compaile/ctrack / skipPathFromFilename

Function skipPathFromFilename

test/doctest.h:3889–3922  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3887DOCTEST_GCC_SUPPRESS_WARNING_WITH_PUSH("-Wnull-dereference")
3888// depending on the current options this will remove the path of filenames
3889const char* skipPathFromFilename(const char* file) {
3890#ifndef DOCTEST_CONFIG_DISABLE
3891 if(getContextOptions()->no_path_in_filenames) {
3892 auto back = std::strrchr(file, '\\');
3893 auto forward = std::strrchr(file, '/');
3894 if(back || forward) {
3895 if(back > forward)
3896 forward = back;
3897 return forward + 1;
3898 }
3899 } else {
3900 const auto prefixes = getContextOptions()->strip_file_prefixes;
3901 const char separator = DOCTEST_CONFIG_OPTIONS_FILE_PREFIX_SEPARATOR;
3902 String::size_type longest_match = 0U;
3903 for(String::size_type pos = 0U; pos < prefixes.size(); ++pos)
3904 {
3905 const auto prefix_start = pos;
3906 pos = std::min(prefixes.find(separator, prefix_start), prefixes.size());
3907
3908 const auto prefix_size = pos - prefix_start;
3909 if(prefix_size > longest_match)
3910 {
3911 // TODO under DOCTEST_MSVC: does the comparison need strnicmp() to work with drive letter capitalization?
3912 if(0 == std::strncmp(prefixes.c_str() + prefix_start, file, prefix_size))
3913 {
3914 longest_match = prefix_size;
3915 }
3916 }
3917 }
3918 return &file[longest_match];
3919 }
3920#endif // DOCTEST_CONFIG_DISABLE
3921 return file;
3922}
3923DOCTEST_CLANG_SUPPRESS_WARNING_POP
3924DOCTEST_GCC_SUPPRESS_WARNING_POP
3925

Callers 12

test_case_start_implMethod · 0.85
report_queryMethod · 0.85
test_run_startMethod · 0.85
subcase_startMethod · 0.85
log_assertMethod · 0.85
log_messageMethod · 0.85
test_run_endMethod · 0.85
test_case_startMethod · 0.85
test_case_reenterMethod · 0.85
log_assertMethod · 0.85
log_messageMethod · 0.85
file_line_to_streamMethod · 0.85

Calls 1

getContextOptionsFunction · 0.85

Tested by

no test coverage detected