Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Cameo
cameo
Commits
9fad2883
Commit
9fad2883
authored
Oct 23, 2020
by
legoc
Browse files
(split) Re-added tcp:// in Endpoint
parent
c49ff939
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/Strings.cpp
View file @
9fad2883
...
...
@@ -53,7 +53,12 @@ int Endpoint::getPort() const {
Endpoint
Endpoint
::
parse
(
const
std
::
string
&
str
)
{
vector
<
string
>
tokens
=
split
(
str
,
':'
);
if
(
str
.
substr
(
0
,
6
)
!=
"tcp://"
)
{
throw
new
BadFormatException
(
"Bad format for endpoint "
+
str
);
}
string
substr
=
str
.
substr
(
6
);
vector
<
string
>
tokens
=
split
(
substr
,
':'
);
if
(
tokens
.
size
()
!=
2
)
{
throw
new
BadFormatException
(
"Bad format for endpoint "
+
str
);
...
...
@@ -73,7 +78,7 @@ Endpoint Endpoint::parse(const std::string& str) {
}
std
::
string
Endpoint
::
toString
()
const
{
return
m_address
+
":"
+
to_string
(
m_port
);
return
string
(
"tcp://"
)
+
m_address
+
":"
+
to_string
(
m_port
);
}
}
...
...
tests/TestEndpoint.cpp
View file @
9fad2883
...
...
@@ -9,21 +9,21 @@ int main(int argc, char *argv[]) {
Endpoint
endpoint
(
"gamma75"
,
9999
);
CAMEO_ASSERT_TRUE
(
"gamma75:9999"
==
endpoint
.
toString
());
CAMEO_ASSERT_TRUE
(
"
tcp://
gamma75:9999"
==
endpoint
.
toString
());
endpoint
=
Endpoint
::
parse
(
"gamma75:9999"
);
endpoint
=
Endpoint
::
parse
(
"
tcp://
gamma75:9999"
);
CAMEO_ASSERT_TRUE
(
"gamma75"
==
endpoint
.
getAddress
());
CAMEO_ASSERT_EQUAL
(
9999
,
endpoint
.
getPort
());
endpoint
=
Endpoint
::
parse
(
"175.29.285.15:9999"
);
endpoint
=
Endpoint
::
parse
(
"
tcp://
175.29.285.15:9999"
);
CAMEO_ASSERT_TRUE
(
"175.29.285.15"
==
endpoint
.
getAddress
());
CAMEO_ASSERT_EQUAL
(
9999
,
endpoint
.
getPort
());
bool
error
=
false
;
try
{
Endpoint
::
parse
(
"gamma
:
75:9999"
);
Endpoint
::
parse
(
"
tcp:/
gamma75:9999"
);
}
catch
(...)
{
error
=
true
;
...
...
@@ -33,7 +33,7 @@ int main(int argc, char *argv[]) {
error
=
false
;
try
{
Endpoint
::
parse
(
"gamma75:"
);
Endpoint
::
parse
(
"
tcp://
gamma75:"
);
}
catch
(...)
{
error
=
true
;
...
...
Shervin Nourbakhsh
@nourbakhsh
mentioned in commit
46e44691
·
Apr 23, 2021
mentioned in commit
46e44691
mentioned in commit 46e44691a03808a23a464818487b0dd014a9c57e
Toggle commit 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