OSC bind address
This commit is contained in:
@@ -74,6 +74,11 @@ struct OscServerTestAccess
|
||||
return server.DispatchMessage(message, error);
|
||||
}
|
||||
|
||||
static bool TryParseBindAddress(const std::string& bindAddress, in_addr& address, std::string& error)
|
||||
{
|
||||
return OscServer::TryParseBindAddress(bindAddress, address, error);
|
||||
}
|
||||
|
||||
static void SetUpdateParameterCallback(
|
||||
OscServer& server,
|
||||
const std::function<bool(const std::string&, const std::string&, const std::string&, std::string&)>& callback)
|
||||
@@ -191,6 +196,23 @@ void TestRejectsUnsupportedAddress()
|
||||
Expect(!called, "unsupported OSC namespace does not invoke callback");
|
||||
Expect(!error.empty(), "unsupported OSC address reports an error");
|
||||
}
|
||||
|
||||
void TestParsesOscBindAddress()
|
||||
{
|
||||
in_addr loopback = {};
|
||||
std::string error;
|
||||
Expect(OscServerTestAccess::TryParseBindAddress("127.0.0.1", loopback, error), "loopback OSC bind address parses");
|
||||
Expect(loopback.S_un.S_addr != 0, "loopback OSC bind address produces a socket address");
|
||||
|
||||
in_addr wildcard = {};
|
||||
error.clear();
|
||||
Expect(OscServerTestAccess::TryParseBindAddress("0.0.0.0", wildcard, error), "wildcard OSC bind address parses");
|
||||
|
||||
in_addr invalid = {};
|
||||
error.clear();
|
||||
Expect(!OscServerTestAccess::TryParseBindAddress("localhost", invalid, error), "hostname OSC bind address is rejected");
|
||||
Expect(!error.empty(), "invalid OSC bind address reports an error");
|
||||
}
|
||||
}
|
||||
|
||||
int main()
|
||||
@@ -201,6 +223,7 @@ int main()
|
||||
TestDecodeIntStringAndBoolMessages();
|
||||
TestDispatchValidAddress();
|
||||
TestRejectsUnsupportedAddress();
|
||||
TestParsesOscBindAddress();
|
||||
|
||||
if (gFailures != 0)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user