Permalink
Browse files

[URI] Added first relative URI test.

  • Loading branch information...
glynos committed Mar 3, 2012
1 parent aba7b0e commit 8cfecda6c1684bf36f408660123ff29860b59d50
@@ -10,6 +10,7 @@
# include <boost/network/uri/detail/uri_parts.hpp>
# include <boost/operators.hpp>
# include <boost/utility/swap.hpp>
+# include <boost/range/algorithm/equal.hpp>
# include <boost/range/iterator_range.hpp>
# include <boost/lexical_cast.hpp>
# include <boost/optional.hpp>
@@ -272,6 +273,11 @@ bool valid(const uri &uri_) {
return uri_.is_valid();
}
+inline
+bool is_absolute(const uri &uri_) {
+ return uri_.is_valid() && !boost::empty(uri_.scheme_range());
+}
+
inline
bool is_valid(const uri &uri_) {
return valid(uri_);
@@ -188,7 +188,7 @@ struct uri_grammar : qi::grammar<
;
start %=
- scheme >> ':'
+ -(scheme >> ':')
>> hier_part
>> -('?' >> query)
>> -('#' >> fragment)
@@ -11,6 +11,7 @@ if (Boost_FOUND)
url_test
url_builder_test
url_encoding_test
+ relative_url_test
)
foreach (test ${TESTS})
if (${CMAKE_CXX_COMPILER_ID} MATCHES GNU)
@@ -0,0 +1,20 @@
+// Copyright 2009, 2010, 2011 Dean Michael Berris, Jeroen Habraken, Glyn Matthews.
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt of copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#define BOOST_TEST_MODULE URL Test
+#include <boost/config/warning_disable.hpp>
+#include <boost/test/unit_test.hpp>
+#include <boost/network/uri/uri.hpp>
+#include <boost/network/uri/uri_io.hpp>
+
+
+using namespace boost::network;
+
+BOOST_AUTO_TEST_CASE(relative_uri_test) {
+ uri::uri instance("www.example.com/");
+ BOOST_REQUIRE(uri::valid(instance));
+ BOOST_CHECK(uri::is_absolute(instance));
+ BOOST_CHECK_EQUAL(uri::path(instance), "www.example.com/");
+}

0 comments on commit 8cfecda

Please sign in to comment.