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
91ab2b6e
Kaydet (Commit)
91ab2b6e
authored
May 14, 2013
tarafından
Jan Holesovsky
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Improve error messages for the xml-diff based unit tests.
Change-Id: Ided6749ebe4899a6d826d069c38d7b21b467d431
üst
e347af86
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
13 deletions
+33
-13
diff.cxx
test/source/diff/diff.cxx
+33
-13
No files found.
test/source/diff/diff.cxx
Dosyayı görüntüle @
91ab2b6e
...
...
@@ -85,15 +85,23 @@ private:
bool
compareAttributes
(
xmlNodePtr
node1
,
xmlNodePtr
node2
);
bool
compareElements
(
xmlNodePtr
node1
,
xmlNodePtr
node2
);
/// Error message for cppunit that prints out when expected and found are not equal.
void
cppunitAssertEqual
(
const
xmlChar
*
expected
,
const
xmlChar
*
found
);
/// Error message for cppunit that prints out when expected and found are not equal - for doubles.
void
cppunitAssertEqualDouble
(
const
xmlChar
*
node
,
double
expected
,
double
found
,
double
delta
);
ToleranceContainer
toleranceContainer
;
xmlDocPtr
xmlFile1
;
xmlDocPtr
xmlFile2
;
std
::
string
fileName
;
};
XMLDiff
::
XMLDiff
(
const
char
*
pFileName
,
const
char
*
pContent
,
int
size
,
const
char
*
pToleranceFile
)
:
fileName
(
pFileName
)
{
xmlFile1
=
xmlParseFile
(
pFileName
);
xmlFile2
=
xmlParseMemory
(
pContent
,
size
);
...
...
@@ -169,9 +177,7 @@ bool XMLDiff::compare()
#if USE_CPPUNIT
CPPUNIT_ASSERT
(
root1
);
CPPUNIT_ASSERT
(
root2
);
std
::
stringstream
stringStream
(
"Expected: "
);
stringStream
<<
(
char
*
)
root1
->
name
<<
"
\n
Found: "
<<
(
char
*
)
root2
->
name
;
CPPUNIT_ASSERT_MESSAGE
(
stringStream
.
str
(),
xmlStrEqual
(
root1
->
name
,
root2
->
name
));
cppunitAssertEqual
(
root1
->
name
,
root2
->
name
);
#else
if
(
!
root1
||
!
root2
)
return
false
;
...
...
@@ -201,9 +207,7 @@ bool checkForEmptyChildren(xmlNodePtr node)
bool
XMLDiff
::
compareElements
(
xmlNode
*
node1
,
xmlNode
*
node2
)
{
#if USE_CPPUNIT
std
::
stringstream
stringStream
(
"Expected: "
);
stringStream
<<
(
xmlChar
*
)
node1
->
name
<<
"
\n
Found: "
<<
node2
->
name
;
CPPUNIT_ASSERT_MESSAGE
(
stringStream
.
str
(),
xmlStrEqual
(
node1
->
name
,
node2
->
name
));
cppunitAssertEqual
(
node1
->
name
,
node2
->
name
);
#else
if
(
!
xmlStrEqual
(
node1
->
name
,
node2
->
name
))
return
false
;
...
...
@@ -244,6 +248,26 @@ bool XMLDiff::compareElements(xmlNode* node1, xmlNode* node2)
return
true
;
}
void
XMLDiff
::
cppunitAssertEqual
(
const
xmlChar
*
expected
,
const
xmlChar
*
found
)
{
#if USE_CPPUNIT
std
::
stringstream
stringStream
;
stringStream
<<
"Reference: "
<<
fileName
<<
"
\n
- Expected: "
<<
(
const
char
*
)
expected
<<
"
\n
- Found: "
<<
(
const
char
*
)
found
;
CPPUNIT_ASSERT_MESSAGE
(
stringStream
.
str
(),
xmlStrEqual
(
expected
,
found
));
#endif
}
void
XMLDiff
::
cppunitAssertEqualDouble
(
const
xmlChar
*
node
,
double
expected
,
double
found
,
double
delta
)
{
#if USE_CPPUNIT
std
::
stringstream
stringStream
;
stringStream
<<
"Reference: "
<<
fileName
<<
"
\n
- Node: "
<<
(
const
char
*
)
node
;
CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE
(
stringStream
.
str
(),
expected
,
found
,
delta
);
#endif
}
namespace
{
bool
compareValuesWithTolerance
(
double
val1
,
double
val2
,
double
tolerance
,
bool
relative
)
...
...
@@ -267,7 +291,7 @@ bool XMLDiff::compareAttributes(xmlNodePtr node1, xmlNodePtr node2)
for
(
attr1
=
node1
->
properties
,
attr2
=
node2
->
properties
;
attr1
!=
NULL
&&
attr2
!=
NULL
;
attr1
=
attr1
->
next
,
attr2
=
attr2
->
next
)
{
#if USE_CPPUNIT
CPPUNIT_ASSERT
(
xmlStrEqual
(
attr1
->
name
,
attr2
->
name
)
);
cppunitAssertEqual
(
attr1
->
name
,
attr2
->
name
);
#else
if
(
!
xmlStrEqual
(
attr1
->
name
,
attr2
->
name
))
return
false
;
...
...
@@ -308,9 +332,7 @@ bool XMLDiff::compareAttributes(xmlNodePtr node1, xmlNodePtr node2)
else
{
#if USE_CPPUNIT
CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE
(
reinterpret_cast
<
char
const
*
>
(
attr1
->
name
),
dVal1
,
dVal2
,
1e-08
);
cppunitAssertEqualDouble
(
attr1
->
name
,
dVal1
,
dVal2
,
1e-08
);
#else
if
(
dVal1
!=
dVal2
)
return
false
;
...
...
@@ -321,9 +343,7 @@ bool XMLDiff::compareAttributes(xmlNodePtr node1, xmlNodePtr node2)
{
#if USE_CPPUNIT
std
::
stringstream
stringStream
(
"Expected: "
);
stringStream
<<
(
char
*
)
val1
<<
"
\n
Found: "
<<
(
char
*
)
val2
;
CPPUNIT_ASSERT_MESSAGE
(
stringStream
.
str
(),
xmlStrEqual
(
val1
,
val2
));
cppunitAssertEqual
(
val1
,
val2
);
#else
if
(
!
xmlStrEqual
(
val1
,
val2
))
return
false
;
...
...
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