test_uri.cpp
Go to the documentation of this file.
1 
11 #include <opc/common/uri_facade.h>
12 
13 #include <gtest/gtest.h>
14 
15 TEST(Uri, CanParseFullURI)
16 {
17  Common::Uri uri("http://host:8080");
18  ASSERT_EQ(uri.Scheme(), "http");
19  ASSERT_EQ(uri.Host(), "host");
20  ASSERT_EQ(uri.Port(), 8080u);
21 }
22 
23 TEST(Uri, CanParseFullURIWithUserAndPassword)
24 {
25  Common::Uri uri("http://user:password@host:8080");
26  ASSERT_EQ(uri.Scheme(), "http");
27  ASSERT_EQ(uri.User(), "user");
28  ASSERT_EQ(uri.Password(), "password");
29  ASSERT_EQ(uri.Host(), "host");
30  ASSERT_EQ(uri.Port(), 8080u);
31 }
32 
33 TEST(Uri, CanParseFullWithoutPort)
34 {
35  Common::Uri uri("http://host");
36  ASSERT_EQ(uri.Scheme(), "http");
37  ASSERT_EQ(uri.Host(), "host");
38 }
39 
40 TEST(Uri, ThrowsIfSchemeEmpty)
41 {
42  ASSERT_THROW(Common::Uri("://host"), std::exception);
43 }
44 
45 TEST(Uri, ThrowsIfHostEmpty)
46 {
47  ASSERT_THROW(Common::Uri("htp://"), std::exception);
48  ASSERT_THROW(Common::Uri("htp://:8080"), std::exception);
49 }
50 
51 TEST(Uri, ThrowsIfInvalid)
52 {
53  ASSERT_THROW(Common::Uri("httphost8080"), std::exception);
54 }
55 
std::string Password() const
Definition: uri_facade.h:36
std::string Scheme() const
Definition: uri_facade.h:26
TEST(Uri, CanParseFullURI)
Dynamic addon for tests. GNU LGPL.
Definition: test_uri.cpp:15
std::string User() const
Definition: uri_facade.h:31
unsigned Port() const
Definition: uri_facade.h:46
#define ASSERT_THROW(statement, expected_exception)
string uri
Definition: client.py:31
#define ASSERT_EQ(val1, val2)
std::string Host() const
Definition: uri_facade.h:41


ros_opcua_impl_freeopcua
Author(s): Denis Štogl
autogenerated on Tue Jan 19 2021 03:12:08