Skip to content

Commit

Permalink
fix: occurences replacement
Browse files Browse the repository at this point in the history
  • Loading branch information
martin-olivier committed Jul 14, 2024
1 parent 7e85a21 commit 3e88b2a
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 17 deletions.
11 changes: 2 additions & 9 deletions src/dylib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,15 +155,8 @@ std::string format_symbol(std::string input) {
replace_occurrences(input, "std::__1::", "std::");
replace_occurrences(input, "std::__cxx11::", "std::");

input.erase(
std::remove_if(
input.begin(),
input.end(),
::isspace
), input.end()
);

add_space_after_comma(input);
replace_occurrences(input, "> >", ">>");
replace_occurrences(input, "()", "(void)");

return input;
}
Expand Down
8 changes: 1 addition & 7 deletions src/win.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,7 @@ std::string format_symbol(std::string input) {
replace_occurrences(input, "<struct ", "<");
replace_occurrences(input, ",struct ", ",");

input.erase(
std::remove_if(
input.begin(),
input.end(),
::isspace
), input.end()
);
replace_occurrences(input, ">const", "> const");

add_space_after_comma(input);

Expand Down
4 changes: 4 additions & 0 deletions tests/lib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,9 @@ namespace tools {
LIB_EXPORT void println(std::string &&str) {
std::cout << "mov: " << str << std::endl;
}

LIB_EXPORT void println(const unsigned int& val) {
std::cout << "ref: " << val << std::endl;
}
}
}
7 changes: 6 additions & 1 deletion tests/tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,14 +210,19 @@ TEST(cpp_symbols, basic_test) {
auto text = std::string("bla,bla,bla...");

testing::internal::CaptureStdout();
auto ref_println = lib.get_function<void(const std::string&)>("tools::string::println(std::basic_string<char, std::char_traits<char>, std::allocator<char>>const&)");
auto ref_println = lib.get_function<void(const std::string&)>("tools::string::println(std::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)");
ref_println(text);
EXPECT_EQ(testing::internal::GetCapturedStdout(), "ref: bla,bla,bla...\n");

testing::internal::CaptureStdout();
auto mov_println = lib.get_function<void(std::string&&)>("tools::string::println(std::basic_string<char, std::char_traits<char>, std::allocator<char>>&&)");
mov_println(std::move(text));
EXPECT_EQ(testing::internal::GetCapturedStdout(), "mov: bla,bla,bla...\n");

testing::internal::CaptureStdout();
auto int_ref_println = lib.get_function<void(const unsigned int&)>("tools::string::println(unsigned int const&)");
int_ref_println(123);
EXPECT_EQ(testing::internal::GetCapturedStdout(), "ref: 123\n");
}

int main(int ac, char **av) {
Expand Down

0 comments on commit 3e88b2a

Please sign in to comment.