Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
2f97bd24
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22017
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
2f97bd24
编写于
2月 21, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
unitest for config
上级
48a2d415
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
193 addition
and
68 deletion
+193
-68
include/libs/config/config.h
include/libs/config/config.h
+8
-4
source/libs/config/inc/cfgInt.h
source/libs/config/inc/cfgInt.h
+1
-1
source/libs/config/src/config.c
source/libs/config/src/config.c
+93
-12
source/libs/config/test/cfgTest.cpp
source/libs/config/test/cfgTest.cpp
+91
-51
未找到文件。
include/libs/config/config.h
浏览文件 @
2f97bd24
...
...
@@ -25,12 +25,12 @@ extern "C" {
typedef
enum
{
CFG_TYPE_DEFAULT
,
CFG_TYPE_
TAOS_CFG
,
CFG_TYPE_
CFG_FILE
,
CFG_TYPE_DOT_ENV
,
CFG_TYPE_ENV_VAR
,
CFG_TYPE_APOLLO_URL
,
CFG_TYPE_CONSOLE_PARA
}
ECfgType
;
}
ECfg
Src
Type
;
typedef
enum
{
CFG_DTYPE_NONE
,
...
...
@@ -63,7 +63,7 @@ typedef enum {
}
ECfgUnitType
;
typedef
struct
SConfigItem
{
ECfg
Type
stype
;
ECfg
SrcType
stype
;
ECfgUnitType
utype
;
ECfgDataType
dtype
;
char
*
name
;
...
...
@@ -90,7 +90,7 @@ typedef struct SConfigItem {
typedef
struct
SConfig
SConfig
;
SConfig
*
cfgInit
();
int32_t
cfgLoad
(
SConfig
*
pConfig
,
ECfgType
cfgType
,
const
char
*
sourceStr
);
int32_t
cfgLoad
(
SConfig
*
pConfig
,
ECfg
Src
Type
cfgType
,
const
char
*
sourceStr
);
void
cfgCleanup
(
SConfig
*
pConfig
);
int32_t
cfgGetSize
(
SConfig
*
pConfig
);
...
...
@@ -115,6 +115,10 @@ int32_t cfgAddIpStr(SConfig *pConfig, const char *name, const char *defaultVal,
int32_t
cfgAddDir
(
SConfig
*
pConfig
,
const
char
*
name
,
const
char
*
defaultVal
,
ECfgUnitType
utype
);
int32_t
cfgAddFile
(
SConfig
*
pConfig
,
const
char
*
name
,
const
char
*
defaultVal
,
ECfgUnitType
utype
);
const
char
*
cfgStypeStr
(
ECfgSrcType
type
);
const
char
*
cfgDtypeStr
(
ECfgDataType
type
);
const
char
*
cfgUtypeStr
(
ECfgUnitType
type
);
#ifdef __cplusplus
}
#endif
...
...
source/libs/config/inc/cfgInt.h
浏览文件 @
2f97bd24
...
...
@@ -27,7 +27,7 @@ extern "C" {
#endif
typedef
struct
SConfig
{
ECfgType
stype
;
ECfg
Src
Type
stype
;
SHashObj
*
hash
;
}
SConfig
;
...
...
source/libs/config/src/config.c
浏览文件 @
2f97bd24
...
...
@@ -33,9 +33,9 @@ SConfig *cfgInit() {
return
pConfig
;
}
int32_t
cfgLoad
(
SConfig
*
pConfig
,
ECfgType
cfgType
,
const
char
*
sourceStr
)
{
int32_t
cfgLoad
(
SConfig
*
pConfig
,
ECfg
Src
Type
cfgType
,
const
char
*
sourceStr
)
{
switch
(
cfgType
)
{
case
CFG_TYPE_
TAOS_CFG
:
case
CFG_TYPE_
CFG_FILE
:
return
cfgLoadFromTaosFile
(
pConfig
,
sourceStr
);
case
CFG_TYPE_DOT_ENV
:
return
cfgLoadFromDotEnvFile
(
pConfig
,
sourceStr
);
...
...
@@ -49,10 +49,12 @@ int32_t cfgLoad(SConfig *pConfig, ECfgType cfgType, const char *sourceStr) {
}
void
cfgCleanup
(
SConfig
*
pConfig
)
{
if
(
pConfig
==
NULL
)
return
;
if
(
pConfig
->
hash
!=
NULL
)
{
taosHashCleanup
(
pConfig
->
hash
);
pConfig
->
hash
==
NULL
;
if
(
pConfig
!=
NULL
)
{
if
(
pConfig
->
hash
!=
NULL
)
{
taosHashCleanup
(
pConfig
->
hash
);
pConfig
->
hash
==
NULL
;
}
free
(
pConfig
);
}
}
...
...
@@ -68,7 +70,7 @@ static int32_t cfgAddItem(SConfig *pConfig, SConfigItem *pItem, const char *name
pItem
->
stype
=
CFG_TYPE_DEFAULT
;
pItem
->
utype
=
utype
;
pItem
->
name
=
strdup
(
name
);
if
(
pItem
->
name
!
=
NULL
)
{
if
(
pItem
->
name
=
=
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
...
...
@@ -152,7 +154,7 @@ int32_t cfgAddDouble(SConfig *pConfig, const char *name, double defaultVal, ECfg
int32_t
cfgAddString
(
SConfig
*
pConfig
,
const
char
*
name
,
const
char
*
defaultVal
,
ECfgUnitType
utype
)
{
SConfigItem
item
=
{.
dtype
=
CFG_DTYPE_STRING
};
item
.
strVal
=
strdup
(
defaultVal
);
if
(
item
.
strVal
!
=
NULL
)
{
if
(
item
.
strVal
=
=
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
...
...
@@ -162,7 +164,7 @@ int32_t cfgAddString(SConfig *pConfig, const char *name, const char *defaultVal,
int32_t
cfgAddFqdn
(
SConfig
*
pConfig
,
const
char
*
name
,
const
char
*
defaultVal
,
ECfgUnitType
utype
)
{
SConfigItem
item
=
{.
dtype
=
CFG_DTYPE_FQDN
};
item
.
fqdnVal
=
strdup
(
defaultVal
);
if
(
item
.
fqdnVal
!
=
NULL
)
{
if
(
item
.
fqdnVal
=
=
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
...
...
@@ -172,7 +174,7 @@ int32_t cfgAddFqdn(SConfig *pConfig, const char *name, const char *defaultVal, E
int32_t
cfgAddIpStr
(
SConfig
*
pConfig
,
const
char
*
name
,
const
char
*
defaultVal
,
ECfgUnitType
utype
)
{
SConfigItem
item
=
{.
dtype
=
CFG_DTYPE_IPSTR
};
item
.
ipstrVal
=
strdup
(
defaultVal
);
if
(
item
.
ipstrVal
!
=
NULL
)
{
if
(
item
.
ipstrVal
=
=
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
...
...
@@ -182,7 +184,7 @@ int32_t cfgAddIpStr(SConfig *pConfig, const char *name, const char *defaultVal,
int32_t
cfgAddDir
(
SConfig
*
pConfig
,
const
char
*
name
,
const
char
*
defaultVal
,
ECfgUnitType
utype
)
{
SConfigItem
item
=
{.
dtype
=
CFG_DTYPE_DIR
};
item
.
dirVal
=
strdup
(
defaultVal
);
if
(
item
.
dirVal
!
=
NULL
)
{
if
(
item
.
dirVal
=
=
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
...
...
@@ -192,9 +194,88 @@ int32_t cfgAddDir(SConfig *pConfig, const char *name, const char *defaultVal, EC
int32_t
cfgAddFile
(
SConfig
*
pConfig
,
const
char
*
name
,
const
char
*
defaultVal
,
ECfgUnitType
utype
)
{
SConfigItem
item
=
{.
dtype
=
CFG_DTYPE_FILE
};
item
.
fileVal
=
strdup
(
defaultVal
);
if
(
item
.
fileVal
!
=
NULL
)
{
if
(
item
.
fileVal
=
=
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
return
cfgAddItem
(
pConfig
,
&
item
,
name
,
utype
);
}
const
char
*
cfgStypeStr
(
ECfgSrcType
type
)
{
switch
(
type
)
{
case
CFG_TYPE_DEFAULT
:
return
"default"
;
case
CFG_TYPE_CFG_FILE
:
return
"cfg"
;
case
CFG_TYPE_DOT_ENV
:
return
".env"
;
case
CFG_TYPE_ENV_VAR
:
return
"env"
;
case
CFG_TYPE_APOLLO_URL
:
return
"apollo"
;
default:
return
"invalid"
;
}
}
const
char
*
cfgDtypeStr
(
ECfgDataType
type
)
{
switch
(
type
)
{
case
CFG_DTYPE_NONE
:
return
"none"
;
case
CFG_DTYPE_BOOL
:
return
"bool"
;
case
CFG_DTYPE_INT8
:
return
"int8"
;
case
CFG_DTYPE_UINT8
:
return
"uint8"
;
case
CFG_DTYPE_INT16
:
return
"int16"
;
case
CFG_DTYPE_UINT16
:
return
"uint16"
;
case
CFG_DTYPE_INT32
:
return
"int32"
;
case
CFG_DTYPE_UINT32
:
return
"uint32"
;
case
CFG_DTYPE_INT64
:
return
"int64"
;
case
CFG_DTYPE_UINT64
:
return
"uint64"
;
case
CFG_DTYPE_FLOAT
:
return
"float"
;
case
CFG_DTYPE_DOUBLE
:
return
"double"
;
case
CFG_DTYPE_STRING
:
return
"string"
;
case
CFG_DTYPE_FQDN
:
return
"fqdn"
;
case
CFG_DTYPE_IPSTR
:
return
"ipstr"
;
case
CFG_DTYPE_DIR
:
return
"dir"
;
case
CFG_DTYPE_FILE
:
return
"file"
;
default:
return
"invalid"
;
}
}
const
char
*
cfgUtypeStr
(
ECfgUnitType
type
)
{
switch
(
type
)
{
case
CFG_UTYPE_NONE
:
return
""
;
case
CFG_UTYPE_PERCENT
:
return
"(%)"
;
case
CFG_UTYPE_GB
:
return
"(GB)"
;
case
CFG_UTYPE_MB
:
return
"(Mb)"
;
case
CFG_UTYPE_BYTE
:
return
"(byte)"
;
case
CFG_UTYPE_SECOND
:
return
"(s)"
;
case
CFG_UTYPE_MS
:
return
"(ms)"
;
default:
return
"invalid"
;
}
}
\ No newline at end of file
source/libs/config/test/cfgTest.cpp
浏览文件 @
2f97bd24
...
...
@@ -28,84 +28,124 @@ class CfgTest : public ::testing::Test {
const
char
*
CfgTest
::
pConfig
;
TEST_F
(
CfgTest
,
01
_Basic
)
{
TEST_F
(
CfgTest
,
02
_Str
)
{
EXPECT_STREQ
(
cfgStypeStr
(
CFG_TYPE_DEFAULT
),
"default"
);
EXPECT_STREQ
(
cfgStypeStr
(
CFG_TYPE_CFG_FILE
),
"cfg"
);
EXPECT_STREQ
(
cfgStypeStr
(
CFG_TYPE_DOT_ENV
),
".env"
);
EXPECT_STREQ
(
cfgStypeStr
(
CFG_TYPE_ENV_VAR
),
"env"
);
EXPECT_STREQ
(
cfgStypeStr
(
CFG_TYPE_APOLLO_URL
),
"apollo"
);
EXPECT_STREQ
(
cfgStypeStr
(
ECfgSrcType
(
1024
)),
"invalid"
);
EXPECT_STREQ
(
cfgDtypeStr
(
CFG_DTYPE_NONE
),
"none"
);
EXPECT_STREQ
(
cfgDtypeStr
(
CFG_DTYPE_BOOL
),
"bool"
);
EXPECT_STREQ
(
cfgDtypeStr
(
CFG_DTYPE_INT8
),
"int8"
);
EXPECT_STREQ
(
cfgDtypeStr
(
CFG_DTYPE_UINT8
),
"uint8"
);
EXPECT_STREQ
(
cfgDtypeStr
(
CFG_DTYPE_INT16
),
"int16"
);
EXPECT_STREQ
(
cfgDtypeStr
(
CFG_DTYPE_UINT16
),
"uint16"
);
EXPECT_STREQ
(
cfgDtypeStr
(
CFG_DTYPE_INT32
),
"int32"
);
EXPECT_STREQ
(
cfgDtypeStr
(
CFG_DTYPE_UINT32
),
"uint32"
);
EXPECT_STREQ
(
cfgDtypeStr
(
CFG_DTYPE_INT64
),
"int64"
);
EXPECT_STREQ
(
cfgDtypeStr
(
CFG_DTYPE_UINT64
),
"uint64"
);
EXPECT_STREQ
(
cfgDtypeStr
(
CFG_DTYPE_FLOAT
),
"float"
);
EXPECT_STREQ
(
cfgDtypeStr
(
CFG_DTYPE_DOUBLE
),
"double"
);
EXPECT_STREQ
(
cfgDtypeStr
(
CFG_DTYPE_STRING
),
"string"
);
EXPECT_STREQ
(
cfgDtypeStr
(
CFG_DTYPE_FQDN
),
"fqdn"
);
EXPECT_STREQ
(
cfgDtypeStr
(
CFG_DTYPE_IPSTR
),
"ipstr"
);
EXPECT_STREQ
(
cfgDtypeStr
(
CFG_DTYPE_DIR
),
"dir"
);
EXPECT_STREQ
(
cfgDtypeStr
(
CFG_DTYPE_FILE
),
"file"
);
EXPECT_STREQ
(
cfgDtypeStr
(
ECfgDataType
(
1024
)),
"invalid"
);
EXPECT_STREQ
(
cfgUtypeStr
(
CFG_UTYPE_NONE
),
""
);
EXPECT_STREQ
(
cfgUtypeStr
(
CFG_UTYPE_PERCENT
),
"(%)"
);
EXPECT_STREQ
(
cfgUtypeStr
(
CFG_UTYPE_GB
),
"(GB)"
);
EXPECT_STREQ
(
cfgUtypeStr
(
CFG_UTYPE_MB
),
"(Mb)"
);
EXPECT_STREQ
(
cfgUtypeStr
(
CFG_UTYPE_BYTE
),
"(byte)"
);
EXPECT_STREQ
(
cfgUtypeStr
(
CFG_UTYPE_SECOND
),
"(s)"
);
EXPECT_STREQ
(
cfgUtypeStr
(
CFG_UTYPE_MS
),
"(ms)"
);
EXPECT_STREQ
(
cfgUtypeStr
(
ECfgUnitType
(
1024
)),
"invalid"
);
}
TEST_F
(
CfgTest
,
02
_Basic
)
{
SConfig
*
pConfig
=
cfgInit
();
cfgAddBool
(
pConfig
,
"test_bool"
,
0
,
CFG_UTYPE_NONE
);
cfgAddInt8
(
pConfig
,
"test_int8"
,
1
,
CFG_UTYPE_GB
);
cfgAddUInt8
(
pConfig
,
"test_uint8"
,
2
,
CFG_UTYPE_MB
);
cfgAddInt16
(
pConfig
,
"test_int16"
,
3
,
CFG_UTYPE_BYTE
);
cfgAddUInt16
(
pConfig
,
"test_uint16"
,
4
,
CFG_UTYPE_SECOND
);
cfgAddInt32
(
pConfig
,
"test_int32"
,
5
,
CFG_UTYPE_MS
);
cfgAddUInt32
(
pConfig
,
"test_uint32"
,
6
,
CFG_UTYPE_PERCENT
);
cfgAddInt64
(
pConfig
,
"test_int64"
,
7
,
CFG_UTYPE_NONE
);
cfgAddUInt64
(
pConfig
,
"test_uint64"
,
8
,
CFG_UTYPE_NONE
);
cfgAddFloat
(
pConfig
,
"test_float"
,
9
,
CFG_UTYPE_NONE
);
cfgAddDouble
(
pConfig
,
"test_double"
,
10
,
CFG_UTYPE_NONE
);
cfgAddString
(
pConfig
,
"test_string"
,
"11"
,
CFG_UTYPE_NONE
);
cfgAddFqdn
(
pConfig
,
"test_fqdn"
,
"localhost"
,
CFG_UTYPE_NONE
);
cfgAddIpStr
(
pConfig
,
"test_ipstr"
,
"192.168.0.1"
,
CFG_UTYPE_NONE
);
cfgAddDir
(
pConfig
,
"test_dir"
,
"/tmp"
,
CFG_UTYPE_NONE
);
cfgAddFile
(
pConfig
,
"test_file"
,
"/tmp/file1"
,
CFG_UTYPE_NONE
);
ASSERT_NE
(
pConfig
,
nullptr
);
EXPECT_EQ
(
cfgAddBool
(
pConfig
,
"test_bool"
,
0
,
CFG_UTYPE_NONE
),
0
);
EXPECT_EQ
(
cfgAddInt8
(
pConfig
,
"test_int8"
,
1
,
CFG_UTYPE_GB
),
0
);
EXPECT_EQ
(
cfgAddUInt8
(
pConfig
,
"test_uint8"
,
2
,
CFG_UTYPE_MB
),
0
);
EXPECT_EQ
(
cfgAddInt16
(
pConfig
,
"test_int16"
,
3
,
CFG_UTYPE_BYTE
),
0
);
EXPECT_EQ
(
cfgAddUInt16
(
pConfig
,
"test_uint16"
,
4
,
CFG_UTYPE_SECOND
),
0
);
EXPECT_EQ
(
cfgAddInt32
(
pConfig
,
"test_int32"
,
5
,
CFG_UTYPE_MS
),
0
);
EXPECT_EQ
(
cfgAddUInt32
(
pConfig
,
"test_uint32"
,
6
,
CFG_UTYPE_PERCENT
),
0
);
EXPECT_EQ
(
cfgAddInt64
(
pConfig
,
"test_int64"
,
7
,
CFG_UTYPE_NONE
),
0
);
EXPECT_EQ
(
cfgAddUInt64
(
pConfig
,
"test_uint64"
,
8
,
CFG_UTYPE_NONE
),
0
);
EXPECT_EQ
(
cfgAddFloat
(
pConfig
,
"test_float"
,
9
,
CFG_UTYPE_NONE
),
0
);
EXPECT_EQ
(
cfgAddDouble
(
pConfig
,
"test_double"
,
10
,
CFG_UTYPE_NONE
),
0
);
EXPECT_EQ
(
cfgAddString
(
pConfig
,
"test_string"
,
"11"
,
CFG_UTYPE_NONE
),
0
);
EXPECT_EQ
(
cfgAddFqdn
(
pConfig
,
"test_fqdn"
,
"localhost"
,
CFG_UTYPE_NONE
),
0
);
EXPECT_EQ
(
cfgAddIpStr
(
pConfig
,
"test_ipstr"
,
"192.168.0.1"
,
CFG_UTYPE_NONE
),
0
);
EXPECT_EQ
(
cfgAddDir
(
pConfig
,
"test_dir"
,
"/tmp"
,
CFG_UTYPE_NONE
),
0
);
EXPECT_EQ
(
cfgAddFile
(
pConfig
,
"test_file"
,
"/tmp/file1"
,
CFG_UTYPE_NONE
),
0
);
EXPECT_EQ
(
cfgGetSize
(
pConfig
),
16
);
int32_t
size
=
0
;
SConfigItem
*
pItem
=
cfgIterate
(
pConfig
,
NULL
);
while
(
pItem
!=
NULL
)
{
pItem
=
cfgIterate
(
pConfig
,
pItem
);
switch
(
pItem
->
dtype
)
{
case
CFG_DTYPE_BOOL
:
printf
(
"
cfg:%s, value:%d
\n
"
,
pItem
->
name
,
pItem
->
boolVal
);
printf
(
"
index:%d, cfg:%s value:%d
\n
"
,
size
,
pItem
->
name
,
pItem
->
boolVal
);
break
;
CFG_DTYPE_INT8:
printf
(
"
cfg:%s, value:%d
\n
"
,
pItem
->
name
,
pItem
->
uint8Val
);
case
CFG_DTYPE_INT8
:
printf
(
"
index:%d, cfg:%s value:%d
\n
"
,
size
,
pItem
->
name
,
pItem
->
uint8Val
);
break
;
CFG_DTYPE_UINT8:
printf
(
"
cfg:%s, value:%d
\n
"
,
pItem
->
name
,
pItem
->
int8Val
);
case
CFG_DTYPE_UINT8
:
printf
(
"
index:%d, cfg:%s value:%d
\n
"
,
size
,
pItem
->
name
,
pItem
->
int8Val
);
break
;
CFG_DTYPE_INT16:
printf
(
"
cfg:%s, value:%d
\n
"
,
pItem
->
name
,
pItem
->
uint16Val
);
case
CFG_DTYPE_INT16
:
printf
(
"
index:%d, cfg:%s value:%d
\n
"
,
size
,
pItem
->
name
,
pItem
->
uint16Val
);
break
;
CFG_DTYPE_UINT16:
printf
(
"
cfg:%s, value:%d
\n
"
,
pItem
->
name
,
pItem
->
int16Val
);
case
CFG_DTYPE_UINT16
:
printf
(
"
index:%d, cfg:%s value:%d
\n
"
,
size
,
pItem
->
name
,
pItem
->
int16Val
);
break
;
CFG_DTYPE_INT32:
printf
(
"
cfg:%s, value:%d
\n
"
,
pItem
->
name
,
pItem
->
uint32Val
);
case
CFG_DTYPE_INT32
:
printf
(
"
index:%d, cfg:%s value:%d
\n
"
,
size
,
pItem
->
name
,
pItem
->
uint32Val
);
break
;
CFG_DTYPE_UINT32:
printf
(
"
cfg:%s, value:%d
\n
"
,
pItem
->
name
,
pItem
->
int32Val
);
case
CFG_DTYPE_UINT32
:
printf
(
"
index:%d, cfg:%s value:%d
\n
"
,
size
,
pItem
->
name
,
pItem
->
int32Val
);
break
;
CFG_DTYPE_INT64:
printf
(
"
cfg:%s, value:%"
PRIu64
,
pItem
->
name
,
pItem
->
uint64Val
);
case
CFG_DTYPE_INT64
:
printf
(
"
index:%d, cfg:%s value:%"
PRIu64
"
\n
"
,
size
,
pItem
->
name
,
pItem
->
uint64Val
);
break
;
CFG_DTYPE_UINT64:
printf
(
"
cfg:%s, value:%"
PRId64
,
pItem
->
name
,
pItem
->
int64Val
);
case
CFG_DTYPE_UINT64
:
printf
(
"
index:%d, cfg:%s value:%"
PRId64
"
\n
"
,
size
,
pItem
->
name
,
pItem
->
int64Val
);
break
;
CFG_DTYPE_FLOAT:
printf
(
"
cfg:%s, value:%f
\n
"
,
pItem
->
name
,
pItem
->
floatVal
);
case
CFG_DTYPE_FLOAT
:
printf
(
"
index:%d, cfg:%s value:%f
\n
"
,
size
,
pItem
->
name
,
pItem
->
floatVal
);
break
;
CFG_DTYPE_DOUBLE:
printf
(
"
cfg:%s, value:%f
\n
"
,
pItem
->
name
,
pItem
->
doubleVal
);
case
CFG_DTYPE_DOUBLE
:
printf
(
"
index:%d, cfg:%s value:%f
\n
"
,
size
,
pItem
->
name
,
pItem
->
doubleVal
);
break
;
CFG_DTYPE_STRING:
printf
(
"
cfg:%s, value:%s
\n
"
,
pItem
->
name
,
pItem
->
strVal
);
case
CFG_DTYPE_STRING
:
printf
(
"
index:%d, cfg:%s value:%s
\n
"
,
size
,
pItem
->
name
,
pItem
->
strVal
);
break
;
CFG_DTYPE_FQDN:
printf
(
"
cfg:%s, value:%s
\n
"
,
pItem
->
name
,
pItem
->
fqdnVal
);
case
CFG_DTYPE_FQDN
:
printf
(
"
index:%d, cfg:%s value:%s
\n
"
,
size
,
pItem
->
name
,
pItem
->
fqdnVal
);
break
;
CFG_DTYPE_IPSTR:
printf
(
"
cfg:%s, value:%s
\n
"
,
pItem
->
name
,
pItem
->
ipstrVal
);
case
CFG_DTYPE_IPSTR
:
printf
(
"
index:%d, cfg:%s value:%s
\n
"
,
size
,
pItem
->
name
,
pItem
->
ipstrVal
);
break
;
CFG_DTYPE_DIR:
printf
(
"
cfg:%s, value:%s
\n
"
,
pItem
->
name
,
pItem
->
dirVal
);
case
CFG_DTYPE_DIR
:
printf
(
"
index:%d, cfg:%s value:%s
\n
"
,
size
,
pItem
->
name
,
pItem
->
dirVal
);
break
;
CFG_DTYPE_FILE:
printf
(
"
cfg:%s, value:%s
\n
"
,
pItem
->
name
,
pItem
->
fileVal
);
case
CFG_DTYPE_FILE
:
printf
(
"
index:%d, cfg:%s value:%s
\n
"
,
size
,
pItem
->
name
,
pItem
->
fileVal
);
break
;
default:
printf
(
"index:%d, cfg:%s invalid cfg dtype:%d
\n
"
,
size
,
pItem
->
name
,
pItem
->
dtype
);
break
;
}
size
++
;
pItem
=
cfgIterate
(
pConfig
,
pItem
);
}
cfgCancelIterate
(
pConfig
,
pItem
);
...
...
@@ -162,8 +202,8 @@ TEST_F(CfgTest, 01_Basic) {
pItem
=
cfgGetItem
(
pConfig
,
"test_int64"
);
EXPECT_EQ
(
pItem
->
stype
,
CFG_TYPE_DEFAULT
);
EXPECT_EQ
(
pItem
->
utype
,
CFG_UTYPE_
SECOND
);
EXPECT_EQ
(
pItem
->
dtype
,
CFG_
UTYPE_NONE
);
EXPECT_EQ
(
pItem
->
utype
,
CFG_UTYPE_
NONE
);
EXPECT_EQ
(
pItem
->
dtype
,
CFG_
DTYPE_INT64
);
EXPECT_STREQ
(
pItem
->
name
,
"test_int64"
);
EXPECT_EQ
(
pItem
->
int64Val
,
7
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录