summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/MemoryManagerSuite.cpp4
-rw-r--r--test/test.cpp57
2 files changed, 60 insertions, 1 deletions
diff --git a/test/MemoryManagerSuite.cpp b/test/MemoryManagerSuite.cpp
index 4cda664..a828d76 100644
--- a/test/MemoryManagerSuite.cpp
+++ b/test/MemoryManagerSuite.cpp
@@ -27,7 +27,11 @@
#include <gtest/gtest.h>
#include <uriparser/Uri.h>
+
+// For defaultMemoryManager
+extern "C" {
#include "../src/UriMemory.h"
+}
namespace {
diff --git a/test/test.cpp b/test/test.cpp
index 9a189f9..4b156a4 100644
--- a/test/test.cpp
+++ b/test/test.cpp
@@ -311,7 +311,7 @@ TEST(UriSuite, TestUri) {
ASSERT_TRUE(0 == uriParseUriA(&stateA, "//user:pass@localhost/one/two/three"));
uriFreeUriMembersA(&uriA);
- // ANSI and Unicode
+ // Both narrow and wide string version
ASSERT_TRUE(0 == uriParseUriA(&stateA, "http://www.example.com/"));
uriFreeUriMembersA(&uriA);
ASSERT_TRUE(0 == uriParseUriW(&stateW, L"http://www.example.com/"));
@@ -1098,6 +1098,19 @@ TEST(UriSuite, TestAddBase) {
// Bug related to absolutePath flag set despite presence of host
ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"/", L"http://a/"));
ASSERT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"/g/", L"http://a/g/"));
+
+ // GitHub issue #92
+ EXPECT_TRUE(testAddBaseHelper(L"http://a/b/c/../d;p?q", L"../..", L"http://a/"));
+ EXPECT_TRUE(testAddBaseHelper(L"http://a/b/c/../d;p?q", L"../../", L"http://a/"));
+
+ EXPECT_TRUE(testAddBaseHelper(L"http://a/b/../c/d;p?q", L"../..", L"http://a/"));
+ EXPECT_TRUE(testAddBaseHelper(L"http://a/b/../c/d;p?q", L"../../", L"http://a/"));
+
+ EXPECT_TRUE(testAddBaseHelper(L"http://a/../b/c/d;p?q", L"../..", L"http://a/"));
+ EXPECT_TRUE(testAddBaseHelper(L"http://a/../b/c/d;p?q", L"../../", L"http://a/"));
+
+ EXPECT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"../../..", L"http://a/"));
+ EXPECT_TRUE(testAddBaseHelper(L"http://a/b/c/d;p?q", L"../../../", L"http://a/"));
}
namespace {
@@ -1477,6 +1490,48 @@ TEST(UriSuite, TestNormalizeSyntaxComponents) {
URI_NORMALIZE_FRAGMENT));
}
+TEST(UriSuite, TestNormalizeSyntaxPath) {
+ // These are from GitHub issue #92
+ EXPECT_TRUE(testNormalizeSyntaxHelper(
+ L"http://a/b/c/../../..",
+ L"http://a/",
+ URI_NORMALIZE_PATH));
+ EXPECT_TRUE(testNormalizeSyntaxHelper(
+ L"http://a/b/../c/../..",
+ L"http://a/",
+ URI_NORMALIZE_PATH));
+ EXPECT_TRUE(testNormalizeSyntaxHelper(
+ L"http://a/b/c/../../..",
+ L"http://a/",
+ URI_NORMALIZE_PATH));
+
+ // .. and these are related
+ EXPECT_TRUE(testNormalizeSyntaxHelper(
+ L"http://a/..",
+ L"http://a/",
+ URI_NORMALIZE_PATH));
+ EXPECT_TRUE(testNormalizeSyntaxHelper(
+ L"/..",
+ L"/",
+ URI_NORMALIZE_PATH));
+ EXPECT_TRUE(testNormalizeSyntaxHelper(
+ L"http://a/..///",
+ L"http://a///",
+ URI_NORMALIZE_PATH));
+ EXPECT_TRUE(testNormalizeSyntaxHelper(
+ L"http://a/..///..",
+ L"http://a//",
+ URI_NORMALIZE_PATH));
+ EXPECT_TRUE(testNormalizeSyntaxHelper(
+ L"a/b/c/../../..",
+ L"",
+ URI_NORMALIZE_PATH));
+ EXPECT_TRUE(testNormalizeSyntaxHelper(
+ L"a/b/../../c/..",
+ L"",
+ URI_NORMALIZE_PATH));
+}
+
TEST(UriSuite, TestNormalizeCrashBug20080224) {
UriParserStateW stateW;
int res;