diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-04-12 15:08:04 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-04-16 08:21:46 +0200 |
commit | 4db9b09cf035e2c9efe44e64c00999be08ccab01 (patch) | |
tree | 8b1ca47e69b48d32de6f18b61ffba1c059d1f39d /sal | |
parent | d911b3d37d13e84e0c6cb8eb990e58a0939a6f6a (diff) |
loplugin:useuniqueptr in sal/qa/
Change-Id: I20b5cfe2fd95da3f37a6812af5683bcc4d918b06
Reviewed-on: https://gerrit.libreoffice.org/52882
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sal')
-rw-r--r-- | sal/qa/osl/condition/osl_Condition.cxx | 14 | ||||
-rw-r--r-- | sal/qa/osl/file/osl_File.cxx | 36 |
2 files changed, 23 insertions, 27 deletions
diff --git a/sal/qa/osl/condition/osl_Condition.cxx b/sal/qa/osl/condition/osl_Condition.cxx index b1203e9787d7..cac87532b8d8 100644 --- a/sal/qa/osl/condition/osl_Condition.cxx +++ b/sal/qa/osl/condition/osl_Condition.cxx @@ -196,18 +196,18 @@ namespace osl_Condition { public: bool bRes, bRes1, bRes2; - TimeValue *tv1; + std::unique_ptr<TimeValue> tv1; void setUp() override { - tv1 = new TimeValue; + tv1.reset(new TimeValue); tv1->Seconds = 1; tv1->Nanosec = 0; } void tearDown() override { - delete tv1; + tv1.reset(); } void wait_testAllCombos( ) @@ -219,9 +219,9 @@ namespace osl_Condition cond1.set(); cond2.set(); - osl::Condition::Result r1=cond1.wait(tv1); + osl::Condition::Result r1=cond1.wait(tv1.get()); osl::Condition::Result r2=cond2.wait(); - osl::Condition::Result r3=cond3.wait(tv1); + osl::Condition::Result r3=cond3.wait(tv1.get()); CPPUNIT_ASSERT_EQUAL_MESSAGE( "#test comment#: test three types of wait.", ::osl::Condition::result_ok, r1 ); @@ -238,10 +238,10 @@ namespace osl_Condition aCond.reset(); bRes = aCond.check(); - wRes = aCond.wait(tv1); + wRes = aCond.wait(tv1.get()); aCond.set(); - wRes1 = aCond.wait(tv1); + wRes1 = aCond.wait(tv1.get()); bRes1 = aCond.check(); CPPUNIT_ASSERT_MESSAGE("#test comment#: wait a condition after set/reset.", diff --git a/sal/qa/osl/file/osl_File.cxx b/sal/qa/osl/file/osl_File.cxx index 8a57c2471df7..e853fb135cc5 100644 --- a/sal/qa/osl/file/osl_File.cxx +++ b/sal/qa/osl/file/osl_File.cxx @@ -1210,38 +1210,35 @@ namespace osl_FileBase osl::FileBase::RC nError1, nError2; bool bOK; - oslFileHandle *pHandle; - OUString *pUStr_DirURL; - OUString *pUStr_FileURL; + std::unique_ptr<oslFileHandle> pHandle; + std::unique_ptr<OUString> pUStr_DirURL; + std::unique_ptr<OUString> pUStr_FileURL; public: createTempFile() : nError1(osl::FileBase::E_None) , nError2(osl::FileBase::E_None) , bOK(false) - , pHandle(nullptr) - , pUStr_DirURL(nullptr) - , pUStr_FileURL(nullptr) { } void setUp() override { - pHandle = new oslFileHandle(); - pUStr_DirURL = new OUString(aUserDirectoryURL); - pUStr_FileURL = new OUString(); + pHandle.reset(new oslFileHandle()); + pUStr_DirURL.reset(new OUString(aUserDirectoryURL)); + pUStr_FileURL.reset(new OUString()); } void tearDown() override { - delete pUStr_DirURL; - delete pUStr_FileURL; - delete pHandle; + pUStr_DirURL.reset(); + pUStr_FileURL.reset(); + pHandle.reset(); } void createTempFile_001() { - nError1 = osl::FileBase::createTempFile(pUStr_DirURL, pHandle, pUStr_FileURL); + nError1 = osl::FileBase::createTempFile(pUStr_DirURL.get(), pHandle.get(), pUStr_FileURL.get()); File testFile(*pUStr_FileURL); nError2 = testFile.open(osl_File_OpenFlag_Create); @@ -1262,7 +1259,7 @@ namespace osl_FileBase void createTempFile_002() { bOK = false; - nError1 = osl::FileBase::createTempFile(pUStr_DirURL, pHandle, pUStr_FileURL); + nError1 = osl::FileBase::createTempFile(pUStr_DirURL.get(), pHandle.get(), pUStr_FileURL.get()); File testFile(*pUStr_FileURL); nError2 = testFile.open(osl_File_OpenFlag_Create); @@ -1287,7 +1284,7 @@ namespace osl_FileBase void createTempFile_003() { - nError1 = osl::FileBase::createTempFile(pUStr_DirURL, pHandle, nullptr); + nError1 = osl::FileBase::createTempFile(pUStr_DirURL.get(), pHandle.get(), nullptr); // the temp file will be removed when return from createTempFile bOK = (pHandle != nullptr && nError1 == osl::FileBase::E_None); if (bOK) @@ -1301,7 +1298,7 @@ namespace osl_FileBase void createTempFile_004() { - nError1 = osl::FileBase::createTempFile(pUStr_DirURL, nullptr, pUStr_FileURL); + nError1 = osl::FileBase::createTempFile(pUStr_DirURL.get(), nullptr, pUStr_FileURL.get()); bOK = (pUStr_FileURL != nullptr); CPPUNIT_ASSERT(bOK); File testFile(*pUStr_FileURL); @@ -1403,12 +1400,11 @@ namespace osl_FileStatus class isValid : public CppUnit::TestFixture { private: - Directory *pDir; + std::unique_ptr<Directory> pDir; DirectoryItem rItem_file, rItem_link; public: isValid() - : pDir(nullptr) { } @@ -1418,7 +1414,7 @@ namespace osl_FileStatus createTestDirectory(aTmpName3); createTestFile(aTmpName4); - pDir = new Directory(aTmpName3); + pDir.reset(new Directory(aTmpName3)); osl::FileBase::RC nError1 = pDir->open(); CPPUNIT_ASSERT_EQUAL(nError1, osl::FileBase::E_None); nError1 = pDir->getNextItem(rItem_file, 1); @@ -1428,7 +1424,7 @@ namespace osl_FileStatus void tearDown() override { osl::FileBase::RC nError1 = pDir->close(); - delete pDir; + pDir.reset(); CPPUNIT_ASSERT_EQUAL_MESSAGE(errorToStr(nError1).getStr(), nError1, osl::FileBase::E_None); // remove the tempfile in $TEMP/tmpdir/tmpname. |