Skip to content
This repository has been archived by the owner on Jun 23, 2022. It is now read-only.

Commit

Permalink
fix by review
Browse files Browse the repository at this point in the history
  • Loading branch information
levy5307 committed Dec 31, 2020
1 parent 443241d commit dd467b7
Showing 1 changed file with 37 additions and 23 deletions.
60 changes: 37 additions & 23 deletions src/utils/test/flag_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,54 +141,68 @@ TEST(flag_test, get_config)
auto res = get_flag_str("get_flag_not_exist");
ASSERT_EQ(res.get_error().code(), ERR_OBJECT_NOT_FOUND);

res = get_flag_str("get_flag_int32");
std::string test_app = "get_flag_int32";
res = get_flag_str(test_app);
ASSERT_TRUE(res.is_ok());
ASSERT_EQ(
res.get_value(),
"{\"name\":\"get_flag_int32\",\"section\":\"flag_test\",\"type\":\"FV_INT32\",\"tags\":"
"\"flag_tag::FT_MUTABLE\",\"description\":\"test get_flag_int32\",\"value\":\"5\"}\n");
R"({"name":")" + test_app +
R"(","section":"flag_test","type":"FV_INT32","tags":"flag_tag::FT_MUTABLE","description":"test get_flag_int32","value":")" +
std::to_string(FLAGS_get_flag_int32) + R"("})" + "\n");

res = get_flag_str("get_flag_uint32");
test_app = "get_flag_uint32";
res = get_flag_str(test_app);
ASSERT_TRUE(res.is_ok());
ASSERT_EQ(
res.get_value(),
"{\"name\":\"get_flag_uint32\",\"section\":\"flag_test\",\"type\":\"FV_UINT32\",\"tags\":"
"\"flag_tag::FT_MUTABLE\",\"description\":\"test get_flag_uint32\",\"value\":\"5\"}\n");
R"({"name":")" + test_app +
R"(","section":"flag_test","type":"FV_UINT32","tags":"flag_tag::FT_MUTABLE","description":"test get_flag_uint32","value":")" +
std::to_string(FLAGS_get_flag_uint32) + R"("})" + "\n");

res = get_flag_str("get_flag_int64");
test_app = "get_flag_int64";
res = get_flag_str(test_app);
ASSERT_TRUE(res.is_ok());
ASSERT_EQ(
res.get_value(),
"{\"name\":\"get_flag_int64\",\"section\":\"flag_test\",\"type\":\"FV_INT64\",\"tags\":"
"\"flag_tag::FT_MUTABLE\",\"description\":\"test get_flag_int64\",\"value\":\"5\"}\n");
R"({"name":")" + test_app +
R"(","section":"flag_test","type":"FV_INT64","tags":"flag_tag::FT_MUTABLE","description":"test get_flag_int64","value":")" +
std::to_string(FLAGS_get_flag_int64) + R"("})" + "\n");

res = get_flag_str("get_flag_uint64");
test_app = "get_flag_uint64";
res = get_flag_str(test_app);
ASSERT_TRUE(res.is_ok());
ASSERT_EQ(
res.get_value(),
"{\"name\":\"get_flag_uint64\",\"section\":\"flag_test\",\"type\":\"FV_UINT64\",\"tags\":"
"\"flag_tag::FT_MUTABLE\",\"description\":\"test get_flag_uint64\",\"value\":\"5\"}\n");
R"({"name":")" + test_app +
R"(","section":"flag_test","type":"FV_UINT64","tags":"flag_tag::FT_MUTABLE","description":"test get_flag_uint64","value":")" +
std::to_string(FLAGS_get_flag_uint64) + R"("})" + "\n");

res = get_flag_str("get_flag_double");
test_app = "get_flag_double";
res = get_flag_str(test_app);
ASSERT_TRUE(res.is_ok());
ASSERT_EQ(
res.get_value(),
"{\"name\":\"get_flag_double\",\"section\":\"flag_test\",\"type\":\"FV_DOUBLE\",\"tags\":"
"\"flag_tag::FT_MUTABLE\",\"description\":\"test get_flag_double\",\"value\":\"5.12\"}\n");
R"({"name":")" + test_app +
R"(","section":"flag_test","type":"FV_DOUBLE","tags":"flag_tag::FT_MUTABLE","description":"test get_flag_double","value":"5.12"})" +
"\n");

res = get_flag_str("get_flag_bool");
test_app = "get_flag_bool";
res = get_flag_str(test_app);
ASSERT_TRUE(res.is_ok());
ASSERT_EQ(
res.get_value(),
"{\"name\":\"get_flag_bool\",\"section\":\"flag_test\",\"type\":\"FV_BOOL\",\"tags\":"
"\"flag_tag::FT_MUTABLE\",\"description\":\"test get_flag_bool\",\"value\":\"true\"}\n");
R"({"name":")" + test_app +
R"(","section":"flag_test","type":"FV_BOOL","tags":"flag_tag::FT_MUTABLE","description":"test get_flag_bool","value":"true"})"
"\n");

res = get_flag_str("get_flag_string");
test_app = "get_flag_string";
res = get_flag_str(test_app);
ASSERT_TRUE(res.is_ok());
ASSERT_EQ(res.get_value(),
"{\"name\":\"get_flag_string\",\"section\":\"flag_test\",\"type\":\"FV_STRING\","
"\"tags\":\"flag_tag::FT_MUTABLE\",\"description\":\"test "
"get_flag_string\",\"value\":\"flag_string\"}\n");
ASSERT_EQ(
res.get_value(),
R"({"name":")" + test_app +
R"(","section":"flag_test","type":"FV_STRING","tags":"flag_tag::FT_MUTABLE","description":"test get_flag_string","value":")" +
FLAGS_get_flag_string + R"("})" + "\n");
}
} // namespace utils
} // namespace dsn

0 comments on commit dd467b7

Please sign in to comment.