Catching more errors when parsing ICE server URLs.
Every malformed URL should now produce an error message in JS, rather than silently failing and possibly printing a warning message to the console (and possibly crashing). Also added some unit tests, and made "ParseIceServers" public. BUG=445002 Review URL: https://codereview.webrtc.org/1344143002 Cr-Commit-Position: refs/heads/master@{#10186}
This commit is contained in:
@ -298,6 +298,22 @@ TEST(TokenizeTest, TokenizeWithMarks) {
|
||||
ASSERT_STREQ("E F", fields.at(3).c_str());
|
||||
}
|
||||
|
||||
TEST(TokenizeTest, TokenizeWithEmptyTokens) {
|
||||
std::vector<std::string> fields;
|
||||
EXPECT_EQ(3ul, tokenize_with_empty_tokens("a.b.c", '.', &fields));
|
||||
EXPECT_EQ("a", fields[0]);
|
||||
EXPECT_EQ("b", fields[1]);
|
||||
EXPECT_EQ("c", fields[2]);
|
||||
|
||||
EXPECT_EQ(3ul, tokenize_with_empty_tokens("..c", '.', &fields));
|
||||
EXPECT_TRUE(fields[0].empty());
|
||||
EXPECT_TRUE(fields[1].empty());
|
||||
EXPECT_EQ("c", fields[2]);
|
||||
|
||||
EXPECT_EQ(1ul, tokenize_with_empty_tokens("", '.', &fields));
|
||||
EXPECT_TRUE(fields[0].empty());
|
||||
}
|
||||
|
||||
TEST(TokenizeFirstTest, NoLeadingSpaces) {
|
||||
std::string token;
|
||||
std::string rest;
|
||||
@ -428,4 +444,5 @@ TEST(BoolTest, RoundTrip) {
|
||||
EXPECT_TRUE(FromString(ToString(false), &value));
|
||||
EXPECT_FALSE(value);
|
||||
}
|
||||
|
||||
} // namespace rtc
|
||||
|
Reference in New Issue
Block a user