Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
core
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
LibreOffice
core
Commits
4d076d4c
Kaydet (Commit)
4d076d4c
authored
Eki 02, 2013
tarafından
Kohei Yoshida
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Write some rudimentary tests for the new shared string pool class.
Change-Id: Ie66de46d69f664839aa0a2d056cd3b8df4d4989b
üst
5d3ea0cd
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
55 additions
and
3 deletions
+55
-3
stringpool.hxx
include/svl/stringpool.hxx
+4
-2
svl.cxx
svl/qa/unit/svl.cxx
+40
-0
stringpool.cxx
svl/source/misc/stringpool.cxx
+11
-1
No files found.
include/svl/stringpool.hxx
Dosyayı görüntüle @
4d076d4c
...
...
@@ -34,11 +34,11 @@ class SVL_DLLPUBLIC StringPool
StrHashType
maStrPool
;
StrHashType
maStrPoolUpper
;
StrIdMapType
maToUpperMap
;
CharClass
*
mpCharClass
;
const
CharClass
*
mpCharClass
;
public
:
StringPool
();
StringPool
(
CharClass
*
pCharClass
);
StringPool
(
const
CharClass
*
pCharClass
);
/**
* Intern a string object into the shared string pool.
...
...
@@ -60,6 +60,8 @@ public:
*/
const
rtl_uString
*
getIdentifier
(
const
OUString
&
rStr
)
const
;
const
rtl_uString
*
getIdentifierIgnoreCase
(
const
OUString
&
rStr
)
const
;
private
:
InsertResultType
findOrInsert
(
StrHashType
&
rPool
,
const
OUString
&
rStr
)
const
;
};
...
...
svl/qa/unit/svl.cxx
Dosyayı görüntüle @
4d076d4c
...
...
@@ -33,6 +33,8 @@
#include "svl/zforlist.hxx"
#include "svl/zformat.hxx"
#include "svl/stringpool.hxx"
#include "unotools/syslocale.hxx"
#define DEBUG_UNIT_TEST 0
...
...
@@ -65,11 +67,13 @@ public:
virtual
void
tearDown
();
void
testNumberFormat
();
void
testStringPool
();
void
testFdo60915
();
void
testI116701
();
CPPUNIT_TEST_SUITE
(
Test
);
CPPUNIT_TEST
(
testNumberFormat
);
CPPUNIT_TEST
(
testStringPool
);
CPPUNIT_TEST
(
testFdo60915
);
CPPUNIT_TEST
(
testI116701
);
CPPUNIT_TEST_SUITE_END
();
...
...
@@ -288,6 +292,42 @@ void Test::testNumberFormat()
}
}
void
Test
::
testStringPool
()
{
SvtSysLocale
aSysLocale
;
svl
::
StringPool
aPool
(
aSysLocale
.
GetCharClassPtr
());
const
rtl_uString
*
p1
=
aPool
.
intern
(
"Andy"
);
const
rtl_uString
*
p2
=
aPool
.
intern
(
"Andy"
);
CPPUNIT_ASSERT_EQUAL
(
p1
,
p2
);
p2
=
aPool
.
intern
(
"Bruce"
);
CPPUNIT_ASSERT_MESSAGE
(
"They must differ."
,
p1
!=
p2
);
OUString
aAndy
(
"Andy"
);
p2
=
aPool
.
getIdentifier
(
aAndy
);
CPPUNIT_ASSERT_EQUAL
(
p1
,
p2
);
// Test case insensitive string ID's.
OUString
aAndyLower
(
"andy"
),
aAndyUpper
(
"ANDY"
);
p1
=
aPool
.
getIdentifier
(
"Andy"
);
CPPUNIT_ASSERT_MESSAGE
(
"This shouldn't be NULL."
,
p1
);
p2
=
aPool
.
intern
(
aAndyLower
);
CPPUNIT_ASSERT_MESSAGE
(
"They must differ."
,
p1
!=
p2
);
p2
=
aPool
.
intern
(
aAndyUpper
);
CPPUNIT_ASSERT_MESSAGE
(
"They must differ."
,
p1
!=
p2
);
p1
=
aPool
.
getIdentifierIgnoreCase
(
"Andy"
);
CPPUNIT_ASSERT_MESSAGE
(
"This shouldn't be NULL."
,
p1
);
p2
=
aPool
.
getIdentifierIgnoreCase
(
"andy"
);
CPPUNIT_ASSERT_MESSAGE
(
"This shouldn't be NULL."
,
p2
);
CPPUNIT_ASSERT_EQUAL
(
p1
,
p2
);
p2
=
aPool
.
getIdentifierIgnoreCase
(
"ANDY"
);
CPPUNIT_ASSERT_MESSAGE
(
"This shouldn't be NULL."
,
p2
);
CPPUNIT_ASSERT_EQUAL
(
p1
,
p2
);
}
void
Test
::
checkPreviewString
(
SvNumberFormatter
&
aFormatter
,
const
OUString
&
sCode
,
double
fPreviewNumber
,
...
...
svl/source/misc/stringpool.cxx
Dosyayı görüntüle @
4d076d4c
...
...
@@ -13,7 +13,7 @@
namespace
svl
{
StringPool
::
StringPool
()
:
mpCharClass
(
NULL
)
{}
StringPool
::
StringPool
(
CharClass
*
pCharClass
)
:
mpCharClass
(
pCharClass
)
{}
StringPool
::
StringPool
(
const
CharClass
*
pCharClass
)
:
mpCharClass
(
pCharClass
)
{}
rtl_uString
*
StringPool
::
intern
(
const
OUString
&
rStr
)
{
...
...
@@ -52,6 +52,16 @@ const rtl_uString* StringPool::getIdentifier( const OUString& rStr ) const
return
(
it
==
maStrPool
.
end
())
?
NULL
:
it
->
pData
;
}
const
rtl_uString
*
StringPool
::
getIdentifierIgnoreCase
(
const
OUString
&
rStr
)
const
{
if
(
!
mpCharClass
)
return
NULL
;
OUString
aUpper
=
mpCharClass
->
uppercase
(
rStr
);
StrHashType
::
iterator
it
=
maStrPoolUpper
.
find
(
aUpper
);
return
(
it
==
maStrPool
.
end
())
?
NULL
:
it
->
pData
;
}
StringPool
::
InsertResultType
StringPool
::
findOrInsert
(
StrHashType
&
rPool
,
const
OUString
&
rStr
)
const
{
StrHashType
::
iterator
it
=
rPool
.
find
(
rStr
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment