[Libreoffice-commits] core.git: o3tl/qa
Miklos Vajna
vmiklos at collabora.co.uk
Fri May 27 07:41:57 UTC 2016
o3tl/qa/cow_wrapper_clients.hxx | 9 ++++++++
o3tl/qa/test-cow_wrapper.cxx | 44 ++++++++++++++++++++--------------------
o3tl/qa/test-vector_pool.cxx | 10 ++++-----
3 files changed, 36 insertions(+), 27 deletions(-)
New commits:
commit 23172fc9337c7f0928de0d938de31a0341c32e89
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Fri May 27 08:23:07 2016 +0200
CppunitTest_o3tl_tests: fix loplugin:cppunitassertequals warnings in ...
... cow_wrapper and vector_pool
Change-Id: I1f224a6bd933592dcb34defd5ad5c480d82346cb
Reviewed-on: https://gerrit.libreoffice.org/25531
Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
Tested-by: Jenkins <ci at libreoffice.org>
diff --git a/o3tl/qa/cow_wrapper_clients.hxx b/o3tl/qa/cow_wrapper_clients.hxx
index 0cd1b4a..48b745a 100644
--- a/o3tl/qa/cow_wrapper_clients.hxx
+++ b/o3tl/qa/cow_wrapper_clients.hxx
@@ -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
diff --git a/o3tl/qa/test-cow_wrapper.cxx b/o3tl/qa/test-cow_wrapper.cxx
index 7c61da6..1ec5f71 100644
--- a/o3tl/qa/test-cow_wrapper.cxx
+++ b/o3tl/qa/test-cow_wrapper.cxx
@@ -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
diff --git a/o3tl/qa/test-vector_pool.cxx b/o3tl/qa/test-vector_pool.cxx
index c1c6677..91cdcf9 100644
--- a/o3tl/qa/test-vector_pool.cxx
+++ b/o3tl/qa/test-vector_pool.cxx
@@ -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
More information about the Libreoffice-commits
mailing list