summaryrefslogtreecommitdiff
path: root/test/test.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/test.cpp')
-rw-r--r--test/test.cpp52
1 files changed, 43 insertions, 9 deletions
diff --git a/test/test.cpp b/test/test.cpp
index 78fd980..7a68c39 100644
--- a/test/test.cpp
+++ b/test/test.cpp
@@ -242,6 +242,19 @@ TEST(UriSuite, TestIpSixFail) {
URI_TEST_IP_SIX_FAIL("g:0:0:0:0:0:0");
}
+TEST(UriSuite, TestIpSixOverread) {
+ UriUriA uri;
+ const char * errorPos;
+
+ // NOTE: This string is designed to not have a terminator
+ char uriText[2 + 3 + 2 + 1 + 1];
+ strncpy(uriText, "//[::44.1", sizeof(uriText));
+
+ EXPECT_EQ(uriParseSingleUriExA(&uri, uriText,
+ uriText + sizeof(uriText), &errorPos), URI_ERROR_SYNTAX);
+ EXPECT_EQ(errorPos, uriText + sizeof(uriText));
+}
+
TEST(UriSuite, TestUri) {
UriParserStateA stateA;
UriParserStateW stateW;
@@ -1214,6 +1227,8 @@ namespace {
return false;
}
+ EXPECT_EQ(charsRequired, wcslen(text));
+
// Minimum
wchar_t * buffer = new wchar_t[charsRequired + 1];
if (uriToStringW(buffer, &uri, charsRequired + 1, NULL) != 0) {
@@ -1236,15 +1251,24 @@ namespace {
} // namespace
TEST(UriSuite, TestToStringCharsRequired) {
- ASSERT_TRUE(testToStringCharsRequiredHelper(L"http://www.example.com/"));
- ASSERT_TRUE(testToStringCharsRequiredHelper(L"http://www.example.com:80/"));
- ASSERT_TRUE(testToStringCharsRequiredHelper(L"http://user:pass@www.example.com/"));
- ASSERT_TRUE(testToStringCharsRequiredHelper(L"http://www.example.com/index.html"));
- ASSERT_TRUE(testToStringCharsRequiredHelper(L"http://www.example.com/?abc"));
- ASSERT_TRUE(testToStringCharsRequiredHelper(L"http://www.example.com/#def"));
- ASSERT_TRUE(testToStringCharsRequiredHelper(L"http://www.example.com/?abc#def"));
- ASSERT_TRUE(testToStringCharsRequiredHelper(L"/test"));
- ASSERT_TRUE(testToStringCharsRequiredHelper(L"test"));
+ EXPECT_TRUE(testToStringCharsRequiredHelper(L"http://1.1.1.1/"));
+ EXPECT_TRUE(testToStringCharsRequiredHelper(L"http://12.1.1.1/"));
+ EXPECT_TRUE(testToStringCharsRequiredHelper(L"http://123.1.1.1/"));
+ EXPECT_TRUE(testToStringCharsRequiredHelper(L"http://1.12.1.1/"));
+ EXPECT_TRUE(testToStringCharsRequiredHelper(L"http://1.123.1.1/"));
+ EXPECT_TRUE(testToStringCharsRequiredHelper(L"http://1.1.12.1/"));
+ EXPECT_TRUE(testToStringCharsRequiredHelper(L"http://1.1.123.1/"));
+ EXPECT_TRUE(testToStringCharsRequiredHelper(L"http://1.1.1.12/"));
+ EXPECT_TRUE(testToStringCharsRequiredHelper(L"http://1.1.1.123/"));
+ EXPECT_TRUE(testToStringCharsRequiredHelper(L"http://www.example.com/"));
+ EXPECT_TRUE(testToStringCharsRequiredHelper(L"http://www.example.com:80/"));
+ EXPECT_TRUE(testToStringCharsRequiredHelper(L"http://user:pass@www.example.com/"));
+ EXPECT_TRUE(testToStringCharsRequiredHelper(L"http://www.example.com/index.html"));
+ EXPECT_TRUE(testToStringCharsRequiredHelper(L"http://www.example.com/?abc"));
+ EXPECT_TRUE(testToStringCharsRequiredHelper(L"http://www.example.com/#def"));
+ EXPECT_TRUE(testToStringCharsRequiredHelper(L"http://www.example.com/?abc#def"));
+ EXPECT_TRUE(testToStringCharsRequiredHelper(L"/test"));
+ EXPECT_TRUE(testToStringCharsRequiredHelper(L"test"));
}
namespace {
@@ -2041,6 +2065,16 @@ TEST(UriSuite, TestRangeComparisonRemoveBaseUriIssue19) {
"http://example2/x/y/z");
}
+TEST(ErrorPosSuite, TestErrorPosIPvFuture) {
+ UriUriA uri;
+ const char * errorPos;
+
+ const char * const uriText = "http://[vA.123456"; // missing "]"
+ EXPECT_EQ(uriParseSingleUriA(&uri, uriText, &errorPos),
+ URI_ERROR_SYNTAX);
+ EXPECT_EQ(errorPos, uriText + strlen(uriText));
+}
+
TEST(UriParseSingleSuite, Success) {
UriUriA uri;