Browse Source

now the unittests compile. \o/ All declared functions & variables are defined.

master
roker 4 months ago
parent
commit
450acba1bc
2 changed files with 30 additions and 2 deletions
  1. +29
    -1
      src/types.cc
  2. +1
    -1
      test/unittest_stringpair.cc

+ 29
- 1
src/types.cc View File

@ -52,7 +52,17 @@ namespace pEp
}
return sp;
}
template<>
template<>
::stringpair_t* Wrapper<::stringpair_t*>::_new(char* key, char* value)
{
return _new<const char*, const char*>(
const_cast<const char*>(key),
const_cast<const char*>(value)
);
}
template<>
template<>
::stringpair_t* Wrapper<::stringpair_t*>::_new(const std::string& key, const std::string& value)
@ -117,6 +127,23 @@ namespace pEp
{
stringpair_list_add(value, sp.move_out());
}
template<>
ListWrapper<::stringpair_list_t*, stringpair_t*>::ListWrapper(const std::initializer_list<StringPair>& il)
: StringPairList{}
{
::stringpair_list_t* last = nullptr;
for(const StringPair& sp : il)
{
last = stringpair_list_add(last, stringpair_dup(sp.get()));
if(last==nullptr)
{
throw std::runtime_error("Cannot create StringPairList from {}: Out Of Memory.");
}
if(value==nullptr)
value = last; // save the head of linked list.
}
}
////////////////
@ -124,5 +151,6 @@ namespace pEp
template class Wrapper<::stringpair_t>;
template class Wrapper<::message>;
template class ListWrapper<::stringpair_list_t*, ::stringpair_t*>;
} // end of namespace pEp

+ 1
- 1
test/unittest_stringpair.cc View File

@ -44,7 +44,7 @@ TEST( StringPair, Dynamic )
EXPECT_EQ(spl.size(), u);
snprintf(key, 15, "k%u", u);
snprintf(value, 15, "v%u", u*91);
spl.push_back( pEp::StringPair{key, value}.move_out() );
spl.push_back( pEp::StringPair{key, value} );
}
auto find_by_key = [key](const ::stringpair_t* sp){ return strcmp(sp->key, key)==0; };


Loading…
Cancel
Save