Browse Source

Tests: Utils rename to_string() functions

LIB-12
heck 1 year ago
parent
commit
06a3fdb0b0
5 changed files with 32 additions and 32 deletions
  1. +12
    -12
      test/framework/utils.cc
  2. +6
    -6
      test/framework/utils.hh
  3. +1
    -1
      test/framework/utils.hxx
  4. +8
    -8
      test/test_group.cc
  5. +5
    -5
      test/test_lm_dummy.cc

+ 12
- 12
test/framework/utils.cc View File

@ -38,7 +38,7 @@ namespace pEp {
namespace Utils {
string identity_to_string(::pEp_identity *ident, bool full, int indent)
string to_string(::pEp_identity *ident, bool full, int indent)
{
stringstream builder;
if (ident != nullptr) {
@ -81,7 +81,7 @@ namespace pEp {
return builder.str();
}
std::string identitylist_to_string(::identity_list *idl, bool full, int indent)
std::string to_string(::identity_list *idl, bool full, int indent)
{
stringstream builder;
if (idl != nullptr) {
@ -89,7 +89,7 @@ namespace pEp {
builder << std::string(indent, '\t') << "[" << endl;
indent++;
for (::identity_list *curr = idl; curr != nullptr; curr = curr->next) {
builder << identity_to_string(curr->ident, full, indent) << endl;
builder << to_string(curr->ident, full, indent) << endl;
}
indent--;
builder << std::string(indent, '\t') << "]";
@ -100,14 +100,14 @@ namespace pEp {
return builder.str();
}
string member_to_string(::pEp_member *member, bool full, int indent)
string to_string(::pEp_member *member, bool full, int indent)
{
stringstream builder;
if (member != nullptr) {
builder << std::string(indent, '\t') << "{" << endl;
indent++;
builder << std::string(indent, '\t')
<< "ident: " << identity_to_string(member->ident, full, indent) << endl;
<< "ident: " << to_string(member->ident, full, indent) << endl;
builder << std::string(indent, '\t') << "joined: " << member->joined << endl;
indent--;
builder << std::string(indent, '\t') << "}";
@ -118,7 +118,7 @@ namespace pEp {
return builder.str();
}
string memberlist_to_string(::member_list *mbl, bool full, int indent)
string to_string(::member_list *mbl, bool full, int indent)
{
stringstream builder;
if (mbl != nullptr) {
@ -127,7 +127,7 @@ namespace pEp {
indent++;
for (member_list *curr_member = mbl; curr_member != nullptr;
curr_member = curr_member->next) {
builder << member_to_string(curr_member->member, full, indent) << endl;
builder << to_string(curr_member->member, full, indent) << endl;
}
indent--;
builder << std::string(indent, '\t') << "]";
@ -138,7 +138,7 @@ namespace pEp {
return builder.str();
}
string group_to_string(::pEp_group *group, bool full, int indent)
string to_string(::pEp_group *group, bool full, int indent)
{
stringstream builder;
if (group != nullptr) {
@ -146,13 +146,13 @@ namespace pEp {
builder << std::string(indent, '\t') << "{" << endl;
indent++;
builder << std::string(indent, '\t') << "group_identity: "
<< identity_to_string(group->group_identity, full, indent) << endl;
<< to_string(group->group_identity, full, indent) << endl;
builder << std::string(indent, '\t')
<< "manager: " << identity_to_string(group->manager, full, indent)
<< "manager: " << to_string(group->manager, full, indent)
<< endl;
builder << std::string(indent, '\t') << "active: " << group->active << endl;
builder << std::string(indent, '\t')
<< "members: " << memberlist_to_string(group->members, full, indent)
<< "members: " << to_string(group->members, full, indent)
<< endl;
indent--;
builder << std::string(indent, '\t') << "]";
@ -205,6 +205,6 @@ namespace pEp {
}
}
} // namespace Utils
} // namespace Utils
} // namespace Test
} // namespace pEp

+ 6
- 6
test/framework/utils.hh View File

@ -18,15 +18,15 @@ namespace pEp {
}
namespace Utils {
// pEpEngine datatypes to string
std::string identity_to_string(::pEp_identity *ident, bool full = true, int indent = 0);
std::string identitylist_to_string(::identity_list *idl, bool full = true, int indent = 0);
std::string member_to_string(::pEp_member *member, bool full = true, int indent = 0);
std::string memberlist_to_string(::member_list *mbl, bool full = true, int indent = 0);
std::string group_to_string(::pEp_group *group, bool full = true, int indent = 0);
std::string to_string(::pEp_identity *ident, bool full = true, int indent = 0);
std::string to_string(::identity_list *idl, bool full = true, int indent = 0);
std::string to_string(::pEp_member *member, bool full = true, int indent = 0);
std::string to_string(::member_list *mbl, bool full = true, int indent = 0);
std::string to_string(::pEp_group *group, bool full = true, int indent = 0);
// C++/STL data types to string
template<typename T>
std::string vector_to_string(std::vector<T> v);
std::string to_string(std::vector<T> v);
// exception utils
void print_exception(const std::exception& e, int level = 0);


+ 1
- 1
test/framework/utils.hxx View File

@ -10,7 +10,7 @@ namespace pEp {
namespace Test {
namespace Utils {
template<typename T>
std::string vector_to_string(std::vector<T> v)
std::string to_string(std::vector<T> v)
{
std::stringstream ss;
for (const T& elem : v) {


+ 8
- 8
test/test_group.cc View File

@ -35,8 +35,8 @@ bool debug_info_full = true;
::PEP_STATUS test_notifyHandshake(::pEp_identity* _me, ::pEp_identity* _partner, sync_handshake_signal signal)
{
cout << "called" << endl;
cout << "me: " << Test::Utils::identity_to_string(_me, false) << endl;
cout << "partner: " << Test::Utils::identity_to_string(_partner, false) << endl;
cout << "me: " << Test::Utils::to_string(_me, false) << endl;
cout << "partner: " << Test::Utils::to_string(_partner, false) << endl;
cout << "Signal: " << signal << endl;
return PEP_STATUS_OK;
@ -56,7 +56,7 @@ void test_create_alice_me()
status = ::myself(Adapter::session(), alice);
cout << "STATUS: " << status_to_string(status) << endl;
assert(!status);
cout << "Alice:" << Test::Utils::identity_to_string(alice, debug_info_full) << endl;
cout << "Alice:" << Test::Utils::to_string(alice, debug_info_full) << endl;
}
void test_create_bob_partner()
@ -69,7 +69,7 @@ void test_create_bob_partner()
status = ::update_identity(Adapter::session(), bob);
cout << "STATUS: " << status_to_string(status) << endl;
assert(!status);
cout << "Bob:" << Test::Utils::identity_to_string(bob, debug_info_full) << endl;
cout << "Bob:" << Test::Utils::to_string(bob, debug_info_full) << endl;
}
void test_create_carol_partner()
@ -82,7 +82,7 @@ void test_create_carol_partner()
status = ::update_identity(Adapter::session(), carol);
cout << "STATUS: " << status_to_string(status) << endl;
assert(!status);
cout << "Carol:" << Test::Utils::identity_to_string(carol, debug_info_full) << endl;
cout << "Carol:" << Test::Utils::to_string(carol, debug_info_full) << endl;
}
void test_setup_and_start_sync()
@ -94,7 +94,7 @@ void test_setup_and_start_sync()
void test_group_create(::identity_list* idl)
{
logH2("test_group_create");
cout << "IDL: " << Test::Utils::identitylist_to_string(idl, debug_info_full) << endl;
cout << "IDL: " << Test::Utils::to_string(idl, debug_info_full) << endl;
cout << "create group identity" << endl;
grp_ident = ::new_identity("group1@peptest.ch", NULL, "432", "group1");
@ -102,7 +102,7 @@ void test_group_create(::identity_list* idl)
status = ::myself(Adapter::session(), grp_ident);
cout << "STATUS: " << status_to_string(status) << endl;
assert(!status);
cout << "grp_ident:" << Test::Utils::identity_to_string(grp_ident, debug_info_full) << endl;
cout << "grp_ident:" << Test::Utils::to_string(grp_ident, debug_info_full) << endl;
cout << "adapter_group_create()" << endl;
::pEp_group* pep_grp1 = nullptr;
@ -110,7 +110,7 @@ void test_group_create(::identity_list* idl)
cout << "STATUS: " << status_to_string(status) << endl;
assert(!status);
assert(pep_grp1);
cout << "GRP: " << Test::Utils::group_to_string(pep_grp1, debug_info_full) << endl;
cout << "GRP: " << Test::Utils::to_string(pep_grp1, debug_info_full) << endl;
}
void test_group_invite_member(::pEp_identity* ident)


+ 5
- 5
test/test_lm_dummy.cc View File

@ -37,7 +37,7 @@ void test_create_alice_me()
status = ::myself(Adapter::session(), alice);
cout << "STATUS: " << status_to_string(status) << endl;
assert(!status);
cout << "Alice:" << Test::Utils::identity_to_string(alice, debug_info_full) << endl;
cout << "Alice:" << Test::Utils::to_string(alice, debug_info_full) << endl;
}
void test_create_bob_partner()
@ -50,7 +50,7 @@ void test_create_bob_partner()
status = ::update_identity(Adapter::session(), bob);
cout << "STATUS: " << status_to_string(status) << endl;
assert(!status);
cout << "Bob:" << Test::Utils::identity_to_string(bob, debug_info_full) << endl;
cout << "Bob:" << Test::Utils::to_string(bob, debug_info_full) << endl;
}
void test_create_carol_partner()
@ -63,14 +63,14 @@ void test_create_carol_partner()
status = ::update_identity(Adapter::session(), carol);
cout << "STATUS: " << status_to_string(status) << endl;
assert(!status);
cout << "Carol:" << Test::Utils::identity_to_string(carol, debug_info_full) << endl;
cout << "Carol:" << Test::Utils::to_string(carol, debug_info_full) << endl;
}
void test_group_create(::identity_list* idl)
{
logH2("test_group_create");
cout << "IDL: " << Test::Utils::identitylist_to_string(idl, debug_info_full) << endl;
cout << "IDL: " << Test::Utils::to_string(idl, debug_info_full) << endl;
cout << "create group identity" << endl;
grp_ident = ::new_identity("group1@peptest.ch", NULL, "432", "group1");
@ -78,7 +78,7 @@ void test_group_create(::identity_list* idl)
status = ::myself(Adapter::session(), grp_ident);
cout << "STATUS: " << status_to_string(status) << endl;
assert(!status);
cout << "grp_ident:" << Test::Utils::identity_to_string(grp_ident, debug_info_full) << endl;
cout << "grp_ident:" << Test::Utils::to_string(grp_ident, debug_info_full) << endl;
lm_backend->create(grp_ident, alice, idl);
}


Loading…
Cancel
Save