TestEndpoint.cpp 825 Bytes
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);

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

14
	endpoint = Endpoint::parse("gamma75:9999");
legoc's avatar
legoc committed
15
16
17
18

	CAMEO_ASSERT_TRUE("gamma75" == endpoint.getAddress());
	CAMEO_ASSERT_EQUAL(9999, endpoint.getPort());

19
	endpoint = Endpoint::parse("175.29.285.15:9999");
legoc's avatar
legoc committed
20
21
22
23
24
25

	CAMEO_ASSERT_TRUE("175.29.285.15" == endpoint.getAddress());
	CAMEO_ASSERT_EQUAL(9999, endpoint.getPort());

	bool error = false;
	try {
26
		Endpoint::parse("gamma:75:9999");
legoc's avatar
legoc committed
27
28
29
30
31
32
33
34
35
	}
	catch (...) {
		error = true;
	}

	CAMEO_ASSERT_TRUE(error);

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

	CAMEO_ASSERT_TRUE(error);

	return 0;
}