Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
savoirfairelinux
jami-daemon
Commits
35360c5b
Commit
35360c5b
authored
Sep 13, 2010
by
Alexandre Savard
Browse files
[#4056] Fix unit test for instant message parsing
parent
d388a2fa
Changes
3
Hide whitespace changes
Inline
Side-by-side
sflphone-common/src/sip/im/InstantMessaging.cpp
View file @
35360c5b
...
...
@@ -325,7 +325,7 @@ std::string InstantMessaging::findTextUriList (std::string& text)
throw
InstantMessageException
(
"Could not find Content-Disposition tag while parsing sip message for recipient-list"
);
// xml content start after content disposition tag (plus \n\n)
begin
=
pos
+
cdispo
.
size
()
+
2
;
begin
=
pos
+
cdispo
.
size
();
// find final boundary
if
(
(
end
=
text
.
find
(
boundary
,
begin
))
==
std
::
string
::
npos
)
...
...
@@ -348,13 +348,13 @@ std::string InstantMessaging::findTextMessage (std::string& text)
throw
InstantMessageException
(
"Could not find Content-Type tag while parsing sip message for text"
);
// plain text content start after content type tag (plus \n\n)
begin
=
pos
+
ctype
.
size
()
+
2
;
begin
=
pos
+
ctype
.
size
();
// retrive end of the text content
if
(
(
end
=
text
.
find
(
boundary
,
begin
))
==
std
::
string
::
npos
)
throw
InstantMessageException
(
"Could not find end of text
\"
boundary
\"
while parsing sip message for text"
);
return
text
.
substr
(
begin
,
end
-
begin
-
1
);
return
text
.
substr
(
begin
,
end
-
begin
);
}
...
...
sflphone-common/src/sip/im/InstantMessaging.h
View file @
35360c5b
...
...
@@ -40,7 +40,7 @@ class InstantMessageException : public std::exception
virtual
~
InstantMessageException
()
throw
()
{}
virtual
const
char
*
what
()
const
throw
()
{
std
::
string
expt
(
"
YamlParser
Exception occured: "
);
std
::
string
expt
(
"
InstantMessage
Exception occured: "
);
expt
.
append
(
errstr
);
return
expt
.
c_str
();
...
...
sflphone-common/test/instantmessagingtest.cpp
View file @
35360c5b
...
...
@@ -266,11 +266,11 @@ void InstantMessagingTest::testXmlUriListParsing ()
void
InstantMessagingTest
::
testGetTextArea
()
{
std
::
string
formatedText
=
"--boundary
\n
Content-Type: text/plain
\n\n
"
;
std
::
string
formatedText
=
"--boundary Content-Type: text/plain"
;
formatedText
.
append
(
"Here is the text area"
);
formatedText
.
append
(
"
\n
--boundary
\n
Content-Type: application/resource-lists+xml
\n
"
);
formatedText
.
append
(
"Content-Disposition: recipient-list
\n\n
"
);
formatedText
.
append
(
"--boundary
Content-Type: application/resource-lists+xml"
);
formatedText
.
append
(
"Content-Disposition: recipient-list"
);
formatedText
.
append
(
"<?xml version=
\"
1.0
\"
encoding=
\"
UTF-8
\"
?>"
);
formatedText
.
append
(
"<resource-lists xmlns=
\"
urn:ietf:params:xml:ns:resource-lists
\"
xmlns:cp=
\"
urn:ietf:params:xml:ns:copycontrol
\"
>"
);
formatedText
.
append
(
"<list>"
);
...
...
@@ -282,19 +282,19 @@ void InstantMessagingTest::testGetTextArea ()
std
::
string
message
=
_im
->
findTextMessage
(
formatedText
);
CPPUNIT_ASSERT
(
message
==
"Here is the text area"
)
;
std
::
cout
<<
"message "
<<
message
<<
std
::
endl
;
std
::
cout
<<
"message: "
<<
message
<<
std
::
endl
;
CPPUNIT_ASSERT
(
message
==
"Here is the text area"
)
;
}
void
InstantMessagingTest
::
testGetUriListArea
()
{
std
::
string
formatedText
=
"--boundary
\n
Content-Type: text/plain
\n\n
"
;
std
::
string
formatedText
=
"--boundary Content-Type: text/plain"
;
formatedText
.
append
(
"Here is the text area"
);
formatedText
.
append
(
"
\n
--boundary
\n
Content-Type: application/resource-lists+xml
\n
"
);
formatedText
.
append
(
"Content-Disposition: recipient-list
\n\n
"
);
formatedText
.
append
(
"--boundary
Content-Type: application/resource-lists+xml"
);
formatedText
.
append
(
"Content-Disposition: recipient-list"
);
formatedText
.
append
(
"<?xml version=
\"
1.0
\"
encoding=
\"
UTF-8
\"
?>"
);
formatedText
.
append
(
"<resource-lists xmlns=
\"
urn:ietf:params:xml:ns:resource-lists
\"
xmlns:cp=
\"
urn:ietf:params:xml:ns:copycontrol
\"
>"
);
formatedText
.
append
(
"<list>"
);
...
...
@@ -334,11 +334,11 @@ void InstantMessagingTest::testIllFormatedMessage ()
bool
exceptionCaught
=
false
;
// SHOULD BE: Content-Type: text/plain
std
::
string
formatedText
=
"--boundary
\n
Content-Ty
\n\n
"
;
std
::
string
formatedText
=
"--boundary Content-Ty"
;
formatedText
.
append
(
"Here is the text area"
);
formatedText
.
append
(
"
\n
--boundary
\n
Content-Type: application/resource-lists+xml
\n
"
);
formatedText
.
append
(
"Content-Disposition: recipient-list
\n\n
"
);
formatedText
.
append
(
"--boundary
Content-Type: application/resource-lists+xml"
);
formatedText
.
append
(
"Content-Disposition: recipient-list"
);
formatedText
.
append
(
"<?xml version=
\"
1.0
\"
encoding=
\"
UTF-8
\"
?>"
);
formatedText
.
append
(
"<resource-lists xmlns=
\"
urn:ietf:params:xml:ns:resource-lists
\"
xmlns:cp=
\"
urn:ietf:params:xml:ns:copycontrol
\"
>"
);
formatedText
.
append
(
"<list>"
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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