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

Commit63f07da

Browse files
committed
[uri] Added a swap function and less than operator.
1 parent00715df commit63f07da

File tree

2 files changed

+45
-1
lines changed

2 files changed

+45
-1
lines changed

‎boost/network/uri/uri.hpp‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
#ifndef __BOOST_NETWORK_URI_INC__
88
#define__BOOST_NETWORK_URI_INC__
99

10+
#pragma once
11+
1012
#include<boost/network/uri/config.hpp>
1113
#include<boost/network/uri/detail/uri_parts.hpp>
1214
#include<boost/network/uri/schemes.hpp>
@@ -295,6 +297,11 @@ bool is_valid(const uri &uri_) {
295297
returnvalid(uri_);
296298
}
297299

300+
inline
301+
voidswap(uri &lhs, uri &rhs) {
302+
lhs.swap(rhs);
303+
}
304+
298305
inline
299306
booloperator == (const uri &lhs,const uri &rhs) {
300307
returnboost::equal(lhs, rhs);
@@ -304,6 +311,11 @@ inline
304311
booloperator != (const uri &lhs,const uri &rhs) {
305312
return !(lhs == rhs);
306313
}
314+
315+
inline
316+
booloperator < (const uri &lhs,const uri &rhs) {
317+
return lhs.string() < rhs.string();
318+
}
307319
}// namespace uri
308320
}// namespace network
309321
}// namespace boost

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

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,10 +310,42 @@ BOOST_AUTO_TEST_CASE(assignment_test) {
310310
BOOST_CHECK_EQUAL(instance, copy);
311311
}
312312

313+
BOOST_AUTO_TEST_CASE(swap_test) {
314+
uri::uriinstance("http://www.example.com/");
315+
uri::uricopy("http://www.example.org/");
316+
uri::swap(instance, copy);
317+
BOOST_CHECK_EQUAL(instance.string(),"http://www.example.org/");
318+
BOOST_CHECK_EQUAL(copy.string(),"http://www.example.com/");
319+
}
320+
321+
BOOST_AUTO_TEST_CASE(equality_test) {
322+
uri::uriuri_1("http://www.example.com/");
323+
uri::uriuri_2("http://www.example.com/");
324+
BOOST_CHECK(uri_1 == uri_2);
325+
}
326+
327+
BOOST_AUTO_TEST_CASE(inequality_test) {
328+
uri::uriuri_1("http://www.example.com/");
329+
uri::uriuri_2("http://www.example.com/");
330+
BOOST_CHECK(!(uri_1 != uri_2));
331+
}
332+
333+
BOOST_AUTO_TEST_CASE(less_than_test) {
334+
// uri_1 is lexicographically less than uri_2
335+
uri::uriuri_1("http://www.example.com/");
336+
uri::uriuri_2("http://www.example.org/");
337+
BOOST_CHECK(uri_1 < uri_2);
338+
}
339+
313340
BOOST_AUTO_TEST_CASE(username_test) {
314-
uri::uriinstance("ftp://john.doe:password@ftp.example.com/");
341+
uri::uriinstance("ftp://john.doe@ftp.example.com/");
315342
BOOST_REQUIRE(uri::valid(instance));
316343
BOOST_CHECK_EQUAL(uri::username(instance),"john.doe");
344+
}
345+
346+
BOOST_AUTO_TEST_CASE(pasword_test) {
347+
uri::uriinstance("ftp://john.doe:password@ftp.example.com/");
348+
BOOST_REQUIRE(uri::valid(instance));
317349
BOOST_CHECK_EQUAL(uri::password(instance),"password");
318350
}
319351

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp