forked from microsoft/go-mssqldb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
queries_go19_amd64_test.go
43 lines (39 loc) · 1.12 KB
/
queries_go19_amd64_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package mssql
import (
"fmt"
"testing"
"time"
)
func TestDateTimeParam19(t *testing.T) {
conn, logger := open(t)
defer conn.Close()
logger.StopLogging()
// testing DateTime1, only supported on go 1.9
var emptydate time.Time
mindate1 := time.Date(1753, 1, 1, 0, 0, 0, 0, time.UTC)
maxdate1 := time.Date(9999, 12, 31, 23, 59, 59, 997000000, time.UTC)
testdates1 := []DateTime1{
DateTime1(mindate1),
DateTime1(maxdate1),
DateTime1(time.Date(1752, 12, 31, 23, 59, 59, 997000000, time.UTC)), // just a little below minimum date
DateTime1(time.Date(10000, 1, 1, 0, 0, 0, 0, time.UTC)), // just a little over maximum date
DateTime1(emptydate),
}
for _, test := range testdates1 {
t.Run(fmt.Sprintf("Test datetime for %v", test), func(t *testing.T) {
var res time.Time
expected := time.Time(test)
queryParamRoundTrip(conn, test, &res)
// clip value
if expected.Before(mindate1) {
expected = mindate1
}
if expected.After(maxdate1) {
expected = maxdate1
}
if expected.Sub(res) != 0 {
t.Errorf("expected: '%s', got: '%s' delta: %d", expected, res, expected.Sub(res))
}
})
}
}