ifw-daq  2.1.0-pre1
IFW Data Acquisition modules
testUri.cpp
Go to the documentation of this file.
1 /**
2  * @file
3  * @ingroup daq_ocm_daqifsupport
4  * @copyright 2022 ESO - European Southern Observatory
5  *
6  * @brief daqif:: uri helper test
7  */
8 #include <gtest/gtest.h>
9 
10 #include <daqif/uri.hpp>
11 
12 using namespace ::testing;
13 
15  EXPECT_EQ(daqif::MakeServerUri("zpb://host"), "zpb://host/");
16  EXPECT_EQ(daqif::MakeServerUri("zpb://host/"), "zpb://host/");
17  EXPECT_EQ(daqif::MakeServerUri("zpb://host//"), "zpb://host/");
18 }
19 
21  EXPECT_EQ(daqif::MakeServiceUri("zpb://host", "service"), "zpb://host/service");
22  EXPECT_EQ(daqif::MakeServiceUri("zpb://host/", "service"), "zpb://host/service");
23  EXPECT_EQ(daqif::MakeServiceUri("zpb://host//", "service"), "zpb://host/service");
24  EXPECT_EQ(daqif::MakeServiceUri("zpb://host", "/service"), "zpb://host/service");
25  EXPECT_EQ(daqif::MakeServiceUri("zpb://host", "//service"), "zpb://host/service");
26  EXPECT_EQ(daqif::MakeServiceUri("zpb://host/", "//service"), "zpb://host/service");
27  EXPECT_EQ(daqif::MakeServiceUri("zpb://host//", "//service"), "zpb://host/service");
28 
29  EXPECT_THROW(daqif::MakeServiceUri("", ""), std::invalid_argument);
30  EXPECT_THROW(daqif::MakeServiceUri("////", "///"), std::invalid_argument);
31  EXPECT_THROW(daqif::MakeServiceUri("/", "/"), std::invalid_argument);
32  EXPECT_THROW(daqif::MakeServiceUri("uri/", "/"), std::invalid_argument);
33  EXPECT_THROW(daqif::MakeServiceUri("/", "/service"), std::invalid_argument);
34 }
35 
daqif::MakeServiceUri
network::uri MakeServiceUri(std::string base_uri, std::string_view service_path)
Creates a service URI of the form <baseuri>/<service>.
Definition: uri.cpp:19
TEST
TEST(Uri, MakeServerUri)
Definition: testUri.cpp:14
daqif::MakeServerUri
network::uri MakeServerUri(std::string uri)
Creates a server URI.
Definition: uri.cpp:13
uri.hpp
Contains URI support functions for daqif.