Split symbols test into 3 tests
This commit is contained in:
parent
5bd910a322
commit
4c2fdd8689
1 changed files with 29 additions and 14 deletions
|
@ -20,6 +20,11 @@
|
||||||
|
|
||||||
#include "tracetools/utils.hpp"
|
#include "tracetools/utils.hpp"
|
||||||
|
|
||||||
|
void function_shared(const std::shared_ptr<int> p)
|
||||||
|
{
|
||||||
|
(void)p;
|
||||||
|
}
|
||||||
|
|
||||||
class SomeClassWithCallback
|
class SomeClassWithCallback
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -32,25 +37,30 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
void function_shared(const std::shared_ptr<int> p)
|
/*
|
||||||
{
|
Testing symbol resolution for std::function object created from a function pointer.
|
||||||
(void)p;
|
*/
|
||||||
|
TEST(TestUtils, valid_symbol_funcptr) {
|
||||||
|
std::function<void(std::shared_ptr<int>)> f = &function_shared;
|
||||||
|
EXPECT_STREQ(get_symbol(f), "function_shared(std::shared_ptr<int>)") <<
|
||||||
|
"invalid symbol";
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Testing address and symbol resolution for std::function objects.
|
Testing symbol resolution for std::function object created from a lambda.
|
||||||
*/
|
*/
|
||||||
TEST(TestUtils, valid_address_symbol) {
|
TEST(TestUtils, valid_symbol_lambda) {
|
||||||
// Function pointer
|
|
||||||
std::function<void(std::shared_ptr<int>)> f = &function_shared;
|
|
||||||
// Address for one with an actual underlying function should be non-zero
|
|
||||||
ASSERT_STREQ(get_symbol(f), "function_shared(std::shared_ptr<int>)") <<
|
|
||||||
"invalid function name";
|
|
||||||
|
|
||||||
// Lambda
|
|
||||||
std::function<int(int)> l = [](int num) {return num + 1;};
|
std::function<int(int)> l = [](int num) {return num + 1;};
|
||||||
// TODO(christophebedard) check symbol
|
EXPECT_STREQ(
|
||||||
|
get_symbol(l),
|
||||||
|
"TestUtils_valid_symbol_lambda_Test::TestBody()::{lambda(int)#1}") <<
|
||||||
|
"invalid symbol";
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Testing symbol resolution for std::function object created from std::bind.
|
||||||
|
*/
|
||||||
|
TEST(TestUtils, valid_symbol_bind) {
|
||||||
// Bind (to member function)
|
// Bind (to member function)
|
||||||
SomeClassWithCallback scwc;
|
SomeClassWithCallback scwc;
|
||||||
std::function<void(int, std::string)> fscwc = std::bind(
|
std::function<void(int, std::string)> fscwc = std::bind(
|
||||||
|
@ -59,5 +69,10 @@ TEST(TestUtils, valid_address_symbol) {
|
||||||
std::placeholders::_1,
|
std::placeholders::_1,
|
||||||
std::placeholders::_2
|
std::placeholders::_2
|
||||||
);
|
);
|
||||||
// TODO(christophebedard) check symbol
|
EXPECT_STREQ(
|
||||||
|
get_symbol(
|
||||||
|
fscwc),
|
||||||
|
"std::_Bind<void (SomeClassWithCallback::*(SomeClassWithCallback*, std::_Placeholder<1>, std::_Placeholder<2>))(int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)>")
|
||||||
|
<<
|
||||||
|
"invalid symbol";
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue