Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
98d1a144
TDengine
项目概览
taosdata
/
TDengine
接近 2 年 前同步成功
通知
1192
Star
22018
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
98d1a144
编写于
1月 09, 2022
作者:
wmmhello
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-12252]<feature>(connector,query,insert,other,tools,taosAdapter):deal with escape character
上级
63903b26
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
63 addition
and
33 deletion
+63
-33
src/util/tests/stringTest.cpp
src/util/tests/stringTest.cpp
+63
-33
未找到文件。
src/util/tests/stringTest.cpp
浏览文件 @
98d1a144
...
...
@@ -6,53 +6,83 @@
#include "taos.h"
#include "tutil.h"
TEST
(
testCase
,
str_
rmquot
e_test
)
{
char
t1
[]
=
"
\"\"
.dd"
;
int32_t
len
=
str
Rmquot
e
(
t1
,
strlen
(
t1
));
TEST
(
testCase
,
str_
escap
e_test
)
{
char
t1
[]
=
"
\"\
\\
"
.dd"
;
int32_t
len
=
str
DealWithEscap
e
(
t1
,
strlen
(
t1
));
printf
(
"t1:%s, len:%d
\n
"
,
t1
,
len
);
EXPECT_EQ
(
3
,
len
);
EXPECT_STRCASEEQ
(
t1
,
".dd"
);
EXPECT_EQ
(
5
,
len
);
EXPECT_STRCASEEQ
(
t1
,
"
\"\"
.dd"
);
char
t2
[]
=
"
\"
fsd
\\\"
fs
\"
.dd"
;
len
=
strRmquot
e
(
t2
,
strlen
(
t2
));
char
t2
[]
=
"
'
\\\'
.dd"
;
len
=
strDealWithEscap
e
(
t2
,
strlen
(
t2
));
printf
(
"t2:%s, len:%d
\n
"
,
t2
,
len
);
EXPECT_EQ
(
9
,
len
);
EXPECT_STRCASEEQ
(
t2
,
"
fsd
\"
fs
.dd"
);
EXPECT_EQ
(
5
,
len
);
EXPECT_STRCASEEQ
(
t2
,
"
''
.dd"
);
char
t3
[]
=
"
fs
\\
_d
\\
%.d
\\
d"
;
len
=
strRmquot
e
(
t3
,
strlen
(
t3
));
char
t3
[]
=
"
\\\\
.d
d"
;
len
=
strDealWithEscap
e
(
t3
,
strlen
(
t3
));
printf
(
"t3:%s, len:%d
\n
"
,
t3
,
len
);
EXPECT_EQ
(
10
,
len
);
EXPECT_STRCASEEQ
(
t3
,
"
fs
\\
_d
\\
%
.dd"
);
EXPECT_EQ
(
4
,
len
);
EXPECT_STRCASEEQ
(
t3
,
"
\\
.dd"
);
char
t4
[]
=
"
\"
fs
\\
_d
\\
%
\"
.dd"
;
len
=
strRmquot
e
(
t4
,
strlen
(
t4
));
char
t4
[]
=
"
'
\\
n
.dd"
;
len
=
strDealWithEscap
e
(
t4
,
strlen
(
t4
));
printf
(
"t4:%s, len:%d
\n
"
,
t4
,
len
);
EXPECT_EQ
(
10
,
len
);
EXPECT_STRCASEEQ
(
t4
,
"fs
\\
_d
\\
%.dd"
);
char
t5
[]
=
"
\"
fs
\\
_d
\\
%
\"
"
;
len
=
strRmquote
(
t5
,
strlen
(
t5
));
printf
(
"t5:%s, len:%d
\n
"
,
t5
,
len
);
EXPECT_EQ
(
7
,
len
);
EXPECT_STRCASEEQ
(
t5
,
"fs
\\
_d
\\
%"
);
char
t6
[]
=
"'fs
\\
_d
\\
%'"
;
len
=
strRmquote
(
t6
,
strlen
(
t6
));
printf
(
"t6:%s, len:%d
\n
"
,
t6
,
len
);
EXPECT_EQ
(
7
,
len
);
EXPECT_STRCASEEQ
(
t6
,
"fs
\\
_d
\\
%"
);
EXPECT_EQ
(
4
,
len
);
EXPECT_STRCASEEQ
(
t4
,
"
\n
.dd"
);
// char t2[] = "\"fsd\\\"fs\".dd";
// len = strDealWithEscape(t2, strlen(t2));
// printf("t2:%s, len:%d\n", t2, len);
// EXPECT_EQ(11, len);
// EXPECT_STRCASEEQ(t2, "\"fsd\"fs\".dd");
//
// char t3[] = "fs\\_d\\%.d\\d";
// len = strRmquote(t3, strlen(t3));
// printf("t3:%s, len:%d\n", t3, len);
// EXPECT_EQ(10, len);
// EXPECT_STRCASEEQ(t3, "fs\\_d\\%.dd");
//
// char t4[] = "\"fs\\_d\\%\".dd";
// len = strRmquote(t4, strlen(t4));
// printf("t4:%s, len:%d\n", t4, len);
// EXPECT_EQ(10, len);
// EXPECT_STRCASEEQ(t4, "fs\\_d\\%.dd");
//
// char t5[] = "\"fs\\_d\\%\"";
// len = strRmquote(t5, strlen(t5));
// printf("t5:%s, len:%d\n", t5, len);
// EXPECT_EQ(7, len);
// EXPECT_STRCASEEQ(t5, "fs\\_d\\%");
//
// char t6[] = "'fs\\_d\\%'";
// len = strRmquote(t6, strlen(t6));
// printf("t6:%s, len:%d\n", t6, len);
// EXPECT_EQ(7, len);
// EXPECT_STRCASEEQ(t6, "fs\\_d\\%");
}
TEST
(
testCase
,
string_dequote_test
)
{
char
t1
[]
=
"'abc'"
;
int32_t
len
=
strdequote
(
t1
);
char
t1
[]
=
"'ab''c'"
;
int32_t
len
=
stringProcess
(
t1
,
strlen
(
t1
));
EXPECT_EQ
(
4
,
len
);
EXPECT_STRCASEEQ
(
t1
,
"ab'c"
);
char
t2
[]
=
"
\"
ab
\"\"
c
\"
"
;
len
=
stringProcess
(
t2
,
strlen
(
t2
));
EXPECT_EQ
(
4
,
len
);
EXPECT_STRCASEEQ
(
t1
,
"ab
\"
c"
);
char
t3
[]
=
"`ab``c`"
;
len
=
stringProcess
(
t3
,
strlen
(
t3
));
EXPECT_EQ
(
3
,
len
);
EXPECT_STRCASEEQ
(
t1
,
"abc"
);
EXPECT_STRCASEEQ
(
t1
,
"ab
`
c"
);
char
t2
[]
=
"
\"
abc
\"
"
;
len
=
str
dequote
(
t2
);
len
=
str
ingProcess
(
t2
,
strlen
(
t2
)
);
EXPECT_EQ
(
3
,
len
);
EXPECT_STRCASEEQ
(
t1
,
"abc"
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录