diff --git a/internal/integration/unified/matches.go b/internal/integration/unified/matches.go index 52afdc283c..3d0f04030e 100644 --- a/internal/integration/unified/matches.go +++ b/internal/integration/unified/matches.go @@ -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": diff --git a/internal/spectest/skip.go b/internal/spectest/skip.go index c3c5d04fe3..70866530e1 100644 --- a/internal/spectest/skip.go +++ b/internal/spectest/skip.go @@ -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