Commit 9fad2883 authored by legoc's avatar legoc
Browse files

(split) Re-added tcp:// in Endpoint

parent c49ff939
......@@ -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);
}
}
......
......@@ -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;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment