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
8fd8a887
Kaydet (Commit)
8fd8a887
authored
Şub 17, 2016
tarafından
Eike Rathke
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
wildcard search unit tests, tdf#72196
Change-Id: Ifa23592f5e72438267926acf89c113a69a7f0ca0
üst
f1a4663c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
119 additions
and
2 deletions
+119
-2
test_textsearch.cxx
i18npool/qa/cppunit/test_textsearch.cxx
+119
-2
No files found.
i18npool/qa/cppunit/test_textsearch.cxx
Dosyayı görüntüle @
8fd8a887
...
@@ -21,8 +21,8 @@
...
@@ -21,8 +21,8 @@
#include <cppuhelper/basemutex.hxx>
#include <cppuhelper/basemutex.hxx>
#include <com/sun/star/util/SearchFlags.hpp>
#include <com/sun/star/util/SearchFlags.hpp>
#include <com/sun/star/util/SearchOptions.hpp>
#include <com/sun/star/util/SearchOptions.hpp>
#include <com/sun/star/util/SearchAlgorithms.hpp>
#include <com/sun/star/util/SearchAlgorithms
2
.hpp>
#include <com/sun/star/util/XTextSearch.hpp>
#include <com/sun/star/util/XTextSearch
2
.hpp>
#include <com/sun/star/i18n/Transliteration.hpp>
#include <com/sun/star/i18n/Transliteration.hpp>
#include <unotest/bootstrapfixturebase.hxx>
#include <unotest/bootstrapfixturebase.hxx>
...
@@ -43,13 +43,16 @@ public:
...
@@ -43,13 +43,16 @@ public:
void
testICU
();
void
testICU
();
void
testSearches
();
void
testSearches
();
void
testWildcardSearch
();
CPPUNIT_TEST_SUITE
(
TestTextSearch
);
CPPUNIT_TEST_SUITE
(
TestTextSearch
);
CPPUNIT_TEST
(
testICU
);
CPPUNIT_TEST
(
testICU
);
CPPUNIT_TEST
(
testSearches
);
CPPUNIT_TEST
(
testSearches
);
CPPUNIT_TEST
(
testWildcardSearch
);
CPPUNIT_TEST_SUITE_END
();
CPPUNIT_TEST_SUITE_END
();
private
:
private
:
uno
::
Reference
<
util
::
XTextSearch
>
m_xSearch
;
uno
::
Reference
<
util
::
XTextSearch
>
m_xSearch
;
uno
::
Reference
<
util
::
XTextSearch2
>
m_xSearch2
;
};
};
// Sanity check our ICU first ...
// Sanity check our ICU first ...
...
@@ -135,15 +138,129 @@ void TestTextSearch::testSearches()
...
@@ -135,15 +138,129 @@ void TestTextSearch::testSearches()
CPPUNIT_ASSERT
((
aRes
.
startOffset
[
2
]
==
3
)
&&
(
aRes
.
endOffset
[
2
]
==
5
));
CPPUNIT_ASSERT
((
aRes
.
startOffset
[
2
]
==
3
)
&&
(
aRes
.
endOffset
[
2
]
==
5
));
}
}
void
TestTextSearch
::
testWildcardSearch
()
{
util
::
SearchOptions2
aOptions
;
OUString
aText
;
util
::
SearchResult
aRes
;
aOptions
.
AlgorithmType2
=
util
::
SearchAlgorithms2
::
WILDCARD
;
aOptions
.
transliterateFlags
=
::
css
::
i18n
::
TransliterationModules
::
TransliterationModules_IGNORE_CASE
;
aText
=
"abAca"
;
aOptions
.
searchString
=
"a"
;
m_xSearch2
->
setOptions2
(
aOptions
);
// match first "a", [0,1)
aRes
=
m_xSearch2
->
searchForward
(
aText
,
0
,
aText
.
getLength
());
CPPUNIT_ASSERT
(
aRes
.
subRegExpressions
==
1
);
CPPUNIT_ASSERT
((
aRes
.
startOffset
[
0
]
==
0
)
&&
(
aRes
.
endOffset
[
0
]
==
1
));
// match last "a", (5,4]
aRes
=
m_xSearch2
->
searchBackward
(
aText
,
aText
.
getLength
(),
0
);
CPPUNIT_ASSERT
(
aRes
.
subRegExpressions
==
1
);
CPPUNIT_ASSERT
((
aRes
.
startOffset
[
0
]
==
5
)
&&
(
aRes
.
endOffset
[
0
]
==
4
));
aOptions
.
searchString
=
"a?"
;
m_xSearch2
->
setOptions2
(
aOptions
);
// match "ab", [0,2)
aRes
=
m_xSearch2
->
searchForward
(
aText
,
0
,
aText
.
getLength
());
CPPUNIT_ASSERT
(
aRes
.
subRegExpressions
==
1
);
CPPUNIT_ASSERT
((
aRes
.
startOffset
[
0
]
==
0
)
&&
(
aRes
.
endOffset
[
0
]
==
2
));
// match "ac", (4,2]
aRes
=
m_xSearch2
->
searchBackward
(
aText
,
aText
.
getLength
(),
0
);
CPPUNIT_ASSERT
(
aRes
.
subRegExpressions
==
1
);
CPPUNIT_ASSERT
((
aRes
.
startOffset
[
0
]
==
4
)
&&
(
aRes
.
endOffset
[
0
]
==
2
));
aOptions
.
searchString
=
"a*c"
;
m_xSearch2
->
setOptions2
(
aOptions
);
// match "abac", [0,4) XXX NOTE: first match forward
aRes
=
m_xSearch2
->
searchForward
(
aText
,
0
,
aText
.
getLength
());
CPPUNIT_ASSERT
(
aRes
.
subRegExpressions
==
1
);
CPPUNIT_ASSERT
((
aRes
.
startOffset
[
0
]
==
0
)
&&
(
aRes
.
endOffset
[
0
]
==
4
));
// match "ac", (4,2] XXX NOTE: first match backward, not greedy
aRes
=
m_xSearch2
->
searchBackward
(
aText
,
aText
.
getLength
(),
0
);
CPPUNIT_ASSERT
(
aRes
.
subRegExpressions
==
1
);
CPPUNIT_ASSERT
((
aRes
.
startOffset
[
0
]
==
4
)
&&
(
aRes
.
endOffset
[
0
]
==
2
));
aOptions
.
searchString
=
"b*a"
;
m_xSearch2
->
setOptions2
(
aOptions
);
// match "ba", [1,3) XXX NOTE: first match forward, not greedy
aRes
=
m_xSearch2
->
searchForward
(
aText
,
0
,
aText
.
getLength
());
CPPUNIT_ASSERT
(
aRes
.
subRegExpressions
==
1
);
CPPUNIT_ASSERT
((
aRes
.
startOffset
[
0
]
==
1
)
&&
(
aRes
.
endOffset
[
0
]
==
3
));
// match "baca", (5,1] XXX NOTE: first match backward
aRes
=
m_xSearch2
->
searchBackward
(
aText
,
aText
.
getLength
(),
0
);
CPPUNIT_ASSERT
(
aRes
.
subRegExpressions
==
1
);
CPPUNIT_ASSERT
((
aRes
.
startOffset
[
0
]
==
5
)
&&
(
aRes
.
endOffset
[
0
]
==
1
));
aText
=
"ab?ca"
;
aOptions
.
searchString
=
"?~??"
;
m_xSearch2
->
setOptions2
(
aOptions
);
// match "b?c", [1,4)
aRes
=
m_xSearch2
->
searchForward
(
aText
,
0
,
aText
.
getLength
());
CPPUNIT_ASSERT
(
aRes
.
subRegExpressions
==
1
);
CPPUNIT_ASSERT
((
aRes
.
startOffset
[
0
]
==
1
)
&&
(
aRes
.
endOffset
[
0
]
==
4
));
// match "b?c", (4,1]
aRes
=
m_xSearch2
->
searchBackward
(
aText
,
aText
.
getLength
(),
0
);
CPPUNIT_ASSERT
(
aRes
.
subRegExpressions
==
1
);
CPPUNIT_ASSERT
((
aRes
.
startOffset
[
0
]
==
4
)
&&
(
aRes
.
endOffset
[
0
]
==
1
));
aText
=
"ab*ca"
;
aOptions
.
searchString
=
"?~*?"
;
m_xSearch2
->
setOptions2
(
aOptions
);
// match "b?c", [1,4)
aRes
=
m_xSearch2
->
searchForward
(
aText
,
0
,
aText
.
getLength
());
CPPUNIT_ASSERT
(
aRes
.
subRegExpressions
==
1
);
CPPUNIT_ASSERT
((
aRes
.
startOffset
[
0
]
==
1
)
&&
(
aRes
.
endOffset
[
0
]
==
4
));
// match "b?c", (4,1]
aRes
=
m_xSearch2
->
searchBackward
(
aText
,
aText
.
getLength
(),
0
);
CPPUNIT_ASSERT
(
aRes
.
subRegExpressions
==
1
);
CPPUNIT_ASSERT
((
aRes
.
startOffset
[
0
]
==
4
)
&&
(
aRes
.
endOffset
[
0
]
==
1
));
aOptions
.
searchString
=
"ca?"
;
m_xSearch2
->
setOptions2
(
aOptions
);
// no match
aRes
=
m_xSearch2
->
searchForward
(
aText
,
0
,
aText
.
getLength
());
CPPUNIT_ASSERT
(
aRes
.
subRegExpressions
==
0
);
// no match
aRes
=
m_xSearch2
->
searchBackward
(
aText
,
aText
.
getLength
(),
0
);
CPPUNIT_ASSERT
(
aRes
.
subRegExpressions
==
0
);
aOptions
.
searchString
=
"ca*"
;
m_xSearch2
->
setOptions2
(
aOptions
);
// match "ca", [3,5)
aRes
=
m_xSearch2
->
searchForward
(
aText
,
0
,
aText
.
getLength
());
CPPUNIT_ASSERT
(
aRes
.
subRegExpressions
==
1
);
CPPUNIT_ASSERT
((
aRes
.
startOffset
[
0
]
==
3
)
&&
(
aRes
.
endOffset
[
0
]
==
5
));
// match "ca", (5,3]
aRes
=
m_xSearch2
->
searchBackward
(
aText
,
aText
.
getLength
(),
0
);
CPPUNIT_ASSERT
(
aRes
.
subRegExpressions
==
1
);
CPPUNIT_ASSERT
((
aRes
.
startOffset
[
0
]
==
5
)
&&
(
aRes
.
endOffset
[
0
]
==
3
));
aOptions
.
searchString
=
"*ca*"
;
m_xSearch2
->
setOptions2
(
aOptions
);
// match "abaca", [0,5)
aRes
=
m_xSearch2
->
searchForward
(
aText
,
0
,
aText
.
getLength
());
CPPUNIT_ASSERT
(
aRes
.
subRegExpressions
==
1
);
CPPUNIT_ASSERT
((
aRes
.
startOffset
[
0
]
==
0
)
&&
(
aRes
.
endOffset
[
0
]
==
5
));
// match "abaca", (5,0]
aRes
=
m_xSearch2
->
searchBackward
(
aText
,
aText
.
getLength
(),
0
);
CPPUNIT_ASSERT
(
aRes
.
subRegExpressions
==
1
);
CPPUNIT_ASSERT
((
aRes
.
startOffset
[
0
]
==
5
)
&&
(
aRes
.
endOffset
[
0
]
==
0
));
}
void
TestTextSearch
::
setUp
()
void
TestTextSearch
::
setUp
()
{
{
BootstrapFixtureBase
::
setUp
();
BootstrapFixtureBase
::
setUp
();
m_xSearch
.
set
(
m_xSFactory
->
createInstance
(
"com.sun.star.util.TextSearch"
),
uno
::
UNO_QUERY_THROW
);
m_xSearch
.
set
(
m_xSFactory
->
createInstance
(
"com.sun.star.util.TextSearch"
),
uno
::
UNO_QUERY_THROW
);
m_xSearch2
.
set
(
m_xSFactory
->
createInstance
(
"com.sun.star.util.TextSearch2"
),
uno
::
UNO_QUERY_THROW
);
}
}
void
TestTextSearch
::
tearDown
()
void
TestTextSearch
::
tearDown
()
{
{
m_xSearch
.
clear
();
m_xSearch
.
clear
();
m_xSearch2
.
clear
();
BootstrapFixtureBase
::
tearDown
();
BootstrapFixtureBase
::
tearDown
();
}
}
...
...
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