Skip to content

Commit

Permalink
Add test case for URI parser for WHATWG compliance (issue #61).
Browse files Browse the repository at this point in the history
  • Loading branch information
lambdafu committed Mar 21, 2018
1 parent 7332bf6 commit cfca3c0
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions lib/proto/uri_tests.cpp
@@ -1,8 +1,7 @@
/* Tests for stream functions
Copyright 2017 The NeoPG developers
NeoPG is released under the Simplified BSD License (see license.txt)
*/
// Tests for stream functions
// Copyright 2017-2018 The NeoPG developers
//
// NeoPG is released under the Simplified BSD License (see license.txt)

#include <neopg/uri.h>
#include "gtest/gtest.h"
Expand Down Expand Up @@ -52,6 +51,19 @@ TEST(NeoPGTest, proto_uri_test) {
EXPECT_EQ(uri.query, "name=foo");
EXPECT_EQ(uri.fragment, "chapter1");
EXPECT_EQ(uri.str(), input);

// Avoid traps like https://github.com/nodejs/node/issues/19468
input = "http://brave.com%60x.code-fu.org";
uri.set_uri(input);
EXPECT_EQ(uri.scheme, "http");
EXPECT_EQ(uri.authority, "brave.com%60x.code-fu.org");
EXPECT_EQ(uri.userinfo, "");
EXPECT_EQ(uri.host, "brave.com%60x.code-fu.org");
EXPECT_EQ(uri.port, "");
EXPECT_EQ(uri.path, "");
EXPECT_EQ(uri.query, "");
EXPECT_EQ(uri.fragment, "");
EXPECT_EQ(uri.str(), input);
}
}
}
} // namespace NeoPG

0 comments on commit cfca3c0

Please sign in to comment.