Skip to content

Commit 50b921b

Browse files
Merge branch 'master' into GODRIVER-3173
2 parents 61a0fc6 + 7791095 commit 50b921b

File tree

4 files changed

+28
-26
lines changed

4 files changed

+28
-26
lines changed

bson/bson_binary_vector_spec_test.go

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ package bson
99
import (
1010
"encoding/hex"
1111
"encoding/json"
12-
"math"
1312
"os"
1413
"path"
1514
"testing"
@@ -27,13 +26,13 @@ type bsonBinaryVectorTests struct {
2726
}
2827

2928
type bsonBinaryVectorTestCase struct {
30-
Description string `json:"description"`
31-
Valid bool `json:"valid"`
32-
Vector []interface{} `json:"vector"`
33-
DtypeHex string `json:"dtype_hex"`
34-
DtypeAlias string `json:"dtype_alias"`
35-
Padding int `json:"padding"`
36-
CanonicalBson string `json:"canonical_bson"`
29+
Description string `json:"description"`
30+
Valid bool `json:"valid"`
31+
Vector json.RawMessage `json:"vector"`
32+
DtypeHex string `json:"dtype_hex"`
33+
DtypeAlias string `json:"dtype_alias"`
34+
Padding int `json:"padding"`
35+
CanonicalBson string `json:"canonical_bson"`
3736
}
3837

3938
func TestBsonBinaryVectorSpec(t *testing.T) {
@@ -83,21 +82,19 @@ func TestBsonBinaryVectorSpec(t *testing.T) {
8382
})
8483
}
8584

86-
func convertSlice[T int8 | float32 | byte](s []interface{}) []T {
85+
func decodeTestSlice[T int8 | float32 | byte](t *testing.T, data []byte) []T {
86+
t.Helper()
87+
88+
if len(data) == 0 {
89+
return nil
90+
}
91+
var s []float64
92+
err := UnmarshalExtJSON(data, true, &s)
93+
require.NoError(t, err)
94+
8795
v := make([]T, len(s))
8896
for i, e := range s {
89-
f := math.NaN()
90-
switch val := e.(type) {
91-
case float64:
92-
f = val
93-
case string:
94-
if val == "inf" {
95-
f = math.Inf(0)
96-
} else if val == "-inf" {
97-
f = math.Inf(-1)
98-
}
99-
}
100-
v[i] = T(f)
97+
v[i] = T(e)
10198
}
10299
return v
103100
}
@@ -108,17 +105,17 @@ func runBsonBinaryVectorTest(t *testing.T, testKey string, test bsonBinaryVector
108105
case "0x03":
109106
testVector[testKey] = Vector{
110107
dType: Int8Vector,
111-
int8Data: convertSlice[int8](test.Vector),
108+
int8Data: decodeTestSlice[int8](t, test.Vector),
112109
}
113110
case "0x27":
114111
testVector[testKey] = Vector{
115112
dType: Float32Vector,
116-
float32Data: convertSlice[float32](test.Vector),
113+
float32Data: decodeTestSlice[float32](t, test.Vector),
117114
}
118115
case "0x10":
119116
testVector[testKey] = Vector{
120117
dType: PackedBitVector,
121-
bitData: convertSlice[byte](test.Vector),
118+
bitData: decodeTestSlice[byte](t, test.Vector),
122119
bitPadding: uint8(test.Padding),
123120
}
124121
default:

internal/spectest/skip.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ import "testing"
1111
// skipTests is a map of "fully-qualified test name" to "the reason for skipping
1212
// the test".
1313
var skipTests = map[string][]string{
14+
// TODO(GODRIVER-3518): Test flexible numeric comparisons with $$lte
15+
"Modifies $$lte operator test to also use floating point and Int64 types (GODRIVER-3518)": {
16+
"TestUnifiedSpec/unified-test-format/tests/valid-pass/operator-lte.json/special_lte_matching_operator",
17+
},
18+
1419
// SPEC-1403: This test checks to see if the correct error is thrown when auto
1520
// encrypting with a server < 4.2. Currently, the test will fail because a
1621
// server < 4.2 wouldn't have mongocryptd, so Client construction would fail

testdata/bson-binary-vector/float32.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
{
3333
"description": "Infinity Vector FLOAT32",
3434
"valid": true,
35-
"vector": ["-inf", 0.0, "inf"],
35+
"vector": [{"$numberDouble": "-Infinity"}, 0.0, {"$numberDouble": "Infinity"}],
3636
"dtype_hex": "0x27",
3737
"dtype_alias": "FLOAT32",
3838
"padding": 0,

0 commit comments

Comments
 (0)