4
4
#include " gtest/gtest.h"
5
5
6
6
using node::url::URL;
7
+ using node::url::URL_FLAGS_FAILED;
7
8
8
9
class URLTest : public ::testing::Test {
9
10
protected:
@@ -20,6 +21,7 @@ class URLTest : public ::testing::Test {
20
21
TEST_F (URLTest, Simple) {
21
22
URL simple (" https://example.org:81/a/b/c?query#fragment" );
22
23
24
+ EXPECT_FALSE (simple.flags () & URL_FLAGS_FAILED);
23
25
EXPECT_EQ (simple.protocol (), " https:" );
24
26
EXPECT_EQ (simple.host (), " example.org" );
25
27
EXPECT_EQ (simple.port (), 81 );
@@ -32,6 +34,7 @@ TEST_F(URLTest, Simple2) {
32
34
const char * input = " https://example.org:81/a/b/c?query#fragment" ;
33
35
URL simple (input, strlen (input));
34
36
37
+ EXPECT_FALSE (simple.flags () & URL_FLAGS_FAILED);
35
38
EXPECT_EQ (simple.protocol (), " https:" );
36
39
EXPECT_EQ (simple.host (), " example.org" );
37
40
EXPECT_EQ (simple.port (), 81 );
@@ -40,10 +43,17 @@ TEST_F(URLTest, Simple2) {
40
43
EXPECT_EQ (simple.fragment (), " fragment" );
41
44
}
42
45
46
+ TEST_F (URLTest, NoBase1) {
47
+ URL error (" 123noscheme" );
48
+ EXPECT_TRUE (error.flags () & URL_FLAGS_FAILED);
49
+ }
50
+
43
51
TEST_F (URLTest, Base1) {
44
52
URL base (" http://example.org/foo/bar" );
45
- URL simple ( " ../baz " , &base );
53
+ ASSERT_FALSE (base. flags () & URL_FLAGS_FAILED );
46
54
55
+ URL simple (" ../baz" , &base);
56
+ EXPECT_FALSE (simple.flags () & URL_FLAGS_FAILED);
47
57
EXPECT_EQ (simple.protocol (), " http:" );
48
58
EXPECT_EQ (simple.host (), " example.org" );
49
59
EXPECT_EQ (simple.path (), " /baz" );
@@ -52,6 +62,7 @@ TEST_F(URLTest, Base1) {
52
62
TEST_F (URLTest, Base2) {
53
63
URL simple (" ../baz" , " http://example.org/foo/bar" );
54
64
65
+ EXPECT_FALSE (simple.flags () & URL_FLAGS_FAILED);
55
66
EXPECT_EQ (simple.protocol (), " http:" );
56
67
EXPECT_EQ (simple.host (), " example.org" );
57
68
EXPECT_EQ (simple.path (), " /baz" );
@@ -63,6 +74,7 @@ TEST_F(URLTest, Base3) {
63
74
64
75
URL simple (input, strlen (input), base, strlen (base));
65
76
77
+ EXPECT_FALSE (simple.flags () & URL_FLAGS_FAILED);
66
78
EXPECT_EQ (simple.protocol (), " http:" );
67
79
EXPECT_EQ (simple.host (), " example.org" );
68
80
EXPECT_EQ (simple.path (), " /baz" );
0 commit comments