Kaydet (Commit) 23172fc9 authored tarafından Miklos Vajna's avatar Miklos Vajna

CppunitTest_o3tl_tests: fix loplugin:cppunitassertequals warnings in ...

... cow_wrapper and vector_pool

Change-Id: I1f224a6bd933592dcb34defd5ad5c480d82346cb
Reviewed-on: https://gerrit.libreoffice.org/25531Reviewed-by: 's avatarMiklos Vajna <vmiklos@collabora.co.uk>
Tested-by: 's avatarJenkins <ci@libreoffice.org>
üst 9eb2e683
......@@ -186,6 +186,7 @@ public:
cow_wrapper_client5& operator=( const cow_wrapper_client5& );
cow_wrapper_client5& operator=( cow_wrapper_client5&& );
int queryUnmodified() const { return *maImpl; }
sal_uInt32 use_count() const { return maImpl.use_count(); }
bool operator==( const cow_wrapper_client5& rRHS ) const;
......@@ -194,6 +195,14 @@ public:
private:
o3tl::cow_wrapper< int, BogusRefCountPolicy > maImpl;
};
template< typename charT, typename traits >
inline std::basic_ostream<charT, traits> & operator <<(
std::basic_ostream<charT, traits> & stream, const cow_wrapper_client5& client )
{
return stream << client.queryUnmodified();
}
} // namespace o3tltests
#endif // INCLUDED_O3TL_QA_COW_WRAPPER_CLIENTS_HXX
......
......@@ -170,8 +170,8 @@ public:
// will occur
cow_wrapper_client5 aTestObj1(1);
cow_wrapper_client5 aTestObj2( std::move( aTestObj1 ) );
CPPUNIT_ASSERT_MESSAGE("aTestObj2.use_count() == 1",
aTestObj2.use_count() == 1 );
CPPUNIT_ASSERT_EQUAL_MESSAGE("aTestObj2.use_count()",
static_cast<sal_uInt32>(1), aTestObj2.use_count() );
// the following should increment
BogusRefCountPolicy::s_bShouldIncrement = true;
......@@ -179,8 +179,8 @@ public:
CPPUNIT_ASSERT_MESSAGE("s_bShouldIncrement == 0",
!BogusRefCountPolicy::s_bShouldIncrement );
CPPUNIT_ASSERT_MESSAGE("aTestObj3.use_count() == 2",
aTestObj3.use_count() == 2 );
CPPUNIT_ASSERT_EQUAL_MESSAGE("aTestObj3.use_count()",
static_cast<sal_uInt32>(2), aTestObj3.use_count() );
{
cow_wrapper_client5 aTestObj4;
// the following should decrement the lvalue and then increment the rvalue
......@@ -192,18 +192,18 @@ public:
CPPUNIT_ASSERT_MESSAGE("s_bShouldDecrement == 0",
!BogusRefCountPolicy::s_bShouldDecrement );
CPPUNIT_ASSERT_MESSAGE("aTestObj2.use_count() == 3",
aTestObj2.use_count() == 3 );
CPPUNIT_ASSERT_MESSAGE("aTestObj3.use_count() == 3",
aTestObj3.use_count() == 3 );
CPPUNIT_ASSERT_MESSAGE("aTestObj4.use_count() == 3",
aTestObj4.use_count() == 3 );
CPPUNIT_ASSERT_MESSAGE("aTestObj2 == aTestObj3",
aTestObj2 == aTestObj3 );
CPPUNIT_ASSERT_MESSAGE("aTestObj3 == aTestObj4",
aTestObj3 == aTestObj4 );
CPPUNIT_ASSERT_MESSAGE("aTestObj2 == aTestObj4",
aTestObj2 == aTestObj4 );
CPPUNIT_ASSERT_EQUAL_MESSAGE("aTestObj2.use_count()",
static_cast<sal_uInt32>(3), aTestObj2.use_count() );
CPPUNIT_ASSERT_EQUAL_MESSAGE("aTestObj3.use_count()",
static_cast<sal_uInt32>(3), aTestObj3.use_count() );
CPPUNIT_ASSERT_EQUAL_MESSAGE("aTestObj4.use_count()",
static_cast<sal_uInt32>(3), aTestObj4.use_count() );
CPPUNIT_ASSERT_EQUAL_MESSAGE("aTestObj2 == aTestObj3",
aTestObj3, aTestObj2 );
CPPUNIT_ASSERT_EQUAL_MESSAGE("aTestObj3 == aTestObj4",
aTestObj4, aTestObj3 );
CPPUNIT_ASSERT_EQUAL_MESSAGE("aTestObj2 == aTestObj4",
aTestObj4, aTestObj2 );
// only decrement the lvalue before assignment
BogusRefCountPolicy::s_bShouldDecrement = true;
......@@ -222,10 +222,10 @@ public:
// aTestObj2 is defunct afterwards, one decrement happens
BogusRefCountPolicy::s_bShouldDecrement = true;
aTestObj3 = std::move( aTestObj2 );
CPPUNIT_ASSERT_MESSAGE("aTestObj2.use_count() == 0",
aTestObj2.use_count() == 0 );
CPPUNIT_ASSERT_MESSAGE("aTestObj3.use_count() == 1",
aTestObj3.use_count() == 1 );
CPPUNIT_ASSERT_EQUAL_MESSAGE("aTestObj2.use_count()",
static_cast<sal_uInt32>(0), aTestObj2.use_count() );
CPPUNIT_ASSERT_EQUAL_MESSAGE("aTestObj3.use_count()",
static_cast<sal_uInt32>(1), aTestObj3.use_count() );
cow_wrapper_client5 aTestObj5;
......@@ -240,8 +240,8 @@ public:
// aTestObj3 still holds a valid instance
BogusRefCountPolicy::s_nEndOfScope = 1;
}
CPPUNIT_ASSERT_MESSAGE("s_EndOfScope == 0",
BogusRefCountPolicy::s_nEndOfScope == 0 );
CPPUNIT_ASSERT_EQUAL_MESSAGE("s_EndOfScope",
static_cast<sal_uInt32>(0), BogusRefCountPolicy::s_nEndOfScope );
}
// Change the following lines only, if you add, remove or rename
......
......@@ -55,22 +55,22 @@ public:
vector_pool<int> aPool;
std::ptrdiff_t nIdx1 = aPool.store(0);
CPPUNIT_ASSERT_MESSAGE("allocator value semantics 1", aPool.get(nIdx1) == 0 );
CPPUNIT_ASSERT_EQUAL_MESSAGE("allocator value semantics 1", 0, aPool.get(nIdx1) );
std::ptrdiff_t nIdx2 = aPool.store(1);
CPPUNIT_ASSERT_MESSAGE("allocator value semantics 2", aPool.get(nIdx2) == 1 );
CPPUNIT_ASSERT_EQUAL_MESSAGE("allocator value semantics 2", 1, aPool.get(nIdx2) );
std::ptrdiff_t nIdx3 = aPool.store(2);
CPPUNIT_ASSERT_MESSAGE("allocator value semantics 3", aPool.get(nIdx3) == 2 );
CPPUNIT_ASSERT_EQUAL_MESSAGE("allocator value semantics 3", 2, aPool.get(nIdx3) );
aPool.free(nIdx2);
aPool.free(nIdx3);
nIdx2 = aPool.store(1);
CPPUNIT_ASSERT_MESSAGE("allocator value semantics 2 after fragmentation", aPool.get(nIdx2) == 1 );
CPPUNIT_ASSERT_EQUAL_MESSAGE("allocator value semantics 2 after fragmentation", 1, aPool.get(nIdx2) );
nIdx3 = aPool.store(2);
CPPUNIT_ASSERT_MESSAGE("allocator value semantics 3 after fragmentation", aPool.get(nIdx3) == 2 );
CPPUNIT_ASSERT_EQUAL_MESSAGE("allocator value semantics 3 after fragmentation", 2, aPool.get(nIdx3) );
}
// Change the following lines only, if you add, remove or rename
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment