TestEndpoint.cpp 1.13 KB
Newer Older
legoc's avatar
legoc committed
1
2
3
4
5
6
7
8
9
10
11
#include "Test.h"
#include "../include/Strings.h"
#include <iostream>

using namespace std;
using namespace cameo;

int main(int argc, char *argv[]) {

	Endpoint endpoint("gamma75", 9999);

legoc's avatar
legoc committed
12
	CAMEO_ASSERT_TRUE("tcp://gamma75:9999" == endpoint.toString());
legoc's avatar
legoc committed
13

legoc's avatar
legoc committed
14
	endpoint = Endpoint::parse("tcp://gamma75:9999");
legoc's avatar
legoc committed
15

16
17
18
19
20
21
22
	CAMEO_ASSERT_TRUE("tcp" == endpoint.getProtocol());
	CAMEO_ASSERT_TRUE("gamma75" == endpoint.getAddress());
	CAMEO_ASSERT_EQUAL(9999, endpoint.getPort());

	endpoint = Endpoint::parse("ws://gamma75:9999");

	CAMEO_ASSERT_TRUE("ws" == endpoint.getProtocol());
legoc's avatar
legoc committed
23
24
25
	CAMEO_ASSERT_TRUE("gamma75" == endpoint.getAddress());
	CAMEO_ASSERT_EQUAL(9999, endpoint.getPort());

legoc's avatar
legoc committed
26
	endpoint = Endpoint::parse("tcp://175.29.285.15:9999");
legoc's avatar
legoc committed
27

28
	CAMEO_ASSERT_TRUE("tcp" == endpoint.getProtocol());
legoc's avatar
legoc committed
29
30
31
32
33
	CAMEO_ASSERT_TRUE("175.29.285.15" == endpoint.getAddress());
	CAMEO_ASSERT_EQUAL(9999, endpoint.getPort());

	bool error = false;
	try {
34
		Endpoint::parse("gamma75:9999");
legoc's avatar
legoc committed
35
36
37
38
39
40
41
42
43
	}
	catch (...) {
		error = true;
	}

	CAMEO_ASSERT_TRUE(error);

	error = false;
	try {
legoc's avatar
legoc committed
44
		Endpoint::parse("tcp://gamma75:");
legoc's avatar
legoc committed
45
46
47
48
49
50
51
52
53
	}
	catch (...) {
		error = true;
	}

	CAMEO_ASSERT_TRUE(error);

	return 0;
}