Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd9f8902

Browse files
committed
[uri] Added further equality tests.
1 parentb63d1ff commitd9f8902

File tree

2 files changed

+57
-6
lines changed

2 files changed

+57
-6
lines changed

‎boost/network/uri/uri.hpp‎

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include<boost/utility/swap.hpp>
1616
#include<boost/range/algorithm/equal.hpp>
1717
#include<boost/range/algorithm/copy.hpp>
18+
#include<boost/range/as_literal.hpp>
1819
#include<boost/range/iterator_range.hpp>
1920
#include<boost/lexical_cast.hpp>
2021
#include<boost/optional.hpp>
@@ -38,14 +39,25 @@ class BOOST_URI_DECL uri {
3839
public:
3940

4041
typedef std::string string_type;
42+
typedef string_type::value_type value_type;
4143
typedef string_type::const_iterator const_iterator;
42-
typedef boost::iterator_range<std::string::const_iterator> const_range_type;
44+
typedef boost::iterator_range<const_iterator> const_range_type;
4345

4446
uri()
4547
: is_valid_(false) {
4648

4749
}
4850

51+
//uri(const value_type *uri)
52+
// : uri_(uri), is_valid_(false) {
53+
// parse();
54+
//}
55+
56+
uri(const string_type &uri)
57+
: uri_(uri), is_valid_(false) {
58+
parse();
59+
}
60+
4961
template<
5062
classFwdIter
5163
>
@@ -54,11 +66,6 @@ class BOOST_URI_DECL uri {
5466
parse();
5567
}
5668

57-
uri(const string_type &uri)
58-
: uri_(uri), is_valid_(false) {
59-
parse();
60-
}
61-
6269
uri(const uri &other)
6370
: uri_(other.uri_) {
6471
parse();
@@ -316,6 +323,26 @@ bool operator == (const uri &lhs, const uri &rhs) {
316323
returnboost::equal(lhs, rhs);
317324
}
318325

326+
inline
327+
booloperator == (const uri &lhs,const uri::string_type &rhs) {
328+
returnboost::equal(lhs, rhs);
329+
}
330+
331+
inline
332+
booloperator == (const uri::string_type &lhs,const uri &rhs) {
333+
returnboost::equal(lhs, rhs);
334+
}
335+
336+
inline
337+
booloperator == (const uri &lhs,const uri::value_type *rhs) {
338+
returnboost::equal(lhs,boost::as_literal(rhs));
339+
}
340+
341+
inline
342+
booloperator == (const uri::value_type *lhs,const uri &rhs) {
343+
returnboost::equal(boost::as_literal(lhs), rhs);
344+
}
345+
319346
inline
320347
booloperator != (const uri &lhs,const uri &rhs) {
321348
return !(lhs == rhs);

‎libs/network/test/uri/uri_test.cpp‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,30 @@ BOOST_AUTO_TEST_CASE(equality_test) {
342342
BOOST_CHECK(uri_1 == uri_2);
343343
}
344344

345+
BOOST_AUTO_TEST_CASE(equality_test_1) {
346+
uri::uriuri_1("http://www.example.com/");
347+
std::stringuri_2("http://www.example.com/");
348+
BOOST_CHECK(uri_1 == uri_2);
349+
}
350+
351+
BOOST_AUTO_TEST_CASE(equality_test_2) {
352+
std::stringuri_1("http://www.example.com/");
353+
uri::uriuri_2("http://www.example.com/");
354+
BOOST_CHECK(uri_1 == uri_2);
355+
}
356+
357+
BOOST_AUTO_TEST_CASE(equality_test_3) {
358+
uri::uriuri_1("http://www.example.com/");
359+
std::stringuri_2("http://www.example.com/");
360+
BOOST_CHECK(uri_1 == uri_2.c_str());
361+
}
362+
363+
BOOST_AUTO_TEST_CASE(equality_test_4) {
364+
std::stringuri_1("http://www.example.com/");
365+
uri::uriuri_2("http://www.example.com/");
366+
BOOST_CHECK(uri_1.c_str() == uri_2);
367+
}
368+
345369
BOOST_AUTO_TEST_CASE(inequality_test) {
346370
uri::uriuri_1("http://www.example.com/");
347371
uri::uriuri_2("http://www.example.com/");

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp