diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2016-09-28 11:45:33 +0200 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2016-09-28 16:34:22 +0200 |
commit | 3f3fc7b7723698e44427e2a14a2f4906832800bf (patch) | |
tree | 5acadfa4d77817c41f612c89c93925a149cbcfc0 /test/util/token.test.cpp | |
parent | a8b007daa0e85ea4b1a4898fd591d55d0117cc85 (diff) | |
download | qtlocation-mapboxgl-3f3fc7b7723698e44427e2a14a2f4906832800bf.tar.gz |
[test] add .test.cpp suffix to test case files
Diffstat (limited to 'test/util/token.test.cpp')
-rw-r--r-- | test/util/token.test.cpp | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/test/util/token.test.cpp b/test/util/token.test.cpp new file mode 100644 index 0000000000..a2885dc8dd --- /dev/null +++ b/test/util/token.test.cpp @@ -0,0 +1,50 @@ +#include <iostream> +#include <mbgl/test/util.hpp> + +#include <mbgl/util/token.hpp> + +using namespace mbgl; + +TEST(Token, replaceTokens) { + EXPECT_EQ("literal", mbgl::util::replaceTokens("literal", [](const std::string& token) -> std::string { + if (token == "name") return "14th St NW"; + return ""; + })); + EXPECT_EQ("14th St NW", mbgl::util::replaceTokens("{name}", [](const std::string& token) -> std::string { + if (token == "name") return "14th St NW"; + return ""; + })); + EXPECT_EQ("", mbgl::util::replaceTokens("{name}", [](const std::string& token) -> std::string { + if (token == "text") return "14th St NW"; + return ""; + })); + EXPECT_EQ("1400", mbgl::util::replaceTokens("{num}", [](const std::string& token) -> std::string { + if (token == "num") return "1400"; + return ""; + })); + EXPECT_EQ("500 m", mbgl::util::replaceTokens("{num} m", [](const std::string& token) -> std::string { + if (token == "num") return "500"; + return ""; + })); + EXPECT_EQ("3 Fine Fields", mbgl::util::replaceTokens("{a} {b} {c}", [](const std::string& token) -> std::string { + if (token == "a") return "3"; + if (token == "b") return "Fine"; + if (token == "c") return "Fields"; + return ""; + })); + EXPECT_EQ(" but still", mbgl::util::replaceTokens("{notset} but still", [](const std::string&) -> std::string { + return ""; + })); + EXPECT_EQ("dashed", mbgl::util::replaceTokens("{dashed-property}", [](const std::string& token) -> std::string { + if (token == "dashed-property") return "dashed"; + return ""; + })); + EXPECT_EQ("colonized", mbgl::util::replaceTokens("{colon:property}", [](const std::string& token) -> std::string { + if (token == "colon:property") return "colonized"; + return ""; + })); + EXPECT_EQ("150 m", mbgl::util::replaceTokens("{HØYDE} m", [](const std::string& token) -> std::string { + if (token == "HØYDE") return "150"; + return ""; + })); +} |