ifw-daq  3.0.0-pre2
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 
network::uri MakeServerUri(std::string uri)
Creates a server URI.
Definition: uri.cpp:13
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
EXPECT_EQ(meta.rr_uri, "zpb.rr://meta")
TEST(Uri, MakeServerUri)
Definition: testUri.cpp:14
Contains URI support functions for daqif.