Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
f56027da
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
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看板
提交
f56027da
编写于
7月 29, 2021
作者:
G
Ganlin Zhao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-5505]<fix>: add test cases
上级
02f88d54
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
26 addition
and
5 deletion
+26
-5
src/os/src/detail/osTime.c
src/os/src/detail/osTime.c
+2
-2
src/query/tests/unitTest.cpp
src/query/tests/unitTest.cpp
+24
-3
未找到文件。
src/os/src/detail/osTime.c
浏览文件 @
f56027da
...
...
@@ -100,8 +100,8 @@ int32_t taosParseTime(char* timestr, int64_t* time, int32_t len, int32_t timePre
if
(
strnchr
(
timestr
,
'T'
,
len
,
false
)
!=
NULL
)
{
return
parseTimeWithTz
(
timestr
,
time
,
timePrec
,
'T'
);
}
else
if
(
strnchr
(
timestr
,
' '
,
len
,
false
)
!=
NULL
&&
(
strnchr
(
seg
,
'Z'
,
len
,
false
)
!=
NULL
||
strnchr
(
seg
,
'z'
,
len
,
false
)
!=
NULL
||
strnchr
(
seg
,
'+'
,
len
,
false
)
!=
NULL
||
strnchr
(
seg
,
'-'
,
len
,
false
)
!=
NULL
))
{
(
strnchr
(
seg
,
'Z'
,
strlen
(
seg
),
false
)
!=
NULL
||
strnchr
(
seg
,
'z'
,
strlen
(
seg
)
,
false
)
!=
NULL
||
strnchr
(
seg
,
'+'
,
strlen
(
seg
),
false
)
!=
NULL
||
strnchr
(
seg
,
'-'
,
strlen
(
seg
)
,
false
)
!=
NULL
))
{
return
parseTimeWithTz
(
timestr
,
time
,
timePrec
,
' '
);
}
else
{
return
(
*
parseLocaltimeFp
[
day_light
])(
timestr
,
time
,
timePrec
);
...
...
src/query/tests/unitTest.cpp
浏览文件 @
f56027da
...
...
@@ -407,11 +407,33 @@ TEST(testCase, parse_time) {
taosParseTime
(
t41
,
&
time
,
strlen
(
t41
),
TSDB_TIME_PRECISION_MILLI
,
0
);
EXPECT_EQ
(
time
,
852048000999
);
int64_t
k
=
timezone
;
char
t42
[]
=
"1997-1-1T0:0:0.999999999Z"
;
taosParseTime
(
t42
,
&
time
,
strlen
(
t42
),
TSDB_TIME_PRECISION_MILLI
,
0
);
EXPECT_EQ
(
time
,
852048000999
-
timezone
*
MILLISECOND_PER_SECOND
);
// "%Y-%m-%d %H:%M:%S" format with TimeZone appendix is also treated as legal
// and TimeZone will be processed
char
t60
[]
=
"2017-4-3 1:1:2.980"
;
char
t61
[]
=
"2017-4-3 2:1:2.98+9:00"
;
taosParseTime
(
t60
,
&
time
,
strlen
(
t60
),
TSDB_TIME_PRECISION_MILLI
,
0
);
taosParseTime
(
t61
,
&
time1
,
strlen
(
t61
),
TSDB_TIME_PRECISION_MILLI
,
0
);
EXPECT_EQ
(
time
,
time1
);
char
t62
[]
=
"2017-4-3 2:1:2.98+09:00"
;
taosParseTime
(
t62
,
&
time
,
strlen
(
t62
),
TSDB_TIME_PRECISION_MILLI
,
0
);
taosParseTime
(
t61
,
&
time1
,
strlen
(
t61
),
TSDB_TIME_PRECISION_MILLI
,
0
);
EXPECT_EQ
(
time
,
time1
);
char
t63
[]
=
"2017-4-3 2:1:2.98+0900"
;
taosParseTime
(
t63
,
&
time
,
strlen
(
t63
),
TSDB_TIME_PRECISION_MILLI
,
0
);
taosParseTime
(
t62
,
&
time1
,
strlen
(
t62
),
TSDB_TIME_PRECISION_MILLI
,
0
);
EXPECT_EQ
(
time
,
time1
);
char
t64
[]
=
"2017-4-2 17:1:2.98Z"
;
taosParseTime
(
t63
,
&
time
,
strlen
(
t63
),
TSDB_TIME_PRECISION_MILLI
,
0
);
taosParseTime
(
t64
,
&
time1
,
strlen
(
t64
),
TSDB_TIME_PRECISION_MILLI
,
0
);
EXPECT_EQ
(
time
,
time1
);
////////////////////////////////////////////////////////////////////
// illegal timestamp format
char
t15
[]
=
"2017-12-33 0:0:0"
;
...
...
@@ -430,8 +452,7 @@ TEST(testCase, parse_time) {
EXPECT_EQ
(
taosParseTime
(
t19
,
&
time
,
strlen
(
t19
),
TSDB_TIME_PRECISION_MILLI
,
0
),
-
1
);
char
t20
[]
=
"2017-12-31 9:0:0.1+12:99"
;
EXPECT_EQ
(
taosParseTime
(
t20
,
&
time
,
strlen
(
t20
),
TSDB_TIME_PRECISION_MILLI
,
0
),
0
);
EXPECT_EQ
(
time
,
1514682000100
);
EXPECT_EQ
(
taosParseTime
(
t20
,
&
time
,
strlen
(
t20
),
TSDB_TIME_PRECISION_MILLI
,
0
),
-
1
);
char
t21
[]
=
"2017-12-31T9:0:0.1+12:99"
;
EXPECT_EQ
(
taosParseTime
(
t21
,
&
time
,
strlen
(
t21
),
TSDB_TIME_PRECISION_MILLI
,
0
),
-
1
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录