7 #define BOOST_TEST_DYN_LINK
8 #define BOOST_TEST_MODULE "Test module for URIs manipulation"
10 #include <boost/test/unit_test.hpp>
16 using namespace boost;
22 BOOST_AUTO_TEST_SUITE( URI_TestSuite )
30 BOOST_CHECK(p0.
empty());
31 BOOST_CHECK_EQUAL(p0.
string().size(), (size_t)0 );
35 BOOST_CHECK(!p1.
empty());
36 BOOST_CHECK_EQUAL( std::strcmp( p1.
path().c_str(),
"lolo" ), 0 );
37 BOOST_CHECK_EQUAL( std::strcmp( p1.
string().c_str(),
"cpath:lolo" ), 0 );
42 BOOST_CHECK(!p2.
empty());
43 BOOST_CHECK(!p3.
empty());
44 BOOST_CHECK_EQUAL( std::strcmp( p2.
string().c_str(), p3.
string().c_str() ), 0 );
46 URI uri_absolute (
"cpath:/hostname/root/component");
47 URI uri_relative (
"../component");
50 BOOST_CHECK(!p4.
empty());
51 BOOST_CHECK_EQUAL( p4.
string(),
"cpath:/hostname/root/component");
55 BOOST_CHECK(!p5.empty());
56 BOOST_CHECK_EQUAL( p5.string(),
"cpath:../component");
57 BOOST_CHECK(p5.is_relative());
65 URI p0 (
"/root/dir1" );
66 URI p1 (
"dir2/dir3" );
69 BOOST_CHECK_EQUAL( std::strcmp( p2.
path().c_str(),
"/root/dir1/dir2/dir3" ), 0 );
73 BOOST_CHECK_EQUAL( std::strcmp( p3.
path().c_str(),
"/root/dir1" ), 0 );
75 URI p5 = p0 /
"dir5/dir55";
76 BOOST_CHECK_EQUAL( std::strcmp( p5.
path().c_str(),
"/root/dir1/dir5/dir55" ), 0 );
78 URI p6 =
"/root/dir6";
79 BOOST_CHECK_EQUAL( std::strcmp( p6.
path().c_str(),
"/root/dir6" ), 0 );
90 BOOST_CHECK_EQUAL( uri.
scheme(), URI::Scheme::CPATH );
91 BOOST_CHECK_EQUAL( uri.
string(), std::string(
"cpath:/Component") );
92 BOOST_CHECK_EQUAL( uri.
path(), std::string(
"/Component") );
95 URI uri2(
"cpath:/Component");
96 BOOST_CHECK_EQUAL( uri2.scheme(), URI::Scheme::CPATH );
97 BOOST_CHECK_EQUAL( uri2.string(), std::string(
"cpath:/Component") );
98 BOOST_CHECK_EQUAL( uri2.path(), std::string(
"/Component") );
101 URI uri3(
"file:///etc/fstab.txt");
103 BOOST_CHECK_EQUAL( uri3.string(), std::string(
"file:///etc/fstab.txt") );
104 BOOST_CHECK_EQUAL( uri3.path(), std::string(
"///etc/fstab.txt") );
105 BOOST_CHECK_EQUAL( uri3.base_path().string(), std::string(
"file:///etc") );
106 BOOST_CHECK_EQUAL( uri3.extension(), std::string(
".txt") );
107 BOOST_CHECK_EQUAL( uri3.base_name(), std::string(
"fstab") );
112 URI uri4(
"http://coolfluidsrv.vki.ac.be");
114 BOOST_CHECK_EQUAL( uri4.scheme(), URI::Scheme::HTTP );
115 BOOST_CHECK_EQUAL( uri4.string(), std::string(
"http://coolfluidsrv.vki.ac.be") );
116 BOOST_CHECK_EQUAL( uri4.path(), std::string(
"//coolfluidsrv.vki.ac.be") );
119 URI uri5(
"https://coolfluidsrv.vki.ac.be");
120 BOOST_CHECK_EQUAL( uri5.scheme(), URI::Scheme::HTTPS );
121 BOOST_CHECK_EQUAL( uri5.string(), std::string(
"https://coolfluidsrv.vki.ac.be") );
122 BOOST_CHECK_EQUAL( uri5.path(), std::string(
"//coolfluidsrv.vki.ac.be") );
125 URI uri6(
"http://coolfluidsrv.vki.ac.be/redmine/projects/activity/coolfluid3?"
126 "show_issues=1&show_changesets=1&show_news=1&show_documents=1&"
127 "show_files=1&show_wiki_edits=1");
128 BOOST_CHECK_EQUAL( uri6.scheme(), URI::Scheme::HTTP );
129 BOOST_CHECK_EQUAL( uri6.string(),
130 std::string(
"http://coolfluidsrv.vki.ac.be/redmine/projects/activity/"
131 "coolfluid3?show_issues=1&show_changesets=1&show_news=1&"
132 "show_documents=1&show_files=1&show_wiki_edits=1") );
133 BOOST_CHECK_EQUAL( uri6.path(),
134 std::string(
"//coolfluidsrv.vki.ac.be/redmine/projects/activity/"
135 "coolfluid3?show_issues=1&show_changesets=1&show_news=1&"
136 "show_documents=1&show_files=1&show_wiki_edits=1") );
144 BOOST_CHECK_EQUAL( URI::Scheme::Convert::instance().
to_str(URI::Scheme::CPATH), std::string(
"cpath") );
149 BOOST_AUTO_TEST_SUITE_END()
external boost library namespace
Scheme::Type scheme() const
common::URI uri(ComponentWrapper &self)
Common_API std::string to_str(const T &v)
Converts to std::string.
Uniform Resource Identifier (see http://en.wikipedia.org/wiki/Uniform_Resource_Identifier) ...
Top-level namespace for coolfluid.
BOOST_AUTO_TEST_CASE(constructors)
Most basic kernel library.
std::string string() const