add unittest case

This commit is contained in:
groot 2019-11-22 19:35:42 +08:00
parent e40c067400
commit d3ab5ffa40

View File

@ -25,6 +25,8 @@
#include "utils/StringHelpFunctions.h"
#include "utils/ValidationUtil.h"
#include <limits>
namespace {
static constexpr uint64_t KB = 1024;
@ -63,9 +65,21 @@ TEST_F(ConfigTest, CONFIG_TEST) {
int64_t port = server_config.GetInt64Value("port");
ASSERT_NE(port, 0);
server_config.SetValue("test", "2.5");
double test = server_config.GetDoubleValue("test");
ASSERT_EQ(test, 2.5);
server_config.SetValue("float_test", "2.5");
double dbl = server_config.GetDoubleValue("float_test");
ASSERT_LE(abs(dbl - 2.5), std::numeric_limits<double>::epsilon());
float flt = server_config.GetFloatValue("float_test");
ASSERT_LE(abs(flt - 2.5), std::numeric_limits<float>::epsilon());
server_config.SetValue("bool_test", "true");
bool blt = server_config.GetBoolValue("bool_test");
ASSERT_TRUE(blt);
server_config.SetValue("int_test", "34");
int32_t it32 = server_config.GetInt32Value("int_test");
ASSERT_EQ(it32, 34);
int64_t it64 = server_config.GetInt64Value("int_test");
ASSERT_EQ(it64, 34);
milvus::server::ConfigNode fake;
server_config.AddChild("fake", fake);