00001 #ifndef TEST_ADDRESSING_HPP_
00002 #define TEST_ADDRESSING_HPP_
00003
00004 #include "addressing.hpp"
00005
00006 namespace ariba {
00007 namespace addressing {
00008 namespace detail {
00009
00010 using namespace ariba::addressing;
00011
00012 void test() {
00013
00014 mac_address mac("01:02:03:04:05:06");
00015 port_address port("12345");
00016 ip_address ipv4("127.0.0.1");
00017 ip_address ipv6("::127.0.0.1");
00018
00019 tcpip_endpoint tcpip;
00020 tcpip = "10.11.12.13:5001";
00021 cout << tcpip.to_string() << endl;
00022 tcpip = "[::10.11.12.13]:5001";
00023 cout << tcpip.to_string() << endl;
00024
00025 address_vf addr_mac = mac;
00026 address_vf addr_port = port;
00027 to_string_vf addr_to_string = ipv4;
00028
00029 cout << addr_to_string->to_string() << endl;
00030 cout << addr_mac->clone()->to_string() << endl;
00031 cout << (*addr_mac == *addr_mac) << endl;
00032
00033 uint8_t bytes[80];
00034
00035 tcpip.to_bytes(bytes);
00036 for (size_t i=0; i<tcpip.to_bytes_size(); i++) printf("%02X",bytes[i]);
00037 printf("\n");
00038 tcpip = "10.11.12.13:5001";
00039 tcpip.assign( bytes, 18 );
00040 cout << tcpip.to_string() << endl;
00041
00042 cout << "Testing endpoint_set: " << endl;
00043 cout << "-> to_string methods:" << endl;
00044 string set_test = "tcp{5001 | 5002};ip{::10.11.12.13 | 127.0.0.1};bluetooth{01:02:03:04:05:06};rfcomm{10 | 11 | 12 | 13};";
00045 endpoint_set set = set_test;
00046 cout << " * This = " << set.to_string() << endl;
00047 cout << " * That = " << set_test << endl;
00048 cout << " * Ok = " << (set.to_string().size() == set_test.size()) << endl;
00049 cout << "-> to_bytes methods:" << endl;
00050 uint8_t* set_bytes = new uint8_t[set.to_bytes_size()];
00051 set.to_bytes(set_bytes);
00052 endpoint_set new_set(set_bytes, set.to_bytes_size());
00053 cout << " * Bin = ";
00054 for (size_t i=0; i<set.to_bytes_size(); i++) printf("%02X",set_bytes[i]);
00055 cout << endl;
00056 cout << " * This = " << set.to_string() << endl;
00057 cout << " * That = " << new_set.to_string() << endl;
00058 cout << " * Ok = " << (set.to_string().size() == new_set.to_string().size()) << endl;
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077 }
00078
00079 }}}
00080
00081 #endif