sal/qa/systools/test_comtools.cxx | 44 +++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 22 deletions(-)
New commits: commit cebc28ce2f2daba73853828f4f81fb06b972e098 Author: Stephan Bergmann <[email protected]> AuthorDate: Mon Mar 4 13:34:34 2019 +0100 Commit: Stephan Bergmann <[email protected]> CommitDate: Mon Mar 4 15:38:46 2019 +0100 Fix various clang-cl warnings ...in Windows-only code that has recently been brought back to life with db8a2a567087cb65ca420bfd582ea2c8c24fcd7b "tdf#39625 make sal/qa/systools/test_comtools.cxx work with CppUnit" Change-Id: Ia93e84f5719c2320789aec5f711067f9174acb55 Reviewed-on: https://gerrit.libreoffice.org/68682 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <[email protected]> diff --git a/sal/qa/systools/test_comtools.cxx b/sal/qa/systools/test_comtools.cxx index 42e5215d729d..284a28b1f407 100644 --- a/sal/qa/systools/test_comtools.cxx +++ b/sal/qa/systools/test_comtools.cxx @@ -28,17 +28,17 @@ public: { } - ~COMObject() + virtual ~COMObject() { } - ULONG __stdcall AddRef() + ULONG __stdcall AddRef() override { ref_count_++; return ref_count_; } - ULONG __stdcall Release() + ULONG __stdcall Release() override { ULONG cnt = --ref_count_; if (cnt == 0) @@ -46,7 +46,7 @@ public: return cnt; } - HRESULT __stdcall QueryInterface(REFIID riid, LPVOID* ppv) + HRESULT __stdcall QueryInterface(REFIID riid, LPVOID* ppv) override { if (riid == IID_IUnknown) { @@ -66,12 +66,12 @@ private: ULONG ref_count_; }; -sal::systools::COMReference<IUnknown> comObjectSource() +static sal::systools::COMReference<IUnknown> comObjectSource() { return sal::systools::COMReference<IUnknown>(new COMObject); } -bool comObjectSink(sal::systools::COMReference<IUnknown> r, ULONG expectedRefCountOnReturn) +static bool comObjectSink(sal::systools::COMReference<IUnknown> r, ULONG expectedRefCountOnReturn) { r = sal::systools::COMReference<IUnknown>(); COMObject* p = reinterpret_cast<COMObject*>(r.get()); @@ -81,7 +81,7 @@ bool comObjectSink(sal::systools::COMReference<IUnknown> r, ULONG expectedRefCou return (0 == expectedRefCountOnReturn); } -void comObjectSource2(LPVOID* ppv) +static void comObjectSource2(LPVOID* ppv) { COMObject* p = new COMObject; p->AddRef(); @@ -99,7 +99,7 @@ namespace test_comtools void default_ctor() { sal::systools::COMReference<IUnknown> r; - CPPUNIT_ASSERT_MESSAGE("COMReference should be empty", r.get() == NULL); + CPPUNIT_ASSERT_EQUAL_MESSAGE("COMReference should be empty", static_cast<IUnknown *>(nullptr), r.get()); } void test_ctor_manual_AddRef() @@ -107,44 +107,44 @@ namespace test_comtools COMObject* p = new COMObject; p->AddRef(); sal::systools::COMReference<IUnknown> r(p, false); - CPPUNIT_ASSERT_MESSAGE("Wrong reference count 1 is expected", reinterpret_cast<COMObject*>(r.get())->GetRefCount() == 1); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong reference count 1 is expected", ULONG(1), reinterpret_cast<COMObject*>(r.get())->GetRefCount()); } void test_copy_ctor() { sal::systools::COMReference<IUnknown> r(comObjectSource()); - CPPUNIT_ASSERT_MESSAGE("Wrong reference count 1 is expected", reinterpret_cast<COMObject*>(r.get())->GetRefCount() == 1); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong reference count 1 is expected", ULONG(1), reinterpret_cast<COMObject*>(r.get())->GetRefCount()); } void test_copy_assignment() { sal::systools::COMReference<IUnknown> r; - CPPUNIT_ASSERT_MESSAGE("COMReference should be empty", r.get() == NULL); + CPPUNIT_ASSERT_EQUAL_MESSAGE("COMReference should be empty", static_cast<IUnknown *>(nullptr), r.get()); r = comObjectSource(); - CPPUNIT_ASSERT_MESSAGE("COMReference should be empty", r.get() != NULL); - CPPUNIT_ASSERT_MESSAGE("Wrong reference count 1 is expected", reinterpret_cast<COMObject*>(r.get())->GetRefCount() == 1); + CPPUNIT_ASSERT_MESSAGE("COMReference should be empty", r.get() != nullptr); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong reference count 1 is expected", ULONG(1), reinterpret_cast<COMObject*>(r.get())->GetRefCount()); } void test_ref_to_ref_assignment() { sal::systools::COMReference<IUnknown> r1 = comObjectSource(); sal::systools::COMReference<IUnknown> r2 = r1; - CPPUNIT_ASSERT_MESSAGE("Wrong reference count 2 is expected", reinterpret_cast<COMObject*>(r2.get())->GetRefCount() == 2); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong reference count 2 is expected", ULONG(2), reinterpret_cast<COMObject*>(r2.get())->GetRefCount()); } void test_pointer_to_ref_assignment() { sal::systools::COMReference<IUnknown> r; r = new COMObject; - CPPUNIT_ASSERT_MESSAGE("Wrong reference count 1 is expected", reinterpret_cast<COMObject*>(r.get())->GetRefCount() == 1); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong reference count 1 is expected", ULONG(1), reinterpret_cast<COMObject*>(r.get())->GetRefCount()); } void test_pointer_to_ref_assignment2() { sal::systools::COMReference<IUnknown> r = comObjectSource(); r = new COMObject; - CPPUNIT_ASSERT_MESSAGE("Wrong reference count 1 is expected", reinterpret_cast<COMObject*>(r.get())->GetRefCount() == 1); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong reference count 1 is expected", ULONG(1), reinterpret_cast<COMObject*>(r.get())->GetRefCount()); } void test_source_sink() @@ -156,23 +156,23 @@ namespace test_comtools { sal::systools::COMReference<IUnknown> r; comObjectSource2(reinterpret_cast<LPVOID*>(&r)); - CPPUNIT_ASSERT_MESSAGE("Wrong reference count, 1 is expected", reinterpret_cast<COMObject*>(r.get())->GetRefCount() == 1); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong reference count, 1 is expected", ULONG(1), reinterpret_cast<COMObject*>(r.get())->GetRefCount()); } void test_address_operator2() { sal::systools::COMReference<IUnknown> r1 = comObjectSource(); sal::systools::COMReference<IUnknown> r2 = r1; - CPPUNIT_ASSERT_MESSAGE("Wrong reference count 2 is expected", reinterpret_cast<COMObject*>(r2.get())->GetRefCount() == 2); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong reference count 2 is expected", ULONG(2), reinterpret_cast<COMObject*>(r2.get())->GetRefCount()); comObjectSource2(reinterpret_cast<LPVOID*>(&r1)); - CPPUNIT_ASSERT_MESSAGE("Wrong reference count 1 is expected", reinterpret_cast<COMObject*>(r1.get())->GetRefCount() == 1); - CPPUNIT_ASSERT_MESSAGE("Wrong reference count 1 is expected", reinterpret_cast<COMObject*>(r2.get())->GetRefCount() == 1); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong reference count 1 is expected", ULONG(1), reinterpret_cast<COMObject*>(r1.get())->GetRefCount()); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong reference count 1 is expected", ULONG(1), reinterpret_cast<COMObject*>(r2.get())->GetRefCount()); } void test_clear() { sal::systools::COMReference<IUnknown> r = comObjectSource(); - CPPUNIT_ASSERT_MESSAGE("Wrong reference count 1 is expected", reinterpret_cast<COMObject*>(r.get())->GetRefCount() == 1); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong reference count 1 is expected", ULONG(1), reinterpret_cast<COMObject*>(r.get())->GetRefCount()); r.clear(); CPPUNIT_ASSERT_MESSAGE("Expect reference to be empty", !r.is()); } @@ -183,7 +183,7 @@ namespace test_comtools { sal::systools::COMReference<IUnknown> r1 = comObjectSource(); sal::systools::COMReference<IUnknown> r2 = r1.QueryInterface<IUnknown>(IID_IUnknown); - CPPUNIT_ASSERT_MESSAGE("Wrong reference count, 2 is expected", reinterpret_cast<COMObject*>(r2.get())->GetRefCount() == 2); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong reference count, 2 is expected", ULONG(2), reinterpret_cast<COMObject*>(r2.get())->GetRefCount()); } catch(const sal::systools::ComError&) { _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
