improve tests

This commit is contained in:
wb-hx510875
2020-01-19 16:05:29 +08:00
committed by Jackson Tian
parent 38dab66f9d
commit b4e95dcd5a
5 changed files with 31 additions and 7 deletions

View File

@@ -61,6 +61,23 @@ namespace {
EXPECT_TRUE(decoded == url);
}
TEST(UtilsTest, MapToJson){
std::map<std::string, std::string> maps;
maps.insert(std::make_pair("foo", "bar"));
std::string jsonStr = MapToJson(maps);
EXPECT_EQ(jsonStr, "{\"foo\":\"bar\"}");
}
TEST(UtilsTest, JsonToMap){
std::map<std::string, std::string> targetMaps;
targetMaps.insert(std::make_pair("foo", "bar"));
targetMaps.insert(std::make_pair("int", "1"));
targetMaps.insert(std::make_pair("array","foo,bar"));
std::string jsonStr = "{\"foo\":\"bar\",\"int\":1,\"array\":[\"foo\",\"bar\"]}";
std::map<std::string, std::string> maps = JsonToMap(jsonStr);
EXPECT_EQ(targetMaps, maps);
}
TEST(Utils, GetEnv) {
const std::string var1 = GetEnv("PATH");
EXPECT_FALSE(var1.empty());