[core] add util::isURL() for checking whether a string starts with a URL scheme
This commit is contained in:
25
test/util/url.test.cpp
Normal file
25
test/util/url.test.cpp
Normal file
@@ -0,0 +1,25 @@
|
||||
#include <mbgl/test/util.hpp>
|
||||
|
||||
#include <mbgl/util/url.hpp>
|
||||
|
||||
#include <memory>
|
||||
|
||||
using namespace mbgl::util;
|
||||
|
||||
TEST(URL, isURL) {
|
||||
EXPECT_TRUE(isURL("mapbox://foo"));
|
||||
EXPECT_TRUE(isURL("mapbox://"));
|
||||
EXPECT_TRUE(isURL("mapbox-test-scheme://foo"));
|
||||
EXPECT_TRUE(isURL("mapbox+style://foo"));
|
||||
EXPECT_TRUE(isURL("mapbox-2.0://foo"));
|
||||
EXPECT_TRUE(isURL("mapbox99://foo"));
|
||||
|
||||
EXPECT_FALSE(isURL("mapbox:/"));
|
||||
EXPECT_FALSE(isURL(" mapbox://"));
|
||||
EXPECT_FALSE(isURL("://"));
|
||||
EXPECT_FALSE(isURL("mapbox"));
|
||||
EXPECT_FALSE(isURL("mapbox:foo"));
|
||||
EXPECT_FALSE(isURL("mapbox:/foo"));
|
||||
EXPECT_FALSE(isURL("test/mapbox://foo"));
|
||||
EXPECT_FALSE(isURL("123://foo"));
|
||||
}
|
||||
Reference in New Issue
Block a user