Skip to content

Commit 2c6aa27

Browse files
committed
removed deprecatedParseDateTime from test
1 parent 32ad982 commit 2c6aa27

File tree

1 file changed

+7
-47
lines changed

1 file changed

+7
-47
lines changed

‎utils_test.go‎

Lines changed: 7 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import (
1313
"database/sql"
1414
"database/sql/driver"
1515
"encoding/binary"
16-
"fmt"
1716
"testing"
1817
"time"
1918
)
@@ -294,23 +293,6 @@ func TestIsolationLevelMapping(t *testing.T){
294293
}
295294
}
296295

297-
funcdeprecatedParseDateTime(strstring, loc*time.Location) (t time.Time, errerror){
298-
constbase="0000-00-00 00:00:00.000000"
299-
switchlen(str){
300-
case10, 19, 21, 22, 23, 24, 25, 26: // up to "YYYY-MM-DD HH:MM:SS.MMMMMM"
301-
ifstr==base[:len(str)]{
302-
return
303-
}
304-
ifloc==time.UTC{
305-
returntime.Parse(timeFormat[:len(str)], str)
306-
}
307-
returntime.ParseInLocation(timeFormat[:len(str)], str, loc)
308-
default:
309-
err=fmt.Errorf("invalid time string: %s", str)
310-
return
311-
}
312-
}
313-
314296
funcTestParseDateTime(t*testing.T){
315297
cases:= []struct{
316298
namestring
@@ -364,9 +346,13 @@ func TestParseDateTime(t *testing.T){
364346
}{
365347
for_, cc:=rangecases{
366348
t.Run(cc.name+"-"+loc.String(), func(t*testing.T){
367-
want, err:=deprecatedParseDateTime(cc.str, loc)
368-
iferr!=nil{
369-
t.Fatal(err)
349+
varwant time.Time
350+
ifcc.str!=sDate0&&cc.str!=sDateTime0{
351+
varerrerror
352+
want, err=time.ParseInLocation(timeFormat[:len(cc.str)], cc.str, loc)
353+
iferr!=nil{
354+
t.Fatal(err)
355+
}
370356
}
371357
got, err:=parseDateTime([]byte(cc.str), loc)
372358
iferr!=nil{
@@ -449,29 +435,3 @@ func TestParseDateTimeFail(t *testing.T){
449435
})
450436
}
451437
}
452-
453-
funcBenchmarkParseDateTime(b*testing.B){
454-
str:="2020-05-13 21:30:45"
455-
loc:=time.FixedZone("test", 8*60*60)
456-
fori:=0; i<b.N; i++{
457-
_, _=deprecatedParseDateTime(str, loc)
458-
}
459-
}
460-
461-
funcBenchmarkParseByteDateTime(b*testing.B){
462-
bStr:= []byte("2020-05-25 23:22:01.159491")
463-
loc:=time.FixedZone("test", 8*60*60)
464-
b.ResetTimer()
465-
fori:=0; i<b.N; i++{
466-
_, _=parseDateTime(bStr, loc)
467-
}
468-
}
469-
470-
funcBenchmarkParseByteDateTimeStringCast(b*testing.B){
471-
bStr:= []byte("2020-05-25 23:22:01.159491")
472-
loc:=time.FixedZone("test", 8*60*60)
473-
b.ResetTimer()
474-
fori:=0; i<b.N; i++{
475-
_, _=deprecatedParseDateTime(string(bStr), loc)
476-
}
477-
}

0 commit comments

Comments
(0)