Browse Source

fix unittests. but there is still a lot to do...

master
roker 1 week ago
parent
commit
68f3006e37
1 changed files with 10 additions and 8 deletions
  1. +10
    -8
      test/unittest_stringpair.cc

+ 10
- 8
test/unittest_stringpair.cc View File

@ -2,13 +2,15 @@
#include "../src/types.hh"
typedef pEp::StringPair SP;
TEST( StringPair, Simple )
{
pEp::StringPair s1{"key", "value"};
pEp::StringPairList spl;
EXPECT_TRUE(spl.empty());
EXPECT_EQUAL(spl.size(), 0);
EXPECT_EQ(spl.size(), 0);
// pEp::StringPair s2{ std::string{"key2"}, std::string{"value"} };
}
@ -16,11 +18,11 @@ TEST( StringPair, Simple )
TEST( StringPair, InitList )
{
pEp::StringPairList spl{ {"key0", "value0"}, {"key1", "value1"} };
EXPECT_EQUAL( spl.size(), 2);
pEp::StringPairList spl( { SP{"key0", "value0"}, SP{"key1", "value1"} } );
EXPECT_EQ( spl.size(), 2);
spl.clear();
EXPECT_EQUAL(spl.size(), 0);
EXPECT_EQ(spl.size(), 0);
EXPECT_TRUE( spl.empty() );
}
@ -33,12 +35,12 @@ TEST( StringPair, Dynamic )
char value[16];
pEp::StringPairList spl;
EXPECT_EQUAL(spl.size(), 0);
EXPECT_EQ(spl.size(), 0);
EXPECT_TRUE( spl.empty() );
for(unsigned u=0; u<NumberOfElements; ++u)
{
EXPECT_EQUAL(spl.size(), u);
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} );
@ -51,12 +53,12 @@ TEST( StringPair, Dynamic )
{
EXPECT_EQUAL(spl.size(), NumberOfElements-u);
snprintf(key, 15, "k%u", (u*7) % NumberOfElements); // permutate keys order
auto q = std::find( spl.begin(), spl.end(), find_by_keys );
auto q = std::find( spl.begin(), spl.end(), find_by_key );
EXPECT_NE( q, spl.end() ); // element with key is found
spl.erase(q);
q = std::find( spl.begin(), spl.end(), find_by_keys );
q = std::find( spl.begin(), spl.end(), find_by_key );
EXPECT_EQ( q, spl.end() ); // element with that key is no longer found
}
}

Loading…
Cancel
Save