@@ -17,8 +17,14 @@ import (
17
17
)
18
18
19
19
func TestValue (t * testing.T ) {
20
+ t .Parallel ()
21
+
20
22
t .Run ("Validate" , func (t * testing.T ) {
23
+ t .Parallel ()
24
+
21
25
t .Run ("invalid" , func (t * testing.T ) {
26
+ t .Parallel ()
27
+
22
28
v := Value {Type : bsontype .Double , Data : []byte {0x01 , 0x02 , 0x03 , 0x04 }}
23
29
want := NewInsufficientBytesError (v .Data , v .Data )
24
30
got := v .Validate ()
@@ -27,6 +33,8 @@ func TestValue(t *testing.T) {
27
33
}
28
34
})
29
35
t .Run ("value" , func (t * testing.T ) {
36
+ t .Parallel ()
37
+
30
38
v := Value {Type : bsontype .Double , Data : AppendDouble (nil , 3.14159 )}
31
39
var want error
32
40
got := v .Validate ()
@@ -35,7 +43,10 @@ func TestValue(t *testing.T) {
35
43
}
36
44
})
37
45
})
46
+
38
47
t .Run ("IsNumber" , func (t * testing.T ) {
48
+ t .Parallel ()
49
+
39
50
testCases := []struct {
40
51
name string
41
52
val Value
@@ -50,7 +61,11 @@ func TestValue(t *testing.T) {
50
61
}
51
62
52
63
for _ , tc := range testCases {
64
+ tc := tc
65
+
53
66
t .Run (tc .name , func (t * testing.T ) {
67
+ t .Parallel ()
68
+
54
69
isnum := tc .val .IsNumber ()
55
70
if isnum != tc .isnum {
56
71
t .Errorf ("IsNumber did not return the expected boolean. got %t; want %t" , isnum , tc .isnum )
@@ -619,10 +634,19 @@ func TestValue(t *testing.T) {
619
634
nil ,
620
635
[]interface {}{primitive .NewDecimal128 (12345 , 67890 ), true },
621
636
},
637
+ {
638
+ "Timestamp.String/Success" , Value .String , Value {Type : bsontype .Timestamp , Data : AppendTimestamp (nil , 12345 , 67890 )},
639
+ nil ,
640
+ []interface {}{"{\" $timestamp\" :{\" t\" :12345,\" i\" :67890}}" },
641
+ },
622
642
}
623
643
624
644
for _ , tc := range testCases {
645
+ tc := tc
646
+
625
647
t .Run (tc .name , func (t * testing.T ) {
648
+ t .Parallel ()
649
+
626
650
defer func () {
627
651
err := recover ()
628
652
if ! cmp .Equal (err , tc .panicErr , cmp .Comparer (compareErrors )) {
0 commit comments