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
456853e9
Kaydet (Commit)
456853e9
authored
Ock 14, 2012
tarafından
Caolán McNamara
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
document with unit test rather odd embedded null handling
üst
a8742cec
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
67 additions
and
0 deletions
+67
-0
test_stream.cxx
tools/qa/cppunit/test_stream.cxx
+67
-0
No files found.
tools/qa/cppunit/test_stream.cxx
Dosyayı görüntüle @
456853e9
...
...
@@ -48,12 +48,14 @@ namespace
void
test_fastostring
();
void
test_read_cstring
();
void
test_read_pstring
();
void
test_readline
();
CPPUNIT_TEST_SUITE
(
Test
);
CPPUNIT_TEST
(
test_stdstream
);
CPPUNIT_TEST
(
test_fastostring
);
CPPUNIT_TEST
(
test_read_cstring
);
CPPUNIT_TEST
(
test_read_pstring
);
CPPUNIT_TEST
(
test_readline
);
CPPUNIT_TEST_SUITE_END
();
};
...
...
@@ -210,6 +212,71 @@ namespace
CPPUNIT_ASSERT
(
!
aMemStream
.
eof
());
}
void
Test
::
test_readline
()
{
char
foo
[]
=
"foo
\n
bar
\n\n
"
;
SvMemoryStream
aMemStream
(
RTL_CONSTASCII_STRINGPARAM
(
foo
),
STREAM_READ
);
rtl
::
OString
aFoo
;
sal_Bool
bRet
;
bRet
=
aMemStream
.
ReadLine
(
aFoo
);
CPPUNIT_ASSERT
(
bRet
);
CPPUNIT_ASSERT
(
aFoo
.
equalsL
(
RTL_CONSTASCII_STRINGPARAM
(
"foo"
)));
CPPUNIT_ASSERT
(
aMemStream
.
good
());
bRet
=
aMemStream
.
ReadLine
(
aFoo
);
CPPUNIT_ASSERT
(
bRet
);
CPPUNIT_ASSERT
(
aFoo
.
equalsL
(
RTL_CONSTASCII_STRINGPARAM
(
"bar"
)));
CPPUNIT_ASSERT
(
aMemStream
.
good
());
bRet
=
aMemStream
.
ReadLine
(
aFoo
);
CPPUNIT_ASSERT
(
bRet
);
CPPUNIT_ASSERT
(
aFoo
.
isEmpty
());
CPPUNIT_ASSERT
(
aMemStream
.
good
());
bRet
=
aMemStream
.
ReadLine
(
aFoo
);
CPPUNIT_ASSERT
(
!
bRet
);
CPPUNIT_ASSERT
(
aFoo
.
isEmpty
());
CPPUNIT_ASSERT
(
aMemStream
.
eof
());
foo
[
3
]
=
0
;
//test reading embedded nulls
aMemStream
.
Seek
(
0
);
bRet
=
aMemStream
.
ReadLine
(
aFoo
);
CPPUNIT_ASSERT
(
bRet
);
//This is the weird current behavior where an embedded null is read but
//discarded
CPPUNIT_ASSERT
(
aFoo
.
equalsL
(
RTL_CONSTASCII_STRINGPARAM
(
"foobar"
)));
CPPUNIT_ASSERT
(
aMemStream
.
good
());
std
::
string
sStr
(
RTL_CONSTASCII_STRINGPARAM
(
foo
));
std
::
istringstream
iss
(
sStr
,
std
::
istringstream
::
in
);
std
::
getline
(
iss
,
sStr
,
'\n'
);
//embedded null read as expected
CPPUNIT_ASSERT
(
sStr
.
size
()
==
7
&&
sStr
[
3
]
==
0
);
CPPUNIT_ASSERT
(
iss
.
good
());
bRet
=
aMemStream
.
ReadLine
(
aFoo
);
CPPUNIT_ASSERT
(
bRet
);
CPPUNIT_ASSERT
(
aFoo
.
isEmpty
());
CPPUNIT_ASSERT
(
aMemStream
.
good
());
std
::
getline
(
iss
,
sStr
,
'\n'
);
CPPUNIT_ASSERT
(
sStr
.
empty
());
CPPUNIT_ASSERT
(
iss
.
good
());
bRet
=
aMemStream
.
ReadLine
(
aFoo
);
CPPUNIT_ASSERT
(
!
bRet
);
CPPUNIT_ASSERT
(
aFoo
.
isEmpty
());
CPPUNIT_ASSERT
(
aMemStream
.
eof
()
&&
!
aMemStream
.
bad
());
std
::
getline
(
iss
,
sStr
,
'\n'
);
CPPUNIT_ASSERT
(
sStr
.
empty
());
CPPUNIT_ASSERT
(
iss
.
eof
()
&&
!
iss
.
bad
());
}
CPPUNIT_TEST_SUITE_REGISTRATION
(
Test
);
}
...
...
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