Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 21 additions & 8 deletions internal/integration/unified/matches.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,19 +242,32 @@ func evaluateSpecialComparison(ctx context.Context, assertionDoc bson.Raw, actua
return fmt.Errorf("expected lsid %v, got %v", expectedID, actualID)
}
case "$$lte":
if assertionVal.Type != bson.TypeInt32 && assertionVal.Type != bson.TypeInt64 {
return fmt.Errorf("expected assertionVal to be an Int32 or Int64 but got a %s", assertionVal.Type)
if assertionVal.Type != bson.TypeInt32 && assertionVal.Type != bson.TypeInt64 && assertionVal.Type != bson.TypeDouble {
return fmt.Errorf("expected assertionVal to be an Int32, Int64, or Double but got a %s", assertionVal.Type)
}
if actual.Type != bson.TypeInt32 && actual.Type != bson.TypeInt64 {
return fmt.Errorf("expected value to be an Int32 or Int64 but got a %s", actual.Type)
if actual.Type != bson.TypeInt32 && actual.Type != bson.TypeInt64 && assertionVal.Type != bson.TypeDouble {
return fmt.Errorf("expected value to be an Int32, Int64, or Double but got a %s", actual.Type)
}

// Numeric values can be compared even if their types are different (e.g. if expected is an int32 and actual
// is an int64).
expectedInt64 := assertionVal.AsInt64()
actualInt64 := actual.AsInt64()
if actualInt64 > expectedInt64 {
return fmt.Errorf("expected numeric value %d to be less than or equal %d", actualInt64, expectedInt64)

// TODO(GODRIVER-3594): If we decide to add AsDoubleOK() as a method to RawValue, this following conversion should be updated.
var expectedF64 float64
if assertionVal.Type == bson.TypeDouble {
expectedF64 = assertionVal.Double()
} else {
expectedF64 = float64(assertionVal.AsInt64())
}
var actualF64 float64
if actual.Type == bson.TypeDouble {
actualF64 = actual.Double()
} else {
actualF64 = float64(actual.AsInt64())
}

if actualF64 > expectedF64 {
return fmt.Errorf("expected numeric value %f to be less than or equal %f", actualF64, expectedF64)
}
return nil
case "$$matchAsDocument":
Expand Down
4 changes: 0 additions & 4 deletions internal/spectest/skip.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ import "testing"
// skipTests is a map of "fully-qualified test name" to "the reason for skipping
// the test".
var skipTests = map[string][]string{
// TODO(GODRIVER-3518): Test flexible numeric comparisons with $$lte
"Modifies $$lte operator test to also use floating point and Int64 types (GODRIVER-3518)": {
"TestUnifiedSpec/unified-test-format/tests/valid-pass/operator-lte.json/special_lte_matching_operator",
},

// SPEC-1403: This test checks to see if the correct error is thrown when auto
// encrypting with a server < 4.2. Currently, the test will fail because a
Expand Down
Loading