The Winamp Remote Control suite
a remote control client and plugin for Winamp 2.x, 5.x
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
NetworkSuite.cpp
Go to the documentation of this file.
1 /*
2  * NetworkSuite.cpp
3  *
4  * Created on: 11 Feb 2012
5  * Author: Patrick
6  */
7 
8 #include "catch.hpp"
9 #include "IPAddressResolver.h"
10 #include "ServerTester.h"
11 #include "ServerEnumerator.h"
12 
16 TEST_CASE("Network/Net/Enumeration", "local Network enumeration")
17 {
19  se.enumerateServers();
20 }
21 
25 TEST_CASE("Network/RPC/Local", "test interface")
26 {
27  ServerTester st;
28  ServerInfo si;
29  st.testServer("127.0.0.1", si);
30  CHECK (si.status == SI_SUCCESS);
31 }
32 
36 TEST_CASE("Network/RPC/Invalid", "test communication with invalid server")
37 {
38  ServerTester st;
39  ServerInfo si;
40  st.testServer("__invalid__", si);
42 }
43 
48 TEST_CASE("Network/IP/Localhost", "tests the IP resolution for localhost")
49 {
50  std::string host = "localhost";
52  CAPTURE(ipr.hostname());
53  CAPTURE(ipr.resolvedName());
54  CHECK("" != ipr.resolvedName());
55 
56  // obtain the local machine name
57  char computerName[MAX_COMPUTERNAME_LENGTH + 1] = "";
58  DWORD nameLen = 15;
59  GetComputerName(computerName, &nameLen);
60  CAPTURE(computerName);
61 
62  CHECK(0 == stricmp(computerName, ipr.resolvedName().c_str()));
63 
64  CHECK(ipr.getAddresses().size());
65  if (ipr.getAddresses().size())
66  CHECK("127.0.0.1" == ipr.getAddresses().at(0));
67 
68 
69 }
70 
71 TEST_CASE("Network/IP/Invalid", "tests the IP resolution for localhost")
72 {
73  std::string host = "__localhost__";
75  CAPTURE(ipr.hostname());
76  CAPTURE(ipr.resolvedName());
77  CHECK("" == ipr.resolvedName());
78 
79  CHECK( (unsigned int) 0 == ipr.getAddresses().size());
80 
81 }
82