diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2024-02-22 12:59:26 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2024-03-08 07:06:13 +0100 |
commit | 7840effb1d5efd1fd7f6798c7c504b05292a7793 (patch) | |
tree | 845e03d4c2cfad1d5bbcaaf9dc3ec1aeece7c864 /test | |
parent | bf35f2b36fc00f9b37397422b2ee425c6a697540 (diff) |
use more string_view
found by tweaking the stringview loplugin
Change-Id: I92203ba99642bef7951ffa146184c5562cb31d09
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163744
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'test')
-rw-r--r-- | test/source/screenshot_test.cxx | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/test/source/screenshot_test.cxx b/test/source/screenshot_test.cxx index b4c188fdbc34..9b85338303a0 100644 --- a/test/source/screenshot_test.cxx +++ b/test/source/screenshot_test.cxx @@ -24,15 +24,23 @@ namespace { - void splitHelpId( const OUString& rHelpId, OUString& rDirname, OUString &rBasename ) + void splitHelpId( std::u16string_view rHelpId, std::u16string_view& rDirname, std::u16string_view& rBasename ) { - sal_Int32 nIndex = rHelpId.lastIndexOf( '/' ); + size_t nIndex = rHelpId.rfind( '/' ); - if( nIndex > 0 ) - rDirname = rHelpId.subView( 0, nIndex ); + if( nIndex != 0 && nIndex != std::u16string_view::npos) + rDirname = rHelpId.substr( 0, nIndex ); - if( rHelpId.getLength() > nIndex+1 ) - rBasename = rHelpId.subView( nIndex+1 ); + if (nIndex == std::u16string_view::npos) + { + if( rHelpId.size() > 0 ) + rBasename = rHelpId; + } + else + { + if( rHelpId.size() > nIndex+1 ) + rBasename = rHelpId.substr( nIndex+1 ); + } } } @@ -71,11 +79,11 @@ void ScreenshotTest::setUp() } } -void ScreenshotTest::implSaveScreenshot(const BitmapEx& rScreenshot, const OUString& rScreenshotId) +void ScreenshotTest::implSaveScreenshot(const BitmapEx& rScreenshot, std::u16string_view rScreenshotId) { - OUString aDirname, aBasename; - splitHelpId(rScreenshotId, aDirname, aBasename); - aDirname = g_aScreenshotDirectory + "/" + aDirname + + std::u16string_view aSplitDirname, aBasename; + splitHelpId(rScreenshotId, aSplitDirname, aBasename); + OUString aDirname = g_aScreenshotDirectory + "/" + aSplitDirname + ( (maCurrentLanguage == "en-US") ? OUString() : "/" + maCurrentLanguage ); auto const dirUrl = m_directories.getURLFromWorkdir(aDirname); |