A C++ wrapper for the basic C datatypes defined by the pEpEngine.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

69 lines
1.8 KiB

#include <gtest/gtest.h>
#include "../src/types.hh"
TEST( PepIdentity, Simple )
{
pEp::Identity id{"test1@pEpdatatypes.lol", "FF00112233445566778899AABBCCDDEEFF001122", "Test User ID", "Test User Name"};
}
TEST( IdentityList, Simple )
{
pEp::IdentityList il;
EXPECT_TRUE(il.empty());
EXPECT_EQ(il.size(), 0);
}
TEST( IdentityList, InitList )
{
pEp::IdentityList il(
{
pEp::Identity{"test-init1@pEpdatatypes.lol", "0100112233445566778899AABBCCDDEEFF001122", "Test User ID1", "Test User 1 Name"},
pEp::Identity{"test-init2@pEpdatatypes.lol", "0200112233445566778899AABBCCDDEEFF001122", "Test User ID2", "Test User 2 Name"}
} );
EXPECT_EQ( il.size(), 2);
il.clear();
EXPECT_EQ(il.size(), 0);
EXPECT_TRUE( il.empty() );
}
/*
TEST( IdentityList, Dynamic )
{
static const unsigned NumberOfElements = 17;
pEp::IdentityList il;
EXPECT_EQ(il.size(), 0);
EXPECT_TRUE( il.empty() );
char buffer[16];
for(unsigned u=0; u<NumberOfElements; ++u)
{
EXPECT_EQ(sl.size(), u);
snprintf(buffer, 15, "k%u", u);
sl.push_back( buffer );
}
auto find_value = [&buffer](const char* v){ return strcmp(v, buffer)==0; };
// delete random elements.
for(unsigned u=0; u<NumberOfElements; ++u)
{
EXPECT_EQ(sl.size(), NumberOfElements-u);
snprintf(buffer, 15, "k%u", (u*7) % NumberOfElements); // permutate keys order
auto q = std::find_if( sl.begin(), sl.end(), find_value );
ASSERT_NE( q, sl.end() ); // element with key is found
EXPECT_STREQ( *q, buffer);
sl.erase(q);
q = std::find_if( sl.begin(), sl.end(), find_value );
EXPECT_EQ( q, sl.end() ); // element with that key is no longer found
}
}
*/