|
1 | 1 | // Copyright 2010 Jeroen Habraken. |
2 | | -// Copyright 2009-2016 Dean Michael Berris, Glyn Matthews. |
| 2 | +// Copyright 2009-2017 Dean Michael Berris, Glyn Matthews. |
3 | 3 | // Copyright 2012 Google, Inc. |
4 | 4 | // Distributed under the Boost Software License, Version 1.0. |
5 | 5 | // (See accompanying file LICENSE_1_0.txt of copy at |
@@ -223,6 +223,17 @@ TEST(uri_test, file_test) { |
223 | 223 | EXPECT_EQ("/bin/bash", instance.path()); |
224 | 224 | } |
225 | 225 |
|
| 226 | +TEST(uri_test, file_path_has_host_bug_98) { |
| 227 | + network::uri instance("file:///bin/bash"); |
| 228 | + EXPECT_TRUE(instance.has_scheme()); |
| 229 | + EXPECT_FALSE(instance.has_user_info()); |
| 230 | + EXPECT_TRUE(instance.has_host()); |
| 231 | + EXPECT_FALSE(instance.has_port()); |
| 232 | + EXPECT_TRUE(instance.has_path()); |
| 233 | + EXPECT_FALSE(instance.has_query()); |
| 234 | + EXPECT_FALSE(instance.has_fragment()); |
| 235 | +} |
| 236 | + |
226 | 237 | TEST(uri_test, xmpp_test) { |
227 | 238 | network::uri instance("xmpp:example-node@example.com?message;subject=Hello%20World"); |
228 | 239 | EXPECT_EQ("xmpp", instance.scheme()); |
@@ -418,11 +429,23 @@ TEST(uri_test, assignment_test) { |
418 | 429 | } |
419 | 430 |
|
420 | 431 | TEST(uri_test, swap_test) { |
421 | | - network::uri instance("http://www.example.com/"); |
422 | | - network::uri copy("http://www.example.org/"); |
423 | | - network::swap(instance, copy); |
424 | | - EXPECT_EQ("http://www.example.org/", instance); |
425 | | - EXPECT_EQ("http://www.example.com/", copy); |
| 432 | + network::uri original("http://example.com/path/to/file.txt"); |
| 433 | + network::uri instance("file:///something/different/"); |
| 434 | + original.swap(instance); |
| 435 | + |
| 436 | + ASSERT_TRUE(original.has_scheme()); |
| 437 | + ASSERT_TRUE(original.has_host()); |
| 438 | + ASSERT_TRUE(original.has_path()); |
| 439 | + EXPECT_EQ("file", original.scheme()); |
| 440 | + EXPECT_EQ("", original.host()); |
| 441 | + EXPECT_EQ("/something/different", original.path()); |
| 442 | + |
| 443 | + ASSERT_TRUE(instance.has_scheme()); |
| 444 | + ASSERT_TRUE(instance.has_host()); |
| 445 | + ASSERT_TRUE(instance.has_path()); |
| 446 | + EXPECT_EQ("http", instance.scheme()); |
| 447 | + EXPECT_EQ("example.com", instance.host()); |
| 448 | + EXPECT_EQ("/path/to/file.txt", instance.path()); |
426 | 449 | } |
427 | 450 |
|
428 | 451 | TEST(uri_test, authority_test) { |
@@ -531,14 +554,14 @@ TEST(uri_test, mailto_has_no_authority) { |
531 | 554 | EXPECT_FALSE(instance.has_authority()); |
532 | 555 | } |
533 | 556 |
|
534 | | -TEST(uri_test, http_is_hierarchical) { |
| 557 | +TEST(uri_test, http_is_not_opaque) { |
535 | 558 | network::uri instance("http://www.example.com/"); |
536 | | - EXPECT_TRUE(!instance.is_opaque()); |
| 559 | + EXPECT_FALSE(instance.is_opaque()); |
537 | 560 | } |
538 | 561 |
|
539 | | -TEST(uri_test, file_is_hierarchical) { |
| 562 | +TEST(uri_test, file_is_not_opaque) { |
540 | 563 | network::uri instance("file:///bin/bash"); |
541 | | - EXPECT_TRUE(!instance.is_opaque()); |
| 564 | + EXPECT_FALSE(instance.is_opaque()); |
542 | 565 | } |
543 | 566 |
|
544 | 567 | TEST(uri_test, mailto_is_absolute) { |
@@ -884,3 +907,96 @@ TEST(uri_test, query_iterator_with_fragment) { |
884 | 907 | EXPECT_EQ("c", query_it->first); |
885 | 908 | EXPECT_EQ("d", query_it->second); |
886 | 909 | } |
| 910 | + |
| 911 | +TEST(uri_test, copy_assignment_bug_98) { |
| 912 | + network::uri original("file:///path/to/file.txt"); |
| 913 | + |
| 914 | + ASSERT_TRUE(original.has_scheme()); |
| 915 | + ASSERT_FALSE(original.is_opaque()); |
| 916 | + ASSERT_TRUE(original.has_host()); |
| 917 | + ASSERT_TRUE(original.has_path()); |
| 918 | + |
| 919 | + network::uri instance; |
| 920 | + instance = original; |
| 921 | + |
| 922 | + ASSERT_TRUE(instance.has_scheme()); |
| 923 | + ASSERT_TRUE(instance.has_host()); |
| 924 | + ASSERT_TRUE(instance.has_path()); |
| 925 | + EXPECT_EQ("file", instance.scheme()); |
| 926 | + EXPECT_EQ("", instance.host()); |
| 927 | + EXPECT_EQ("/path/to/file.txt", instance.path()); |
| 928 | +} |
| 929 | + |
| 930 | +TEST(uri_test, copy_assignment_bug_98_2) { |
| 931 | + network::uri original("file:///path/to/file.txt?query=value#foo"); |
| 932 | + |
| 933 | + network::uri instance; |
| 934 | + instance = original; |
| 935 | + |
| 936 | + ASSERT_TRUE(instance.has_scheme()); |
| 937 | + ASSERT_TRUE(instance.has_path()); |
| 938 | + ASSERT_TRUE(instance.has_query()); |
| 939 | + ASSERT_TRUE(instance.has_fragment()); |
| 940 | + EXPECT_EQ("file", instance.scheme()); |
| 941 | + EXPECT_EQ("/path/to/file.txt", instance.path()); |
| 942 | + EXPECT_EQ("query=value", instance.query()); |
| 943 | + EXPECT_EQ("foo", instance.fragment()); |
| 944 | +} |
| 945 | + |
| 946 | +TEST(uri_test, copy_constructor_bug_98) { |
| 947 | + network::uri original("file:///path/to/file.txt?query=value#foo"); |
| 948 | + |
| 949 | + network::uri instance(original); |
| 950 | + |
| 951 | + ASSERT_TRUE(instance.has_scheme()); |
| 952 | + ASSERT_TRUE(instance.has_path()); |
| 953 | + ASSERT_TRUE(instance.has_query()); |
| 954 | + ASSERT_TRUE(instance.has_fragment()); |
| 955 | + EXPECT_EQ("file", instance.scheme()); |
| 956 | + EXPECT_EQ("/path/to/file.txt", instance.path()); |
| 957 | + EXPECT_EQ("query=value", instance.query()); |
| 958 | + EXPECT_EQ("foo", instance.fragment()); |
| 959 | +} |
| 960 | + |
| 961 | +TEST(uri_test, move_assignment_bug_98) { |
| 962 | + network::uri original("file:///path/to/file.txt?query=value#foo"); |
| 963 | + |
| 964 | + network::uri instance; |
| 965 | + instance = std::move(original); |
| 966 | + |
| 967 | + ASSERT_TRUE(instance.has_scheme()); |
| 968 | + ASSERT_TRUE(instance.has_path()); |
| 969 | + ASSERT_TRUE(instance.has_query()); |
| 970 | + ASSERT_TRUE(instance.has_fragment()); |
| 971 | + EXPECT_EQ("file", instance.scheme()); |
| 972 | + EXPECT_EQ("/path/to/file.txt", instance.path()); |
| 973 | + EXPECT_EQ("query=value", instance.query()); |
| 974 | + EXPECT_EQ("foo", instance.fragment()); |
| 975 | +} |
| 976 | + |
| 977 | +TEST(uri_test, move_constructor_bug_98) { |
| 978 | + network::uri original("file:///path/to/file.txt?query=value#foo"); |
| 979 | + |
| 980 | + network::uri instance(std::move(original)); |
| 981 | + |
| 982 | + ASSERT_TRUE(instance.has_scheme()); |
| 983 | + ASSERT_TRUE(instance.has_path()); |
| 984 | + ASSERT_TRUE(instance.has_query()); |
| 985 | + ASSERT_TRUE(instance.has_fragment()); |
| 986 | + EXPECT_EQ("file", instance.scheme()); |
| 987 | + EXPECT_EQ("/path/to/file.txt", instance.path()); |
| 988 | + EXPECT_EQ("query=value", instance.query()); |
| 989 | + EXPECT_EQ("foo", instance.fragment()); |
| 990 | +} |
| 991 | + |
| 992 | +TEST(uri_test, http_copy_assignment_bug_98) { |
| 993 | + network::uri original("http://example.com/path/to/file.txt"); |
| 994 | + |
| 995 | + network::uri instance; |
| 996 | + instance = original; |
| 997 | + |
| 998 | + ASSERT_TRUE(instance.has_scheme()); |
| 999 | + ASSERT_TRUE(instance.has_path()); |
| 1000 | + EXPECT_EQ("http", instance.scheme()); |
| 1001 | + EXPECT_EQ("/path/to/file.txt", instance.path()); |
| 1002 | +} |
0 commit comments