size_t found = host_token.find(']');
- if(found == std::string::npos)
+ if(found == std::string::npos || found == 0)
{
throw ResourceInitException(m_uri.empty(), m_resourceTypes.empty(),
m_interfaces.empty(), m_clientWrapper.expired(), false, false);
{
size_t found = host_token.find(':');
- if(found == std::string::npos)
+ if(found == std::string::npos || found == 0)
{
throw ResourceInitException(m_uri.empty(), m_resourceTypes.empty(),
m_interfaces.empty(), m_clientWrapper.expired(), false, false);
EXPECT_ANY_THROW(ConstructResourceObject("coap://192.168.1.2", "/resource"));
}
+ TEST(ConstructResourceTest, ConstructResourceObjectInvalidHost)
+ {
+ EXPECT_ANY_THROW(ConstructResourceObject("192.168.1.2:5000", "/resource"));
+ }
+
+ TEST(ConstructResourceTest, ConstructResourceObjectInvalidHost2)
+ {
+ EXPECT_ANY_THROW(ConstructResourceObject("coap://:5000", "/resource"));
+ }
+
TEST(ResourceGetTest, DISABLED_ResourceGetForValidUri)
{
OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");