libmongocrypt-helper 1.7.4.0.1002 → 1.11.0.0.1001
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/libmongocrypt/libmongocrypt/CHANGELOG.md +40 -5
- data/ext/libmongocrypt/libmongocrypt/CMakeLists.txt +29 -24
- data/ext/libmongocrypt/libmongocrypt/CODEOWNERS +1 -4
- data/ext/libmongocrypt/libmongocrypt/Earthfile +522 -0
- data/ext/libmongocrypt/libmongocrypt/README.md +36 -40
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/CMakeLists.txt +1 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Driver.snk +0 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/AssemblyInfo.cs +2 -2
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/Binary.cs +16 -2
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/CryptClient.cs +25 -6
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/CryptClientFactory.cs +8 -4
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/Library.cs +35 -3
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/LibraryLoader.cs +81 -44
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/MongoDB.Libmongocrypt.csproj +2 -1
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt.Example/MongoDB.Libmongocrypt.Example.csproj +1 -1
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt.Test/BasicTests.cs +1 -1
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt.Test/MongoDB.Libmongocrypt.Test.csproj +2 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt.Test32/MongoDB.Libmongocrypt.Test32.csproj +2 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/README.md +3 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/Scripts/build.cake +22 -26
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/Scripts/build.config +3 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/Scripts/build.sh +0 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/benchmarks/build.gradle.kts +28 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/benchmarks/src/main/java/com/mongodb/crypt/benchmark/BenchmarkRunner.java +217 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/benchmarks/src/main/resources/keyDocument.json +24 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/build.gradle.kts +22 -7
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/gradle/wrapper/gradle-wrapper.jar +0 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/gradle/wrapper/gradle-wrapper.properties +1 -1
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/gradlew +154 -108
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/gradlew.bat +7 -18
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/settings.gradle.kts +1 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/CAPI.java +41 -6
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/CAPIHelper.java +5 -5
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/CipherCallback.java +27 -1
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/MongoCryptImpl.java +34 -19
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/MongoExplicitEncryptOptions.java +6 -4
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/resources/META-INF/native-image/jni-config.json +180 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/resources/META-INF/native-image/reflect-config.json +134 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/java/com/mongodb/crypt/capi/MongoCryptTest.java +50 -6
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/fle2-find-range-explicit-v2/int32/encrypted-payload.json +26 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/{python/test/data/fle2-find-range-explicit → java/mongocrypt/src/test/resources/fle2-find-range-explicit-v2}/int32/rangeopts.json +3 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/README.md +4 -771
- data/ext/libmongocrypt/libmongocrypt/bindings/python/CHANGELOG.rst +86 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/README.rst +41 -20
- data/ext/libmongocrypt/libmongocrypt/bindings/python/RELEASE.rst +6 -24
- data/ext/libmongocrypt/libmongocrypt/bindings/python/build-manylinux-wheel.sh +4 -13
- data/ext/libmongocrypt/libmongocrypt/bindings/python/hatch_build.py +36 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/libmongocrypt-version.txt +1 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/__init__.py +2 -2
- data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/asynchronous/auto_encrypter.py +61 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/asynchronous/credentials.py +156 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/asynchronous/explicit_encrypter.py +156 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/asynchronous/state_machine.py +149 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/auto_encrypter.py +2 -46
- data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/binary.py +14 -17
- data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/binding.py +232 -296
- data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/compat.py +6 -31
- data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/credentials.py +2 -121
- data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/crypto.py +31 -20
- data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/errors.py +2 -2
- data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/explicit_encrypter.py +2 -233
- data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/mongocrypt.py +168 -254
- data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/options.py +265 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/state_machine.py +2 -141
- data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/synchronous/auto_encrypter.py +61 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/synchronous/credentials.py +156 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/synchronous/explicit_encrypter.py +156 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/synchronous/state_machine.py +149 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/version.py +2 -2
- data/ext/libmongocrypt/libmongocrypt/bindings/python/pyproject.toml +118 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/release.sh +97 -61
- data/ext/libmongocrypt/libmongocrypt/bindings/python/requirements-test.txt +7 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/requirements.txt +4 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/sbom.json +76 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/strip_header.py +6 -7
- data/ext/libmongocrypt/libmongocrypt/bindings/python/synchro.py +64 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/__init__.py +2 -10
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/collection-info.json +1 -1
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/command.json +1 -1
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/compact/success/encrypted-payload.json +21 -21
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/encrypted-command-reply.json +1 -1
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/encrypted-field-config-map.json +1 -1
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/fle2-find-range-explicit-v2/int32/encrypted-payload.json +26 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/fle2-find-range-explicit-v2/int32/rangeopts.json +14 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/key-document-azure.json +1 -1
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/key-document-gcp.json +1 -1
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/key-document.json +1 -1
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/key-filter.json +1 -1
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/list-collections-filter.json +1 -1
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/mongocryptd-command.json +1 -1
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/mongocryptd-reply.json +1 -1
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/schema-map.json +1 -1
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/performance/keyDocument.json +24 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/performance/perf_test.py +165 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/test_binding.py +8 -12
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/test_crypto.py +9 -11
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/test_mongocrypt.py +991 -343
- data/ext/libmongocrypt/libmongocrypt/bindings/python/update-sbom.sh +14 -0
- data/ext/libmongocrypt/libmongocrypt/cmake/FetchMongoC.cmake +19 -1
- data/ext/libmongocrypt/libmongocrypt/cmake/ImportBSON.cmake +31 -6
- data/ext/libmongocrypt/libmongocrypt/cmake/IntelDFP.cmake +20 -227
- data/ext/libmongocrypt/libmongocrypt/cmake/Patch.cmake +54 -0
- data/ext/libmongocrypt/libmongocrypt/cmake/Platform.cmake +50 -0
- data/ext/libmongocrypt/libmongocrypt/cmake/mongocrypt-config.cmake +21 -0
- data/ext/libmongocrypt/libmongocrypt/doc/img/cli-icon.png +0 -0
- data/ext/libmongocrypt/libmongocrypt/doc/img/reference-targets.png +0 -0
- data/ext/libmongocrypt/libmongocrypt/doc/releasing.md +153 -0
- data/ext/libmongocrypt/libmongocrypt/etc/c6-vault.repo +39 -0
- data/ext/libmongocrypt/libmongocrypt/etc/calc_release_version.py +61 -28
- data/ext/libmongocrypt/libmongocrypt/etc/calc_release_version_selftest.sh +73 -0
- data/ext/libmongocrypt/libmongocrypt/etc/cyclonedx.sbom.json +108 -0
- data/ext/libmongocrypt/libmongocrypt/etc/fle2_aead_generate_tests.py +15 -24
- data/ext/libmongocrypt/libmongocrypt/etc/fle2_crypto.py +66 -54
- data/ext/libmongocrypt/libmongocrypt/etc/fle2_generate_tests.py +14 -23
- data/ext/libmongocrypt/libmongocrypt/etc/fle2v2_aead_generate_tests.py +32 -0
- data/ext/libmongocrypt/libmongocrypt/etc/format-all.sh +12 -0
- data/ext/libmongocrypt/libmongocrypt/etc/format.sh +16 -0
- data/ext/libmongocrypt/libmongocrypt/etc/install-package.sh +48 -0
- data/ext/libmongocrypt/libmongocrypt/etc/libbson-remove-GCC-diagnostic-pragma.patch +27 -0
- data/ext/libmongocrypt/libmongocrypt/etc/mongo-inteldfp-alpine-arm-fix.patch +17 -0
- data/ext/libmongocrypt/libmongocrypt/etc/mongo-inteldfp-libmongocrypt-pr-625.patch +13 -0
- data/ext/libmongocrypt/libmongocrypt/etc/packager.py +120 -91
- data/ext/libmongocrypt/libmongocrypt/etc/purls.txt +14 -0
- data/ext/libmongocrypt/libmongocrypt/etc/repo_config.yaml +56 -0
- data/ext/libmongocrypt/libmongocrypt/etc/silk-create-asset-group.sh +70 -0
- data/ext/libmongocrypt/libmongocrypt/etc/ssdlc_compliance_report.md +37 -0
- data/ext/libmongocrypt/libmongocrypt/etc/third_party_vulnerabilities.md +42 -0
- data/ext/libmongocrypt/libmongocrypt/integrating.md +18 -1
- data/ext/libmongocrypt/libmongocrypt/kms-message/CMakeLists.txt +11 -3
- data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_gcp_request.c +1 -1
- data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_kmip_reader_writer.c +17 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_kmip_reader_writer_private.h +6 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_kmip_request.c +211 -1
- data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_kmip_response.c +163 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_kmip_tag_type_private.h +2 -1
- data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_message/kms_kmip_request.h +17 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_message/kms_kmip_response.h +6 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_port.c +3 -2
- data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_request.c +4 -2
- data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_request_str.c +2 -2
- data/ext/libmongocrypt/libmongocrypt/kms-message/test/test_kmip_reader_writer.c +23 -2
- data/ext/libmongocrypt/libmongocrypt/src/crypto/cng.c +381 -436
- data/ext/libmongocrypt/libmongocrypt/src/crypto/commoncrypto.c +162 -227
- data/ext/libmongocrypt/libmongocrypt/src/crypto/libcrypto.c +183 -248
- data/ext/libmongocrypt/libmongocrypt/src/crypto/none.c +33 -55
- data/ext/libmongocrypt/libmongocrypt/src/csfle-markup.cpp +175 -205
- data/ext/libmongocrypt/libmongocrypt/src/mc-array-private.h +10 -21
- data/ext/libmongocrypt/libmongocrypt/src/mc-array.c +44 -56
- data/ext/libmongocrypt/libmongocrypt/src/mc-check-conversions-private.h +4 -8
- data/ext/libmongocrypt/libmongocrypt/src/mc-dec128.h +351 -463
- data/ext/libmongocrypt/libmongocrypt/src/mc-dec128.test.cpp +59 -66
- data/ext/libmongocrypt/libmongocrypt/src/mc-efc-private.h +21 -11
- data/ext/libmongocrypt/libmongocrypt/src/mc-efc.c +175 -99
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle-blob-subtype-private.h +18 -10
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-encryption-placeholder-private.h +69 -70
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-encryption-placeholder.c +445 -439
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-equality-payload-private-v2.h +41 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-equality-payload-private.h +11 -18
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-equality-payload-v2.c +135 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-equality-payload.c +109 -126
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-range-payload-private-v2.h +103 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-range-payload-private.h +28 -31
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-range-payload-v2.c +173 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-range-payload.c +106 -125
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-insert-update-payload-private-v2.h +130 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-insert-update-payload-private.h +36 -44
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-insert-update-payload-v2.c +382 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-insert-update-payload.c +237 -278
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-iev-private-v2.h +133 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-iev-private.h +67 -56
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-iev-v2.c +437 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-iev.c +454 -325
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-uev-common-private.h +69 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-uev-common.c +182 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-uev-private.h +23 -31
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-uev-v2-private.h +85 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-uev-v2.c +142 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-uev.c +104 -231
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-range-operator-private.h +8 -7
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-rfds-private.h +56 -56
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-rfds.c +520 -580
- data/ext/libmongocrypt/libmongocrypt/src/mc-optional-private.h +47 -66
- data/ext/libmongocrypt/libmongocrypt/src/mc-range-edge-generation-private.h +67 -76
- data/ext/libmongocrypt/libmongocrypt/src/mc-range-edge-generation.c +201 -190
- data/ext/libmongocrypt/libmongocrypt/src/mc-range-encoding-private.h +55 -42
- data/ext/libmongocrypt/libmongocrypt/src/mc-range-encoding.c +809 -558
- data/ext/libmongocrypt/libmongocrypt/src/mc-range-mincover-generator.template.h +177 -201
- data/ext/libmongocrypt/libmongocrypt/src/mc-range-mincover-private.h +54 -53
- data/ext/libmongocrypt/libmongocrypt/src/mc-range-mincover.c +188 -240
- data/ext/libmongocrypt/libmongocrypt/src/mc-rangeopts-private.h +43 -35
- data/ext/libmongocrypt/libmongocrypt/src/mc-rangeopts.c +484 -337
- data/ext/libmongocrypt/libmongocrypt/src/mc-reader-private.h +36 -71
- data/ext/libmongocrypt/libmongocrypt/src/mc-reader.c +111 -164
- data/ext/libmongocrypt/libmongocrypt/src/mc-tokens-private.h +87 -65
- data/ext/libmongocrypt/libmongocrypt/src/mc-tokens.c +153 -125
- data/ext/libmongocrypt/libmongocrypt/src/mc-writer-private.h +66 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-writer.c +141 -0
- data/ext/libmongocrypt/libmongocrypt/src/mlib/check.hpp +37 -55
- data/ext/libmongocrypt/libmongocrypt/src/mlib/endian.h +11 -11
- data/ext/libmongocrypt/libmongocrypt/src/mlib/error.h +27 -32
- data/ext/libmongocrypt/libmongocrypt/src/mlib/int128.h +461 -499
- data/ext/libmongocrypt/libmongocrypt/src/mlib/int128.test.cpp +256 -334
- data/ext/libmongocrypt/libmongocrypt/src/mlib/macros.h +4 -5
- data/ext/libmongocrypt/libmongocrypt/src/mlib/path.h +196 -231
- data/ext/libmongocrypt/libmongocrypt/src/mlib/path.test.c +56 -79
- data/ext/libmongocrypt/libmongocrypt/src/mlib/str.h +411 -530
- data/ext/libmongocrypt/libmongocrypt/src/mlib/str.test.c +116 -131
- data/ext/libmongocrypt/libmongocrypt/src/mlib/thread.h +17 -26
- data/ext/libmongocrypt/libmongocrypt/src/mlib/user-check.h +2 -2
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-binary-private.h +1 -9
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-binary.c +31 -48
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-buffer-private.h +55 -131
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-buffer.c +442 -565
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache-collinfo-private.h +1 -2
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache-collinfo.c +28 -45
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache-key-private.h +11 -17
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache-key.c +104 -132
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache-oauth-private.h +16 -24
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache-oauth.c +110 -93
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache-private.h +26 -45
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache.c +220 -273
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ciphertext-private.h +13 -25
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ciphertext.c +147 -166
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-compat.h +2 -2
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-crypto-private.h +110 -204
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-crypto.c +1145 -1567
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx-datakey.c +510 -476
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx-decrypt.c +817 -694
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx-encrypt.c +2775 -2697
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx-private.h +189 -184
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx-rewrap-many-datakey.c +308 -351
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx.c +990 -1139
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-dll-private.h +23 -24
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-endian-private.h +44 -58
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-endpoint-private.h +21 -25
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-endpoint.c +167 -181
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-kek-private.h +42 -44
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-kek.c +292 -272
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-key-broker-private.h +70 -110
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-key-broker.c +1010 -1033
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-key-private.h +27 -44
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-key.c +349 -402
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-kms-ctx-private.h +127 -120
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-kms-ctx.c +1692 -1611
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-log-private.h +35 -67
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-log.c +49 -83
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-marking-private.h +31 -36
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-marking.c +1923 -1479
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-mutex-private.h +7 -12
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-opts-private.h +124 -107
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-opts.c +925 -419
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-private.h +99 -122
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-status-private.h +3 -8
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-status.c +92 -119
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-traverse-util-private.h +19 -29
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-traverse-util.c +136 -176
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-util-private.h +11 -21
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-util.c +98 -136
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt.c +924 -1339
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt.h +199 -313
- data/ext/libmongocrypt/libmongocrypt/src/os_posix/os_dll.c +83 -79
- data/ext/libmongocrypt/libmongocrypt/src/os_posix/os_mutex.c +20 -28
- data/ext/libmongocrypt/libmongocrypt/src/os_win/os_dll.c +64 -73
- data/ext/libmongocrypt/libmongocrypt/src/os_win/os_mutex.c +8 -16
- data/ext/libmongocrypt/libmongocrypt/test/crypt_shared-stub.cpp +57 -87
- data/ext/libmongocrypt/libmongocrypt/test/data/bulkWrite/bypassQueryAnalysis/payload.json +53 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/bulkWrite/jsonSchema/cmd-to-mongocryptd.json +23 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/bulkWrite/jsonSchema/cmd.json +20 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/bulkWrite/simple/cmd-to-mongocryptd.json +50 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/bulkWrite/simple/cmd.json +20 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/bulkWrite/simple/collinfo.json +44 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/bulkWrite/simple/encrypted-field-map.json +24 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/bulkWrite/simple/encrypted-payload-pattern.json +53 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/bulkWrite/simple/mongocryptd-reply.json +62 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/bulkWrite/unencrypted/cmd-to-mongocryptd.json +30 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/bulkWrite/unencrypted/cmd.json +17 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/bulkWrite/unencrypted/mongocryptd-reply.json +39 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/bulkWrite/unencrypted/payload.json +21 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/cleanup/missing-key-id/collinfo.json +20 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/cleanup/no-fields/collinfo.json +9 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/cleanup/no-fields/encrypted-payload.json +4 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/cleanup/success/cmd.json +1 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/cleanup/success/collinfo.json +63 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/cleanup/success/encrypted-field-config-map.json +61 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/cleanup/success/encrypted-payload-range-v2.json +37 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/cleanup/success/encrypted-payload.json +29 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/compact/anchor-pad/cmd.json +1 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/compact/anchor-pad/collinfo.json +64 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/compact/anchor-pad/encrypted-payload-range-v2.json +105 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/compact/anchor-pad/encrypted-payload.json +30 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/compact/no-range/cmd.json +1 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/compact/no-range/collinfo.json +49 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/compact/no-range/encrypted-field-config-map.json +47 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/compact/no-range/encrypted-payload.json +23 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/compact/success/collinfo.json +15 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/compact/success/encrypted-field-config-map.json +10 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/compact/success/encrypted-payload-range-v2.json +104 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/compact/success/encrypted-payload.json +6 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-delete/empty/encrypted-payload-v2.json +60 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-delete/success/encrypted-payload-v2.json +67 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-explain/with-csfle/collinfo.json +4 -4
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-explain/with-csfle/encrypted-payload.json +5 -5
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-explicit/find-indexed-contentionFactor1-v2.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-explicit/find-indexed-v2.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-explicit/insert-indexed-contentionFactor1-v2.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-explicit/insert-indexed-same-user-and-index-key-v2.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-explicit/insert-indexed-v2.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-equality-v2/cmd.json +6 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-equality-v2/encrypted-field-map.json +22 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-equality-v2/encrypted-payload.json +40 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-equality-v2/mongocryptd-reply.json +19 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/date-v2/cmd.json +10 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/date-v2/encrypted-field-map.json +27 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/date-v2/encrypted-payload.json +41 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/date-v2/mongocryptd-reply.json +49 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128-precision-v2/cmd.json +6 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128-precision-v2/encrypted-field-map.json +30 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128-precision-v2/encrypted-payload.json +50 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128-precision-v2/mongocryptd-reply.json +58 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128-v2/cmd.json +6 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128-v2/encrypted-field-map.json +27 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128-v2/encrypted-payload.json +41 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128-v2/mongocryptd-reply.json +49 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double-precision-v2/cmd.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double-precision-v2/encrypted-field-map.json +30 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double-precision-v2/encrypted-payload.json +44 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double-precision-v2/mongocryptd-reply.json +52 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double-v2/cmd.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double-v2/encrypted-field-map.json +27 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double-v2/encrypted-payload.json +41 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double-v2/mongocryptd-reply.json +49 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int32-v2/cmd.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int32-v2/encrypted-field-map.json +27 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int32-v2/encrypted-payload.json +41 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int32-v2/mongocryptd-reply.json +49 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int64-v2/cmd.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int64-v2/encrypted-field-map.json +27 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int64-v2/encrypted-payload.json +41 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int64-v2/mongocryptd-reply.json +49 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/double/encrypted-payload-v2.json +26 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/double-precision/encrypted-payload-v2.json +26 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/int32/encrypted-payload-v2.json +26 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/int32-nominmax/encrypted-payload-v2.json +26 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/int32-openinterval/encrypted-payload-v2.json +16 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert/cmd.json +1 -1
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/date/RNG_DATA.h +65 -65
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/date-v2/cmd.json +13 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/date-v2/encrypted-field-map.json +27 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/date-v2/encrypted-payload.json +44 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/date-v2/mongocryptd-reply.json +52 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128/RNG_DATA.h +132 -132
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-precision/RNG_DATA.h +71 -71
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-precision-v2/cmd.json +9 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-precision-v2/encrypted-field-map.json +30 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-precision-v2/encrypted-payload.json +53 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-precision-v2/mongocryptd-reply.json +61 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-v2/cmd.json +9 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-v2/encrypted-field-map.json +27 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-v2/encrypted-payload.json +44 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-v2/mongocryptd-reply.json +52 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double/RNG_DATA.h +68 -68
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-precision/RNG_DATA.h +19 -19
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-precision-v2/cmd.json +11 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-precision-v2/encrypted-field-map.json +30 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-precision-v2/encrypted-payload.json +47 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-precision-v2/mongocryptd-reply.json +55 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-v2/cmd.json +11 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-v2/encrypted-field-map.json +27 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-v2/encrypted-payload.json +44 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-v2/mongocryptd-reply.json +52 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int32/RNG_DATA.h +25 -25
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int32-v2/cmd.json +11 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int32-v2/encrypted-field-map.json +27 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int32-v2/encrypted-payload.json +44 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int32-v2/mongocryptd-reply.json +52 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int64/RNG_DATA.h +65 -65
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int64-v2/cmd.json +11 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int64-v2/encrypted-field-map.json +27 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int64-v2/encrypted-payload.json +44 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int64-v2/mongocryptd-reply.json +52 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/double/RNG_DATA.h +68 -68
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/double/encrypted-payload-v2.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/double-precision/RNG_DATA.h +19 -19
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/double-precision/encrypted-payload-v2.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/int32/RNG_DATA.h +25 -25
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/int32/encrypted-payload-v2.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/int32-nominmax/encrypted-payload-v2.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/sparsity-2/RNG_DATA.h +15 -15
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/sparsity-2/encrypted-payload-v2.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-unindexed-v2/cmd.json +9 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-unindexed-v2/encrypted-field-map.json +18 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-unindexed-v2/encrypted-payload.json +14 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-unindexed-v2/mongocryptd-reply.json +41 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-v2/cmd.json +9 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-v2/encrypted-field-map.json +22 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-v2/encrypted-payload.json +39 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-v2/mongocryptd-reply.json +49 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/iev-v2/FLECrudTest-insertOneRangeV2.json +10 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/iev-v2/FLECrudTest-insertOneV2.json +10 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/kms-azure/decrypt-response.txt +16 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/kms-azure/encrypt-response.txt +16 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/kms-azure/oauth-response.txt +19 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/no-trimFactor/find/cmd.json +9 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/no-trimFactor/find/encrypted-field-map.json +19 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/no-trimFactor/find/encrypted-payload.json +62 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/no-trimFactor/find/mongocryptd-reply.json +69 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/no-trimFactor/insert/cmd.json +11 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/no-trimFactor/insert/encrypted-field-map.json +19 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/no-trimFactor/insert/encrypted-payload.json +40 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/no-trimFactor/insert/mongocryptd-reply.json +47 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/range-edge-generation/edges_decimal128.cstruct +1 -1
- data/ext/libmongocrypt/libmongocrypt/test/data/range-edge-generation/edges_double.cstruct +8637 -7958
- data/ext/libmongocrypt/libmongocrypt/test/data/range-edge-generation/edges_int32.cstruct +5522 -1382
- data/ext/libmongocrypt/libmongocrypt/test/data/range-edge-generation/edges_int64.cstruct +5042 -1262
- data/ext/libmongocrypt/libmongocrypt/test/data/range-min-cover/mincover_decimal128.cstruct +1 -1
- data/ext/libmongocrypt/libmongocrypt/test/data/range-min-cover/mincover_decimal128_precision.cstruct +1 -1
- data/ext/libmongocrypt/libmongocrypt/test/data/range-min-cover/mincover_double.cstruct +1 -1
- data/ext/libmongocrypt/libmongocrypt/test/data/range-min-cover/mincover_double_precision.cstruct +2 -2
- data/ext/libmongocrypt/libmongocrypt/test/data/range-min-cover/mincover_int32.cstruct +1 -1
- data/ext/libmongocrypt/libmongocrypt/test/data/range-min-cover/mincover_int64.cstruct +1 -1
- data/ext/libmongocrypt/libmongocrypt/test/data/range-sends-cryptoParams/auto-find-int32/cmd.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/range-sends-cryptoParams/auto-find-int32/encrypted-field-map.json +19 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/range-sends-cryptoParams/auto-find-int32/encrypted-payload.json +53 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/range-sends-cryptoParams/auto-find-int32/mongocryptd-reply.json +58 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/range-sends-cryptoParams/auto-insert-int32/cmd.json +11 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/range-sends-cryptoParams/auto-insert-int32/encrypted-field-map.json +19 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/range-sends-cryptoParams/auto-insert-int32/encrypted-payload.json +40 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/range-sends-cryptoParams/auto-insert-int32/mongocryptd-reply.json +45 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/range-sends-cryptoParams/explicit-find-int32/expected.json +26 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/range-sends-cryptoParams/explicit-find-int32/to-encrypt.json +20 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/range-sends-cryptoParams/explicit-find-int32-defaults/expected.json +26 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/range-sends-cryptoParams/explicit-find-int32-defaults/to-encrypt.json +20 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/range-sends-cryptoParams/explicit-insert-double/expected.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/range-sends-cryptoParams/explicit-insert-int32/expected.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/range-sends-cryptoParams/explicit-insert-int32-defaults/expected.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/README.md +17 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/aes-ctr.json +29 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/fle2-fixed.json +10 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/fle2-generated.json +38 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/fle2aead-decrypt.json +35 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/fle2aead-fixed.json +29 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/fle2aead-generated.json +122 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/fle2v2-aead-fixed.json +29 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/fle2v2-aead-generated.json +122 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/mcgrew.json +12 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/nist.json +20 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/tokens/README.md +30 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/tokens/mc.json +25 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/tokens/server.json +25 -0
- data/ext/libmongocrypt/libmongocrypt/test/example-no-bson.c +4 -4
- data/ext/libmongocrypt/libmongocrypt/test/example-state-machine.c +279 -323
- data/ext/libmongocrypt/libmongocrypt/test/fuzz_kms.c +8 -7
- data/ext/libmongocrypt/libmongocrypt/test/test-dll.cpp +6 -7
- data/ext/libmongocrypt/libmongocrypt/test/test-gcp-auth.c +221 -283
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-efc.c +60 -73
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-find-equality-payload-v2.c +78 -0
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-find-range-payload-v2.c +129 -0
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-payload-iev-v2.c +248 -0
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-payload-iev.c +467 -414
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-payload-iup-v2.c +248 -0
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-payload-iup.c +141 -159
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-payload-uev-v2.c +338 -0
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-payload-uev.c +238 -176
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-rfds.c +373 -474
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-range-edge-generation.c +421 -388
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-range-encoding.c +974 -825
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-range-mincover.c +499 -481
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-rangeopts.c +312 -148
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-reader.c +124 -207
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-tokens.c +249 -213
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-writer.c +176 -0
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-assert-match-bson.c +632 -808
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-assert-match-bson.h +22 -2
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-assert.h +168 -189
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-buffer.c +187 -211
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-cache-oauth.c +118 -37
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-cache.c +210 -233
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-ciphertext.c +185 -220
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-cleanup.c +374 -0
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-compact.c +410 -445
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-crypto-hooks.c +798 -812
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-crypto-std-hooks.c +142 -135
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-crypto-std-hooks.h +70 -71
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-crypto.c +394 -846
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-csfle-lib.c +159 -183
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-ctx-decrypt.c +870 -1045
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-ctx-encrypt.c +5183 -4717
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-ctx-rewrap-many-datakey.c +750 -964
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-ctx-setopt.c +1093 -1178
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-datakey.c +348 -420
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-dll.c +23 -30
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-endpoint.c +98 -111
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-kek.c +49 -52
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-key-broker.c +770 -920
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-key-cache.c +354 -407
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-key.c +197 -245
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-kms-ctx.c +705 -368
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-kms-responses.c +147 -166
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-local-kms.c +50 -61
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-log.c +85 -100
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-marking.c +1073 -690
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-opts.c +42 -0
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-status.c +46 -58
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-traverse-util.c +381 -451
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-util.c +55 -67
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-util.h +7 -10
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt.c +879 -918
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt.h +119 -169
- data/ext/libmongocrypt/libmongocrypt/test/test-named-kms-providers.c +2381 -0
- data/ext/libmongocrypt/libmongocrypt/test/util/HELP.autogen +3 -1
- data/ext/libmongocrypt/libmongocrypt/test/util/README.md +1 -0
- data/ext/libmongocrypt/libmongocrypt/test/util/csfle.c +512 -559
- data/ext/libmongocrypt/libmongocrypt/test/util/make_includes.py +1 -1
- data/ext/libmongocrypt/libmongocrypt/test/util/util.c +771 -882
- data/ext/libmongocrypt/libmongocrypt/test/util/util.h +33 -55
- data/lib/libmongocrypt_helper/version.rb +2 -2
- metadata +245 -111
- checksums.yaml.gz.sig +0 -0
- data/ext/libmongocrypt/libmongocrypt/VERSION_CURRENT +0 -1
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/fle2-find-range-explicit/int32/encrypted-payload.json +0 -26
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/fle2-find-range-explicit/int32/key-document.json +0 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/CHANGELOG.md +0 -81
- data/ext/libmongocrypt/libmongocrypt/bindings/node/LICENSE +0 -201
- data/ext/libmongocrypt/libmongocrypt/bindings/node/binding.gyp +0 -79
- data/ext/libmongocrypt/libmongocrypt/bindings/node/etc/README.hbs +0 -44
- data/ext/libmongocrypt/libmongocrypt/bindings/node/etc/build-static.sh +0 -39
- data/ext/libmongocrypt/libmongocrypt/bindings/node/index.d.ts +0 -515
- data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/autoEncrypter.js +0 -420
- data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/buffer_pool.js +0 -123
- data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/clientEncryption.js +0 -699
- data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/common.js +0 -100
- data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/credentialsProvider.js +0 -33
- data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/cryptoCallbacks.js +0 -87
- data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/index.js +0 -42
- data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/mongocryptdManager.js +0 -66
- data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/stateMachine.js +0 -487
- data/ext/libmongocrypt/libmongocrypt/bindings/node/package-lock.json +0 -16051
- data/ext/libmongocrypt/libmongocrypt/bindings/node/package.json +0 -81
- data/ext/libmongocrypt/libmongocrypt/bindings/node/src/mongocrypt.cc +0 -929
- data/ext/libmongocrypt/libmongocrypt/bindings/node/src/mongocrypt.h +0 -114
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/autoEncrypter.test.js +0 -953
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/buffer_pool.test.js +0 -91
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/clientEncryption.test.js +0 -701
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/credentialsProvider.test.js +0 -163
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/cryptoCallbacks.test.js +0 -284
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/data/README.md +0 -5
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/data/cmd.json +0 -6
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/data/collection-info.json +0 -37
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/data/encrypted-document-nested.json +0 -8
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/data/encrypted-document.json +0 -11
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/data/encryptedFields.json +0 -30
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/data/key-document.json +0 -32
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/data/key1-document.json +0 -30
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/data/mongocryptd-reply.json +0 -18
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/mongocryptdManager.test.js +0 -48
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/release.test.js +0 -59
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/requirements.helper.js +0 -29
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/stateMachine.test.js +0 -331
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/tools/mongodb_reporter.js +0 -325
- data/ext/libmongocrypt/libmongocrypt/bindings/python/setup.py +0 -84
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/fle2-find-range-explicit/int32/encrypted-payload.json +0 -26
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test-requirements.txt +0 -12
- data/ext/libmongocrypt/libmongocrypt/debian/build_snapshot.sh +0 -79
- data/ext/libmongocrypt/libmongocrypt/debian/changelog +0 -105
- data/ext/libmongocrypt/libmongocrypt/debian/compat +0 -1
- data/ext/libmongocrypt/libmongocrypt/debian/control +0 -41
- data/ext/libmongocrypt/libmongocrypt/debian/copyright +0 -129
- data/ext/libmongocrypt/libmongocrypt/debian/gbp.conf +0 -23
- data/ext/libmongocrypt/libmongocrypt/debian/libmongocrypt-dev.dirs +0 -2
- data/ext/libmongocrypt/libmongocrypt/debian/libmongocrypt-dev.install +0 -5
- data/ext/libmongocrypt/libmongocrypt/debian/libmongocrypt0.dirs +0 -1
- data/ext/libmongocrypt/libmongocrypt/debian/libmongocrypt0.install +0 -1
- data/ext/libmongocrypt/libmongocrypt/debian/rules +0 -46
- data/ext/libmongocrypt/libmongocrypt/debian/source/format +0 -1
- data/ext/libmongocrypt/libmongocrypt/debian/source/lintian-overrides +0 -3
- data/ext/libmongocrypt/libmongocrypt/debian/source/options +0 -1
- data/ext/libmongocrypt/libmongocrypt/debian/watch +0 -3
- data/ext/libmongocrypt/libmongocrypt/test/data/aes-ctr.cstructs +0 -359
- data/ext/libmongocrypt/libmongocrypt/test/data/compact/success/mongocryptd-reply.json +0 -72
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-aead.cstructs +0 -109
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/int32-nominmax/encrypted-payload.json +0 -26
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/int32-nominmax/rangeopts.json +0 -5
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/int32-nominmax/RNG_DATA.h +0 -70
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/int32-nominmax/encrypted-payload.json +0 -8
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/int32-nominmax/rangeopts.json +0 -5
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/int32-nominmax/value-to-encrypt.json +0 -5
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2.cstructs +0 -33
- data.tar.gz.sig +0 -0
- metadata.gz.sig +0 -0
- /data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/{fle2-find-range-explicit → fle2-find-range-explicit-v2}/int32/key-filter.json +0 -0
- /data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/{fle2-find-range-explicit → fle2-find-range-explicit-v2}/int32/value-to-encrypt.json +0 -0
- /data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/{fle2-find-range-explicit → fle2-find-range-explicit-v2}/int32/value-to-encrypt.json +0 -0
- /data/ext/libmongocrypt/libmongocrypt/bindings/{java/mongocrypt/src/test/resources/fle2-find-range-explicit → python/test/data/fle2-find-rangePreview-explicit}/int32/rangeopts.json +0 -0
- /data/ext/libmongocrypt/libmongocrypt/{test/data/fle2-find-range-explicit/int32-nominmax → bindings/python/test/data/fle2-find-rangePreview-explicit/int32}/value-to-encrypt.json +0 -0
- /data/ext/libmongocrypt/libmongocrypt/{bindings/node/test/data/kms-decrypt-reply.txt → test/data/kms-aws/decrypt-response.txt} +0 -0
- /data/ext/libmongocrypt/libmongocrypt/{bindings/node/test/data/kms-encrypt-reply.txt → test/data/kms-aws/encrypt-response.txt} +0 -0
- /data/ext/libmongocrypt/libmongocrypt/test/data/{gcp-auth → kms-gcp}/decrypt-response.txt +0 -0
- /data/ext/libmongocrypt/libmongocrypt/test/data/{gcp-auth → kms-gcp}/encrypt-response.txt +0 -0
- /data/ext/libmongocrypt/libmongocrypt/test/data/{gcp-auth → kms-gcp}/oauth-response.txt +0 -0
@@ -20,867 +20,1016 @@
|
|
20
20
|
|
21
21
|
#include <float.h> // DBL_MAX
|
22
22
|
#include <math.h> // INFINITY, NAN
|
23
|
+
#include <stdint.h>
|
23
24
|
|
24
25
|
typedef struct {
|
25
|
-
|
26
|
-
|
27
|
-
|
26
|
+
mc_getTypeInfo32_args_t args;
|
27
|
+
mc_OSTType_Int32 expect;
|
28
|
+
const char *expectError;
|
28
29
|
} Int32Test;
|
29
30
|
|
30
|
-
static void
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
"value and less than or equal to the maximum value"},
|
107
|
-
{.args = {.value = 4,
|
108
|
-
.min = OPT_I32 (INT32_MIN),
|
109
|
-
.max = OPT_I32 (INT32_MIN)},
|
110
|
-
.expectError = "The minimum value must be less than the maximum value"},
|
111
|
-
/* Test cases copied from server Int32_Errors test ... end */
|
112
|
-
};
|
113
|
-
|
114
|
-
for (size_t i = 0; i < sizeof (tests) / sizeof (tests[0]); i++) {
|
115
|
-
Int32Test *test = tests + i;
|
116
|
-
mongocrypt_status_t *const status = mongocrypt_status_new ();
|
117
|
-
|
118
|
-
// Print a description of the test case.
|
119
|
-
printf ("_test_RangeTest_Encode_Int32: value=%" PRId32, test->args.value);
|
120
|
-
if (test->args.min.set) {
|
121
|
-
printf (" min=%" PRId32, test->args.min.value);
|
122
|
-
}
|
123
|
-
if (test->args.max.set) {
|
124
|
-
printf (" max=%" PRId32, test->args.max.value);
|
125
|
-
}
|
126
|
-
printf ("\n");
|
127
|
-
mc_OSTType_Int32 got;
|
128
|
-
const bool ok = mc_getTypeInfo32 (test->args, &got, status);
|
129
|
-
if (test->expectError) {
|
130
|
-
ASSERT_OR_PRINT_MSG (!ok, "expected error, but got none");
|
131
|
-
ASSERT_STATUS_CONTAINS (status, test->expectError);
|
132
|
-
} else {
|
133
|
-
ASSERT_OK_STATUS (ok, status);
|
134
|
-
ASSERT_CMPUINT32 (got.value, ==, test->expect.value);
|
135
|
-
ASSERT_CMPUINT32 (got.min, ==, test->expect.min);
|
136
|
-
ASSERT_CMPUINT32 (got.max, ==, test->expect.max);
|
137
|
-
}
|
138
|
-
mongocrypt_status_destroy (status);
|
139
|
-
}
|
31
|
+
static void _test_RangeTest_Encode_Int32(_mongocrypt_tester_t *tester) {
|
32
|
+
Int32Test tests[] = {
|
33
|
+
/* Test cases copied from server Int32_NoBounds test ... begin */
|
34
|
+
{.args = {.value = INT32_C(2147483647)},
|
35
|
+
.expect = {.value = UINT32_C(4294967295), .min = 0, .max = UINT32_MAX}},
|
36
|
+
{.args = {.value = 1}, .expect = {.value = UINT32_C(2147483649), .min = 0, .max = UINT32_MAX}},
|
37
|
+
{.args = {.value = 0}, .expect = {.value = UINT32_C(2147483648), .min = 0, .max = UINT32_MAX}},
|
38
|
+
{.args = {.value = -1}, .expect = {.value = UINT32_C(2147483647), .min = 0, .max = UINT32_MAX}},
|
39
|
+
{.args = {.value = -2}, .expect = {.value = UINT32_C(2147483646), .min = 0, .max = UINT32_MAX}},
|
40
|
+
{.args = {.value = INT32_C(-2147483647)}, .expect = {.value = 1, .min = 0, .max = UINT32_MAX}},
|
41
|
+
{.args = {.value = INT32_MIN}, .expect = {.value = 0, .min = 0, .max = UINT32_MAX}},
|
42
|
+
/* Test cases copied from server Int32_NoBounds test ... end */
|
43
|
+
/* Test cases copied from server Int32_Bounds test .. begin */
|
44
|
+
{.args = {.value = 1, .min = OPT_I32(1), .max = OPT_I32(3)}, .expect = {.value = 0, 0, .max = 2}},
|
45
|
+
{.args = {.value = 0, .min = OPT_I32(0), .max = OPT_I32(1)}, .expect = {.value = 0, .min = 0, .max = 1}},
|
46
|
+
{.args = {.value = -1, .min = OPT_I32(-1), .max = OPT_I32(0)}, .expect = {.value = 0, .min = 0, .max = 1}},
|
47
|
+
{.args = {.value = -2, .min = OPT_I32(-2), .max = OPT_I32(0)}, .expect = {.value = 0, .min = 0, .max = 2}},
|
48
|
+
{.args = {.value = INT32_C(-2147483647), .min = OPT_I32(INT32_MIN), .max = OPT_I32(1)},
|
49
|
+
.expect = {.value = 1, .min = 0, .max = UINT32_C(2147483649)}},
|
50
|
+
{.args = {.value = INT32_MIN, .min = OPT_I32(INT32_MIN), .max = OPT_I32(0)},
|
51
|
+
.expect = {.value = 0, .min = 0, .max = UINT32_C(2147483648)}},
|
52
|
+
{.args = {.value = 0, .min = OPT_I32(INT32_MIN), .max = OPT_I32(1)},
|
53
|
+
.expect = {.value = UINT32_C(2147483648), .min = 0, .max = UINT32_C(2147483649)}},
|
54
|
+
{.args = {.value = 1, .min = OPT_I32(INT32_MIN), .max = OPT_I32(2)},
|
55
|
+
.expect = {.value = UINT32_C(2147483649), .min = 0, .max = UINT32_C(2147483650)}},
|
56
|
+
{.args = {.value = INT32_C(2147483647), .min = OPT_I32(-2147483647), .max = OPT_I32(2147483647)},
|
57
|
+
.expect = {.value = UINT32_C(4294967294), .min = 0, .max = UINT32_C(4294967294)}},
|
58
|
+
{.args = {.value = INT32_C(2147483647), .min = OPT_I32(INT32_MIN), .max = OPT_I32(2147483647)},
|
59
|
+
.expect = {.value = UINT32_C(4294967295), .min = 0, .max = UINT32_C(4294967295)}},
|
60
|
+
{.args = {.value = 15, .min = OPT_I32(10), .max = OPT_I32(26)}, .expect = {.value = 5, .min = 0, .max = 16}},
|
61
|
+
{.args = {.value = 15, .min = OPT_I32(-10), .max = OPT_I32(55)}, .expect = {.value = 25, .min = 0, .max = 65}},
|
62
|
+
/* Test cases copied from server Int32_Bounds test ... end */
|
63
|
+
/* Test cases copied from server Int32_Errors test ... begin */
|
64
|
+
{.args = {.value = 1, .max = OPT_I32(2)},
|
65
|
+
.expectError = "Must specify both a lower and upper bound or no bounds."},
|
66
|
+
{.args = {.value = 1, .min = OPT_I32(0)},
|
67
|
+
.expectError = "Must specify both a lower and upper bound or no bounds."},
|
68
|
+
{.args = {.value = 1, .min = OPT_I32(2), .max = OPT_I32(1)},
|
69
|
+
.expectError = "The minimum value must be less than the maximum value"},
|
70
|
+
{.args = {.value = 1, .min = OPT_I32(2), .max = OPT_I32(3)},
|
71
|
+
.expectError = "Value must be greater than or equal to the minimum "
|
72
|
+
"value and less than or equal to the maximum value"},
|
73
|
+
{.args = {.value = 4, .min = OPT_I32(2), .max = OPT_I32(3)},
|
74
|
+
.expectError = "Value must be greater than or equal to the minimum "
|
75
|
+
"value and less than or equal to the maximum value"},
|
76
|
+
{.args = {.value = 4, .min = OPT_I32(INT32_MIN), .max = OPT_I32(INT32_MIN)},
|
77
|
+
.expectError = "The minimum value must be less than the maximum value"},
|
78
|
+
/* Test cases copied from server Int32_Errors test ... end */
|
79
|
+
};
|
80
|
+
|
81
|
+
for (size_t i = 0; i < sizeof(tests) / sizeof(tests[0]); i++) {
|
82
|
+
Int32Test *test = tests + i;
|
83
|
+
mongocrypt_status_t *const status = mongocrypt_status_new();
|
84
|
+
|
85
|
+
// Print a description of the test case.
|
86
|
+
printf("_test_RangeTest_Encode_Int32: value=%" PRId32, test->args.value);
|
87
|
+
if (test->args.min.set) {
|
88
|
+
printf(" min=%" PRId32, test->args.min.value);
|
89
|
+
}
|
90
|
+
if (test->args.max.set) {
|
91
|
+
printf(" max=%" PRId32, test->args.max.value);
|
92
|
+
}
|
93
|
+
printf("\n");
|
94
|
+
mc_OSTType_Int32 got;
|
95
|
+
const bool ok = mc_getTypeInfo32(test->args, &got, status);
|
96
|
+
if (test->expectError) {
|
97
|
+
ASSERT_OR_PRINT_MSG(!ok, "expected error, but got none");
|
98
|
+
ASSERT_STATUS_CONTAINS(status, test->expectError);
|
99
|
+
} else {
|
100
|
+
ASSERT_OK_STATUS(ok, status);
|
101
|
+
ASSERT_CMPUINT32(got.value, ==, test->expect.value);
|
102
|
+
ASSERT_CMPUINT32(got.min, ==, test->expect.min);
|
103
|
+
ASSERT_CMPUINT32(got.max, ==, test->expect.max);
|
104
|
+
}
|
105
|
+
mongocrypt_status_destroy(status);
|
106
|
+
}
|
140
107
|
}
|
141
108
|
|
142
109
|
typedef struct {
|
143
|
-
|
144
|
-
|
145
|
-
|
110
|
+
mc_getTypeInfo64_args_t args;
|
111
|
+
mc_OSTType_Int64 expect;
|
112
|
+
const char *expectError;
|
146
113
|
} Int64Test;
|
147
114
|
|
148
|
-
static void
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
115
|
+
static void _test_RangeTest_Encode_Int64(_mongocrypt_tester_t *tester) {
|
116
|
+
Int64Test tests[] = {
|
117
|
+
/* Test cases copied from server Int64_NoBounds test ... begin */
|
118
|
+
{.args = {.value = INT64_C(9223372036854775807)},
|
119
|
+
.expect = {.value = UINT64_C(18446744073709551615), .min = 0, .max = UINT64_MAX}},
|
120
|
+
{.args = {.value = 1}, .expect = {.value = UINT64_C(9223372036854775809), .min = 0, .max = UINT64_MAX}},
|
121
|
+
{.args = {.value = 0}, .expect = {.value = UINT64_C(9223372036854775808), .min = 0, .max = UINT64_MAX}},
|
122
|
+
{.args = {.value = -1}, .expect = {.value = UINT64_C(9223372036854775807), .min = 0, .max = UINT64_MAX}},
|
123
|
+
{.args = {.value = -2}, .expect = {.value = UINT64_C(9223372036854775806), .min = 0, .max = UINT64_MAX}},
|
124
|
+
{.args = {.value = INT64_C(-9223372036854775807)}, .expect = {.value = 1, .min = 0, .max = UINT64_MAX}},
|
125
|
+
{.args = {.value = INT64_MIN}, .expect = {.value = 0, .min = 0, .max = UINT64_MAX}},
|
126
|
+
/* Test cases copied from server Int64_NoBounds test ... end */
|
127
|
+
/* Test cases copied from server Int64_Bounds test ... begin */
|
128
|
+
{.args = {.value = 1, .min = OPT_I64(1), .max = OPT_I64(2)}, .expect = {.value = 0, .min = 0, .max = 1}},
|
129
|
+
{.args = {.value = 0, .min = OPT_I64(0), .max = OPT_I64(1)}, .expect = {.value = 0, .min = 0, .max = 1}},
|
130
|
+
{.args = {.value = -1, .min = OPT_I64(-1), .max = OPT_I64(0)}, .expect = {.value = 0, .min = 0, .max = 1}},
|
131
|
+
{.args = {.value = -2, .min = OPT_I64(-2), .max = OPT_I64(0)}, .expect = {.value = 0, .min = 0, .max = 2}},
|
132
|
+
{.args = {.value = INT64_C(-9223372036854775807), .min = OPT_I64(INT64_MIN), .max = OPT_I64(1)},
|
133
|
+
.expect = {.value = 1, .min = 0, .max = UINT64_C(9223372036854775809)}},
|
134
|
+
{.args = {.value = INT64_MIN, .min = OPT_I64(INT64_MIN), .max = OPT_I64(0)},
|
135
|
+
.expect = {.value = 0, .min = 0, .max = UINT64_C(9223372036854775808)}},
|
136
|
+
{.args = {.value = 0, .min = OPT_I64(INT64_MIN), .max = OPT_I64(37)},
|
137
|
+
.expect = {.value = UINT64_C(9223372036854775808), .min = 0, .max = UINT64_C(9223372036854775845)}},
|
138
|
+
{.args = {.value = 1, .min = OPT_I64(INT64_MIN), .max = OPT_I64(42)},
|
139
|
+
.expect = {.value = UINT64_C(9223372036854775809), .min = 0, .max = UINT64_C(9223372036854775850)}},
|
140
|
+
{.args = {.value = INT64_C(9223372036854775807),
|
141
|
+
.min = OPT_I64(-9223372036854775807),
|
142
|
+
.max = OPT_I64(9223372036854775807)},
|
143
|
+
.expect = {.value = UINT64_C(18446744073709551614), .min = 0, .max = UINT64_C(18446744073709551614)}},
|
144
|
+
{.args = {.value = INT64_C(9223372036854775807),
|
145
|
+
.min = OPT_I64(INT64_MIN),
|
146
|
+
.max = OPT_I64(9223372036854775807)},
|
147
|
+
.expect = {.value = UINT64_C(18446744073709551615), .min = 0, .max = UINT64_C(18446744073709551615)}},
|
148
|
+
{.args = {.value = 15, .min = OPT_I64(10), .max = OPT_I64(26)}, .expect = {.value = 5, .min = 0, .max = 16}},
|
149
|
+
{.args = {.value = 15, .min = OPT_I64(-10), .max = OPT_I64(55)}, .expect = {.value = 25, .min = 0, .max = 65}},
|
150
|
+
/* Test cases copied from server Int64_Bounds test ... end */
|
151
|
+
/* Test cases copied from server Int64_Errors test ... begin */
|
152
|
+
{.args = {.value = 1, .max = OPT_I64(2)},
|
153
|
+
.expectError = "Must specify both a lower and upper bound or no bounds."},
|
154
|
+
{.args = {.value = 1, .min = OPT_I64(0)},
|
155
|
+
.expectError = "Must specify both a lower and upper bound or no bounds."},
|
156
|
+
{.args = {.value = 1, .min = OPT_I64(2), .max = OPT_I64(1)},
|
157
|
+
.expectError = "The minimum value must be less than the maximum value"},
|
158
|
+
{.args = {.value = 1, .min = OPT_I64(2), .max = OPT_I64(3)},
|
159
|
+
.expectError = "Value must be greater than or equal to the minimum "
|
160
|
+
"value and less than or equal to the maximum value"},
|
161
|
+
{.args = {.value = 4, .min = OPT_I64(2), .max = OPT_I64(3)},
|
162
|
+
.expectError = "Value must be greater than or equal to the minimum "
|
163
|
+
"value and less than or equal to the maximum value"},
|
164
|
+
{.args = {.value = 4, .min = OPT_I64(INT64_MIN), .max = OPT_I64(INT64_MIN)},
|
165
|
+
.expectError = "The minimum value must be less than the maximum value"},
|
166
|
+
/* Test cases copied from server Int64_Errors test ... end */
|
167
|
+
};
|
168
|
+
|
169
|
+
for (size_t i = 0; i < sizeof(tests) / sizeof(tests[0]); i++) {
|
170
|
+
Int64Test *test = tests + i;
|
171
|
+
mongocrypt_status_t *const status = mongocrypt_status_new();
|
172
|
+
|
173
|
+
// Print a description of the test case.
|
174
|
+
printf("_test_RangeTest_Encode_Int64: value=%" PRId64, test->args.value);
|
175
|
+
if (test->args.min.set) {
|
176
|
+
printf(" min=%" PRId64, test->args.min.value);
|
177
|
+
}
|
178
|
+
if (test->args.max.set) {
|
179
|
+
printf(" max=%" PRId64, test->args.max.value);
|
180
|
+
}
|
181
|
+
printf("\n");
|
182
|
+
mc_OSTType_Int64 got;
|
183
|
+
const bool ok = mc_getTypeInfo64(test->args, &got, status);
|
184
|
+
if (test->expectError) {
|
185
|
+
ASSERT_OR_PRINT_MSG(!ok, "expected error, but got none");
|
186
|
+
ASSERT_STATUS_CONTAINS(status, test->expectError);
|
187
|
+
} else {
|
188
|
+
ASSERT_OK_STATUS(ok, status);
|
189
|
+
ASSERT_CMPUINT64(got.value, ==, test->expect.value);
|
190
|
+
ASSERT_CMPUINT64(got.min, ==, test->expect.min);
|
191
|
+
ASSERT_CMPUINT64(got.max, ==, test->expect.max);
|
192
|
+
}
|
193
|
+
mongocrypt_status_destroy(status);
|
194
|
+
}
|
195
|
+
}
|
196
|
+
|
197
|
+
#define INT_64_MAX_DOUBLE (double)18446744073709551615ull
|
198
|
+
|
199
|
+
static void _test_canUsePrecisionModeDouble(_mongocrypt_tester_t *tester) {
|
200
|
+
#define CAN_USE_PRECISION_MODE(lb, ub, prc, expected, expected_bits_out) \
|
201
|
+
{ \
|
202
|
+
uint32_t bits_out = 0; \
|
203
|
+
mongocrypt_status_t *const status = mongocrypt_status_new(); \
|
204
|
+
printf("_test_canUsePrecisionModeDecimal, min: %f, max: %f, prc: %" PRIu32, lb, ub, prc); \
|
205
|
+
bool result = mc_canUsePrecisionModeDouble(lb, ub, prc, &bits_out, status); \
|
206
|
+
ASSERT_OK_STATUS(mongocrypt_status_ok(status), status); \
|
207
|
+
ASSERT(result == expected); \
|
208
|
+
ASSERT_CMPINT32(expected_bits_out, ==, bits_out); \
|
209
|
+
mongocrypt_status_destroy(status); \
|
210
|
+
}
|
211
|
+
|
212
|
+
#define CAN_USE_PRECISION_MODE_ERRORS(lb, ub, prc, error) \
|
213
|
+
{ \
|
214
|
+
mongocrypt_status_t *const status = mongocrypt_status_new(); \
|
215
|
+
printf("_test_canUsePrecisionModeDecimal errors, min: %f, max: %f, prc: %" PRIu32, lb, ub, prc); \
|
216
|
+
uint32_t bits_out = 0; \
|
217
|
+
bool result = mc_canUsePrecisionModeDouble(lb, ub, prc, &bits_out, status); \
|
218
|
+
ASSERT_OR_PRINT_MSG(!result, "expected error, but got none"); \
|
219
|
+
ASSERT_STATUS_CONTAINS(status, error); \
|
220
|
+
mongocrypt_status_destroy(status); \
|
221
|
+
}
|
222
|
+
|
223
|
+
CAN_USE_PRECISION_MODE(1.0, 16.0, 0, true, 4);
|
224
|
+
CAN_USE_PRECISION_MODE(0.0, 16.0, 0, true, 5);
|
225
|
+
// 2^53 + 1 is where double starts to lose precision, so we need to ensure that we get the
|
226
|
+
// correct value for max_bits out.
|
227
|
+
CAN_USE_PRECISION_MODE_ERRORS(1.0, 9007199254740992.0, 0, "Invalid upper bound for double precision. Absolute");
|
228
|
+
CAN_USE_PRECISION_MODE_ERRORS(0.0, 9007199254740992.0, 0, "Invalid upper bound for double precision. Absolute");
|
229
|
+
|
230
|
+
CAN_USE_PRECISION_MODE(2.718281, 314.159265, 6, true, 29);
|
231
|
+
|
232
|
+
CAN_USE_PRECISION_MODE_ERRORS(-1000000000.0,
|
233
|
+
9223372036844775424.0,
|
234
|
+
0,
|
235
|
+
"Invalid upper bound for double precision. Absolute");
|
236
|
+
|
237
|
+
CAN_USE_PRECISION_MODE_ERRORS(2.710000,
|
238
|
+
314.150000,
|
239
|
+
2,
|
240
|
+
"Invalid upper bound for double precision. Fractional digits");
|
241
|
+
CAN_USE_PRECISION_MODE_ERRORS(314.150000, 350.0, 2, "Invalid lower bound for double precision. Fractional digits");
|
242
|
+
|
243
|
+
CAN_USE_PRECISION_MODE_ERRORS((double)9007199254740992,
|
244
|
+
INT_64_MAX_DOUBLE,
|
245
|
+
0,
|
246
|
+
"Invalid upper bound for double precision. Absolute scaled value");
|
247
|
+
CAN_USE_PRECISION_MODE_ERRORS(-1 * INT_64_MAX_DOUBLE,
|
248
|
+
1.0,
|
249
|
+
0,
|
250
|
+
"Invalid lower bound for double precision. Absolute scaled value");
|
251
|
+
CAN_USE_PRECISION_MODE_ERRORS(-92233720368547.0,
|
252
|
+
92233720368547.0,
|
253
|
+
5,
|
254
|
+
"Invalid upper bound for double precision. Absolute");
|
255
|
+
|
256
|
+
#undef CAN_USE_PRECISION_MODE
|
257
|
+
#undef CAN_USE_PRECISION_MODE_ERRORS
|
268
258
|
}
|
269
259
|
|
270
260
|
typedef struct {
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
261
|
+
double value;
|
262
|
+
mc_optional_double_t min;
|
263
|
+
mc_optional_double_t max;
|
264
|
+
mc_optional_int32_t precision;
|
265
|
+
uint64_t expect;
|
266
|
+
mc_optional_uint64_t expectMax;
|
267
|
+
const char *expectError;
|
268
|
+
bool use_range_v1; // By default, use range v2.
|
278
269
|
} DoubleTest;
|
279
270
|
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
// Smaller exponents map to smaller uint64
|
304
|
-
{.value = 1E-6, .expect = UINT64_C (13740701229962882445)},
|
305
|
-
{.value = 1E-7, .expect = UINT64_C (13725520251343122248)},
|
306
|
-
{.value = 1E-8, .expect = UINT64_C (13710498295186492474)},
|
307
|
-
{.value = 1E-56, .expect = UINT64_C (12992711961033031890)},
|
308
|
-
{.value = 1E-57, .expect = UINT64_C (12977434315086142017)},
|
309
|
-
{.value = 1E-58, .expect = UINT64_C (12962510038552207822)},
|
310
|
-
|
311
|
-
// Smaller negative exponents map to smaller uint64
|
312
|
-
{.value = -1E-06, .expect = UINT64_C (4706042843746669171)},
|
313
|
-
{.value = -1E-07, .expect = UINT64_C (4721223822366429368)},
|
314
|
-
{.value = -1E-08, .expect = UINT64_C (4736245778523059142)},
|
315
|
-
{.value = -1E-56, .expect = UINT64_C (5454032112676519726)},
|
316
|
-
{.value = -1E-57, .expect = UINT64_C (5469309758623409599)},
|
317
|
-
{.value = -1E-58, .expect = UINT64_C (5484234035157343794)},
|
318
|
-
|
319
|
-
// Larger exponents map to larger uint64
|
320
|
-
{.value = -33E+56, .expect = UINT64_C (3755770421083717738)},
|
321
|
-
{.value = -22E+57, .expect = UINT64_C (3743606376648545798)},
|
322
|
-
{.value = -11E+58, .expect = UINT64_C (3733055120123088324)},
|
323
|
-
|
324
|
-
{.value = 0, .expect = UINT64_C (9223372036854775808)},
|
325
|
-
{.value = -0.0, .expect = UINT64_C (9223372036854775808)},
|
326
|
-
/* Test cases copied from server Double_Bounds test ... end */
|
327
|
-
/* Test cases copied from server Double_Errors test ... begin */
|
328
|
-
{.value = INFINITY,
|
329
|
-
.expectError = "Infinity and NaN double values are not supported."},
|
330
|
-
{.value = NAN,
|
331
|
-
.expectError = "Infinity and NaN double values are not supported."},
|
332
|
-
/* Test cases copied from server Double_Errors test ... end */
|
333
|
-
|
334
|
-
/* Test cases copied from Double_Bounds_Precision ... begin */
|
335
|
-
{.value = 3.141592653589,
|
336
|
-
.precision = OPT_U32_C (1),
|
337
|
-
.min = OPT_DOUBLE_C (-100000),
|
338
|
-
.max = OPT_DOUBLE_C (100000),
|
339
|
-
.expect = UINT64_C (1000031),
|
340
|
-
.expectMax = OPT_U64_C (2097151)},
|
341
|
-
{.value = 3.141592653589,
|
342
|
-
.precision = OPT_U32_C (2),
|
343
|
-
.min = OPT_DOUBLE_C (-100000),
|
344
|
-
.max = OPT_DOUBLE_C (100000),
|
345
|
-
.expect = 10000314,
|
346
|
-
.expectMax = OPT_U64_C (33554431)},
|
347
|
-
{.value = 3.141592653589,
|
348
|
-
.precision = OPT_U32_C (3),
|
349
|
-
.min = OPT_DOUBLE_C (-100000),
|
350
|
-
.max = OPT_DOUBLE_C (100000),
|
351
|
-
.expect = 100003141,
|
352
|
-
.expectMax = OPT_U64_C (268435455)},
|
353
|
-
{.value = 3.141592653589,
|
354
|
-
.precision = OPT_U32_C (4),
|
355
|
-
.min = OPT_DOUBLE_C (-100000),
|
356
|
-
.max = OPT_DOUBLE_C (100000),
|
357
|
-
.expect = 1000031415,
|
358
|
-
.expectMax = OPT_U64_C (2147483647)},
|
359
|
-
{.value = 3.141592653589,
|
360
|
-
.precision = OPT_U32_C (5),
|
361
|
-
.min = OPT_DOUBLE_C (-100000),
|
362
|
-
.max = OPT_DOUBLE_C (100000),
|
363
|
-
.expect = 10000314159,
|
364
|
-
.expectMax = OPT_U64_C (34359738367)},
|
365
|
-
{.value = 3.141592653589,
|
366
|
-
.precision = OPT_U32_C (6),
|
367
|
-
.min = OPT_DOUBLE_C (-100000),
|
368
|
-
.max = OPT_DOUBLE_C (100000),
|
369
|
-
.expect = 100003141592,
|
370
|
-
.expectMax = OPT_U64_C (274877906943)},
|
371
|
-
{.value = 3.141592653589,
|
372
|
-
.precision = OPT_U32_C (7),
|
373
|
-
.min = OPT_DOUBLE_C (-100000),
|
374
|
-
.max = OPT_DOUBLE_C (100000),
|
375
|
-
.expect = 1000031415926,
|
376
|
-
.expectMax = OPT_U64_C (2199023255551)},
|
377
|
-
{.value = 0,
|
378
|
-
.max = OPT_DOUBLE_C (1),
|
379
|
-
.min = OPT_DOUBLE_C (-1),
|
380
|
-
.precision = OPT_U32_C (3),
|
381
|
-
.expect = 1000,
|
382
|
-
.expectMax = OPT_U64_C (4095)},
|
383
|
-
{.value = 0,
|
384
|
-
.max = OPT_DOUBLE_C (1),
|
385
|
-
.min = OPT_DOUBLE_C (-1E5),
|
386
|
-
.precision = OPT_U32_C (3),
|
387
|
-
.expect = 100000000,
|
388
|
-
.expectMax = OPT_U64_C (134217727)},
|
389
|
-
{.value = -1E-33,
|
390
|
-
.max = OPT_DOUBLE_C (1),
|
391
|
-
.min = OPT_DOUBLE_C (-1E5),
|
392
|
-
.precision = OPT_U32_C (3),
|
393
|
-
.expect = 100000000,
|
394
|
-
.expectMax = OPT_U64_C (134217727)},
|
395
|
-
{.value = 0,
|
396
|
-
.max = OPT_DOUBLE_C (DBL_MAX),
|
397
|
-
.min = OPT_DOUBLE_C (-DBL_MAX),
|
398
|
-
.precision = OPT_U32_C (3),
|
399
|
-
.expect = UINT64_C (9223372036854775808),
|
400
|
-
// Expect precision not to be used.
|
401
|
-
.expectMax = OPT_U64_C (UINT64_MAX)},
|
402
|
-
{.value = 3.141592653589,
|
403
|
-
.max = OPT_DOUBLE_C (5),
|
404
|
-
.min = OPT_DOUBLE_C (0),
|
405
|
-
.precision = OPT_U32_C (0),
|
406
|
-
.expect = 3,
|
407
|
-
.expectMax = OPT_U64_C (7)},
|
408
|
-
{.value = 3.141592653589,
|
409
|
-
.max = OPT_DOUBLE_C (5),
|
410
|
-
.min = OPT_DOUBLE_C (0),
|
411
|
-
.precision = OPT_U32_C (1),
|
412
|
-
.expect = 31,
|
413
|
-
.expectMax = OPT_U64_C (63)},
|
414
|
-
{.value = 3.141592653589,
|
415
|
-
.max = OPT_DOUBLE_C (5),
|
416
|
-
.min = OPT_DOUBLE_C (0),
|
417
|
-
.precision = OPT_U32_C (2),
|
418
|
-
.expect = 314,
|
419
|
-
.expectMax = OPT_U64_C (1023)},
|
420
|
-
{.value = 3.141592653589,
|
421
|
-
.max = OPT_DOUBLE_C (5),
|
422
|
-
.min = OPT_DOUBLE_C (0),
|
423
|
-
.precision = OPT_U32_C (3),
|
424
|
-
.expect = 3141,
|
425
|
-
.expectMax = OPT_U64_C (8191)},
|
426
|
-
{.value = 3.141592653589,
|
427
|
-
.max = OPT_DOUBLE_C (5),
|
428
|
-
.min = OPT_DOUBLE_C (0),
|
429
|
-
.precision = OPT_U32_C (16),
|
430
|
-
.expect = 31415926535890000,
|
431
|
-
.expectMax = OPT_U64_C (72057594037927935)},
|
432
|
-
{.value = -5,
|
433
|
-
.max = OPT_DOUBLE_C (-1),
|
434
|
-
.min = OPT_DOUBLE_C (-10),
|
435
|
-
.precision = OPT_U32_C (3),
|
436
|
-
.expect = 5000,
|
437
|
-
.expectMax = OPT_U64_C (16383)},
|
438
|
-
{.value = 1E100,
|
439
|
-
.max = OPT_DOUBLE_C (DBL_MAX),
|
440
|
-
.min = OPT_DOUBLE_C (-DBL_MAX),
|
441
|
-
.precision = OPT_U32_C (3),
|
442
|
-
.expect = 15326393489903895421ULL,
|
443
|
-
// Expect precision not to be used.
|
444
|
-
.expectMax = OPT_U64_C (UINT64_MAX)},
|
445
|
-
{.value = 1E9,
|
446
|
-
.max = OPT_DOUBLE_C (1E10),
|
447
|
-
.min = OPT_DOUBLE_C (0),
|
448
|
-
.precision = OPT_U32_C (3),
|
449
|
-
.expect = 1000000000000,
|
450
|
-
.expectMax = OPT_U64_C (17592186044415)},
|
451
|
-
{.value = 1E9,
|
452
|
-
.max = OPT_DOUBLE_C (1E10),
|
453
|
-
.min = OPT_DOUBLE_C (0),
|
454
|
-
.precision = OPT_U32_C (0),
|
455
|
-
.expect = 1000000000,
|
456
|
-
.expectMax = OPT_U64_C (17179869183)},
|
457
|
-
{.value = -5,
|
458
|
-
.max = OPT_DOUBLE_C (10),
|
459
|
-
.min = OPT_DOUBLE_C (-10),
|
460
|
-
.precision = OPT_U32_C (0),
|
461
|
-
.expect = 5,
|
462
|
-
.expectMax = OPT_U64_C (31)},
|
463
|
-
{.value = -5,
|
464
|
-
.max = OPT_DOUBLE_C (10),
|
465
|
-
.min = OPT_DOUBLE_C (-10),
|
466
|
-
.precision = OPT_U32_C (2),
|
467
|
-
.expect = 500,
|
468
|
-
.expectMax = OPT_U64_C (4095)},
|
469
|
-
{.value = 1E-30,
|
470
|
-
.max = OPT_DOUBLE_C (10E-30),
|
471
|
-
.min = OPT_DOUBLE_C (1E-30),
|
472
|
-
.precision = OPT_U32_C (35),
|
473
|
-
.expect = 13381399884061196960ULL,
|
474
|
-
// Expect precision not to be used.
|
475
|
-
.expectMax = OPT_U64_C (UINT64_MAX)},
|
476
|
-
/* Test cases copied from Double_Bounds_Precision ... end */
|
477
|
-
{.value = -1,
|
478
|
-
.min = OPT_DOUBLE_C (0),
|
479
|
-
.max = OPT_DOUBLE_C (200),
|
480
|
-
.precision = OPT_U32_C (1),
|
481
|
-
.expectError = "greater than or equal to the minimum value"},
|
482
|
-
{.value = -1,
|
483
|
-
.min = OPT_DOUBLE_C (0),
|
484
|
-
.max = OPT_DOUBLE_C (201),
|
485
|
-
.precision = OPT_U32_C (1),
|
486
|
-
.expectError = "less than or equal to the maximum value"}};
|
487
|
-
|
488
|
-
for (size_t i = 0; i < sizeof (tests) / sizeof (tests[0]); i++) {
|
489
|
-
DoubleTest *test = tests + i;
|
490
|
-
mongocrypt_status_t *const status = mongocrypt_status_new ();
|
491
|
-
|
492
|
-
if (test->min.set && test->max.set && test->precision.set) {
|
493
|
-
printf ("_test_RangeTest_Encode_Double: value=%f, min=%f, max=%f, "
|
494
|
-
"precision=%" PRIu32 "\n",
|
495
|
-
test->value,
|
496
|
-
test->min.value,
|
497
|
-
test->max.value,
|
498
|
-
test->precision.value);
|
499
|
-
} else {
|
500
|
-
printf ("_test_RangeTest_Encode_Double: value=%f\n", test->value);
|
501
|
-
}
|
502
|
-
|
503
|
-
mc_OSTType_Double got;
|
504
|
-
const bool ok = mc_getTypeInfoDouble (
|
505
|
-
(mc_getTypeInfoDouble_args_t){.value = test->value,
|
506
|
-
.min = test->min,
|
507
|
-
.max = test->max,
|
508
|
-
.precision = test->precision},
|
509
|
-
&got,
|
510
|
-
status);
|
511
|
-
if (test->expectError) {
|
512
|
-
ASSERT_OR_PRINT_MSG (!ok, "expected error, but got none");
|
513
|
-
ASSERT_STATUS_CONTAINS (status, test->expectError);
|
514
|
-
} else {
|
515
|
-
ASSERT_OK_STATUS (ok, status);
|
516
|
-
ASSERT_CMPUINT64 (got.value, ==, test->expect);
|
517
|
-
ASSERT_CMPUINT64 (got.min, ==, 0);
|
518
|
-
ASSERT_CMPUINT64 (got.max,
|
519
|
-
==,
|
520
|
-
test->expectMax.set ? test->expectMax.value
|
521
|
-
: UINT64_MAX);
|
522
|
-
}
|
523
|
-
mongocrypt_status_destroy (status);
|
524
|
-
}
|
525
|
-
}
|
271
|
+
// Smallest and Largest integer that fits in a double before precision is lost
|
272
|
+
#define DOUBLE_MIN_SAFE_INT -9007199254740992 // -2^53
|
273
|
+
#define DOUBLE_MAX_SAFE_INT 9007199254740992 // 2^53
|
274
|
+
|
275
|
+
static void _test_RangeTest_Encode_Double(_mongocrypt_tester_t *tester) {
|
276
|
+
DoubleTest tests[] = {/* Test cases copied from server Double_Bounds test ... begin */
|
277
|
+
// Larger numbers map to larger uint64
|
278
|
+
{.value = -1111, .expect = UINT64_C(4570770991734587392)},
|
279
|
+
{.value = -111, .expect = UINT64_C(4585860689314185216)},
|
280
|
+
{.value = -11, .expect = UINT64_C(4600989969312382976)},
|
281
|
+
{.value = -10, .expect = UINT64_C(4601552919265804288)},
|
282
|
+
{.value = -3, .expect = UINT64_C(4609434218613702656)},
|
283
|
+
{.value = -2, .expect = UINT64_C(4611686018427387904)},
|
284
|
+
|
285
|
+
{.value = -1, .expect = UINT64_C(4616189618054758400)},
|
286
|
+
{.value = 1, .expect = UINT64_C(13830554455654793216)},
|
287
|
+
{.value = 22, .expect = UINT64_C(13850257704024539136)},
|
288
|
+
{.value = 333, .expect = UINT64_C(13867937850999177216)},
|
289
|
+
|
290
|
+
// Larger exponents map to larger uint64
|
291
|
+
{.value = 33E56, .expect = UINT64_C(14690973652625833878)},
|
292
|
+
{.value = 22E57, .expect = UINT64_C(14703137697061005818)},
|
293
|
+
{.value = 11E58, .expect = UINT64_C(14713688953586463292)},
|
526
294
|
|
295
|
+
// Smaller exponents map to smaller uint64
|
296
|
+
{.value = 1E-6, .expect = UINT64_C(13740701229962882445)},
|
297
|
+
{.value = 1E-7, .expect = UINT64_C(13725520251343122248)},
|
298
|
+
{.value = 1E-8, .expect = UINT64_C(13710498295186492474)},
|
299
|
+
{.value = 1E-56, .expect = UINT64_C(12992711961033031890)},
|
300
|
+
{.value = 1E-57, .expect = UINT64_C(12977434315086142017)},
|
301
|
+
{.value = 1E-58, .expect = UINT64_C(12962510038552207822)},
|
302
|
+
|
303
|
+
// Smaller negative exponents map to smaller uint64
|
304
|
+
{.value = -1E-06, .expect = UINT64_C(4706042843746669171)},
|
305
|
+
{.value = -1E-07, .expect = UINT64_C(4721223822366429368)},
|
306
|
+
{.value = -1E-08, .expect = UINT64_C(4736245778523059142)},
|
307
|
+
{.value = -1E-56, .expect = UINT64_C(5454032112676519726)},
|
308
|
+
{.value = -1E-57, .expect = UINT64_C(5469309758623409599)},
|
309
|
+
{.value = -1E-58, .expect = UINT64_C(5484234035157343794)},
|
310
|
+
|
311
|
+
// Larger exponents map to larger uint64
|
312
|
+
{.value = -33E+56, .expect = UINT64_C(3755770421083717738)},
|
313
|
+
{.value = -22E+57, .expect = UINT64_C(3743606376648545798)},
|
314
|
+
{.value = -11E+58, .expect = UINT64_C(3733055120123088324)},
|
315
|
+
|
316
|
+
{.value = 0, .expect = UINT64_C(9223372036854775808)},
|
317
|
+
{.value = -0.0, .expect = UINT64_C(9223372036854775808)},
|
318
|
+
/* Test cases copied from server Double_Bounds test ... end */
|
319
|
+
/* Test cases copied from server Double_Errors test ... begin */
|
320
|
+
{.value = INFINITY, .expectError = "Infinity and NaN double values are not supported."},
|
321
|
+
{.value = NAN, .expectError = "Infinity and NaN double values are not supported."},
|
322
|
+
/* Test cases copied from server Double_Errors test ... end */
|
323
|
+
|
324
|
+
/* Test cases copied from Double_Bounds_Precision ... begin */
|
325
|
+
{.value = 3.141592653589,
|
326
|
+
.precision = OPT_I32_C(1),
|
327
|
+
.min = OPT_DOUBLE_C(-100000),
|
328
|
+
.max = OPT_DOUBLE_C(100000),
|
329
|
+
.expect = UINT64_C(1000031),
|
330
|
+
.expectMax = OPT_U64_C(2097151)},
|
331
|
+
{.value = 3.141592653589,
|
332
|
+
.precision = OPT_I32_C(2),
|
333
|
+
.min = OPT_DOUBLE_C(-100000),
|
334
|
+
.max = OPT_DOUBLE_C(100000),
|
335
|
+
.expect = 10000314,
|
336
|
+
.expectMax = OPT_U64_C(33554431)},
|
337
|
+
{.value = 3.141592653589,
|
338
|
+
.precision = OPT_I32_C(3),
|
339
|
+
.min = OPT_DOUBLE_C(-100000),
|
340
|
+
.max = OPT_DOUBLE_C(100000),
|
341
|
+
.expect = 100003141,
|
342
|
+
.expectMax = OPT_U64_C(268435455)},
|
343
|
+
{.value = 3.141592653589,
|
344
|
+
.precision = OPT_I32_C(4),
|
345
|
+
.min = OPT_DOUBLE_C(-100000),
|
346
|
+
.max = OPT_DOUBLE_C(100000),
|
347
|
+
.expect = 1000031415,
|
348
|
+
.expectMax = OPT_U64_C(2147483647)},
|
349
|
+
{.value = 3.141592653589,
|
350
|
+
.precision = OPT_I32_C(5),
|
351
|
+
.min = OPT_DOUBLE_C(-100000),
|
352
|
+
.max = OPT_DOUBLE_C(100000),
|
353
|
+
.expect = 10000314159,
|
354
|
+
.expectMax = OPT_U64_C(34359738367)},
|
355
|
+
{.value = 3.141592653589,
|
356
|
+
.precision = OPT_I32_C(6),
|
357
|
+
.min = OPT_DOUBLE_C(-100000),
|
358
|
+
.max = OPT_DOUBLE_C(100000),
|
359
|
+
.expect = 100003141592,
|
360
|
+
.expectMax = OPT_U64_C(274877906943)},
|
361
|
+
{.value = 3.141592653589,
|
362
|
+
.precision = OPT_I32_C(7),
|
363
|
+
.min = OPT_DOUBLE_C(-100000),
|
364
|
+
.max = OPT_DOUBLE_C(100000),
|
365
|
+
.expect = 1000031415926,
|
366
|
+
.expectMax = OPT_U64_C(2199023255551)},
|
367
|
+
{.value = 0,
|
368
|
+
.max = OPT_DOUBLE_C(1),
|
369
|
+
.min = OPT_DOUBLE_C(-1),
|
370
|
+
.precision = OPT_I32_C(3),
|
371
|
+
.expect = 1000,
|
372
|
+
.expectMax = OPT_U64_C(4095)},
|
373
|
+
{.value = 0,
|
374
|
+
.max = OPT_DOUBLE_C(1),
|
375
|
+
.min = OPT_DOUBLE_C(-1E5),
|
376
|
+
.precision = OPT_I32_C(3),
|
377
|
+
.expect = 100000000,
|
378
|
+
.expectMax = OPT_U64_C(134217727)},
|
379
|
+
{.value = -1E-33,
|
380
|
+
.max = OPT_DOUBLE_C(1),
|
381
|
+
.min = OPT_DOUBLE_C(-1E5),
|
382
|
+
.precision = OPT_I32_C(3),
|
383
|
+
.expect = 100000000,
|
384
|
+
.expectMax = OPT_U64_C(134217727)},
|
385
|
+
{.value = 0,
|
386
|
+
.max = OPT_DOUBLE_C(DBL_MAX),
|
387
|
+
.min = OPT_DOUBLE_C(-DBL_MAX),
|
388
|
+
.precision = OPT_I32_C(3),
|
389
|
+
// Applying min/max/precision result in a domain needing >= 64 bits to represent.
|
390
|
+
// For range v2, expect an error.
|
391
|
+
.expectError = "Invalid upper bound for double precision."},
|
392
|
+
{.value = 0,
|
393
|
+
.max = OPT_DOUBLE_C(DBL_MAX),
|
394
|
+
.min = OPT_DOUBLE_C(-DBL_MAX),
|
395
|
+
.precision = OPT_I32_C(3),
|
396
|
+
// Applying min/max/precision result in a domain needing >= 64 bits to represent.
|
397
|
+
// For range v2, expect an error.
|
398
|
+
.expectError = "Invalid upper bound for double precision."},
|
399
|
+
{.value = 3.141592653589,
|
400
|
+
.max = OPT_DOUBLE_C(5),
|
401
|
+
.min = OPT_DOUBLE_C(0),
|
402
|
+
.precision = OPT_I32_C(0),
|
403
|
+
.expect = 3,
|
404
|
+
.expectMax = OPT_U64_C(7)},
|
405
|
+
{.value = 3.141592653589,
|
406
|
+
.max = OPT_DOUBLE_C(5),
|
407
|
+
.min = OPT_DOUBLE_C(0),
|
408
|
+
.precision = OPT_I32_C(1),
|
409
|
+
.expect = 31,
|
410
|
+
.expectMax = OPT_U64_C(63)},
|
411
|
+
{.value = 3.141592653589,
|
412
|
+
.max = OPT_DOUBLE_C(5),
|
413
|
+
.min = OPT_DOUBLE_C(0),
|
414
|
+
.precision = OPT_I32_C(2),
|
415
|
+
.expect = 314,
|
416
|
+
.expectMax = OPT_U64_C(1023)},
|
417
|
+
{.value = 3.141592653589,
|
418
|
+
.max = OPT_DOUBLE_C(5),
|
419
|
+
.min = OPT_DOUBLE_C(0),
|
420
|
+
.precision = OPT_I32_C(3),
|
421
|
+
.expect = 3141,
|
422
|
+
.expectMax = OPT_U64_C(8191)},
|
423
|
+
{.value = 3.141592653589,
|
424
|
+
.max = OPT_DOUBLE_C(5),
|
425
|
+
.min = OPT_DOUBLE_C(0),
|
426
|
+
.precision = OPT_I32_C(16),
|
427
|
+
.expectError = "Invalid upper bound for double precision"},
|
428
|
+
{.value = -5,
|
429
|
+
.max = OPT_DOUBLE_C(-1),
|
430
|
+
.min = OPT_DOUBLE_C(-10),
|
431
|
+
.precision = OPT_I32_C(3),
|
432
|
+
.expect = 5000,
|
433
|
+
.expectMax = OPT_U64_C(16383)},
|
434
|
+
{.value = 1E100,
|
435
|
+
.max = OPT_DOUBLE_C(DBL_MAX),
|
436
|
+
.min = OPT_DOUBLE_C(-DBL_MAX),
|
437
|
+
.precision = OPT_I32_C(3),
|
438
|
+
// Applying min/max/precision result in a domain needing >= 64 bits to represent.
|
439
|
+
// For range v2, expect an error.
|
440
|
+
.expectError = "Invalid upper bound for double precision."},
|
441
|
+
{.value = 1E100,
|
442
|
+
.max = OPT_DOUBLE_C(DBL_MAX),
|
443
|
+
.min = OPT_DOUBLE_C(-DBL_MAX),
|
444
|
+
.precision = OPT_I32_C(3),
|
445
|
+
// Applying min/max/precision result in a domain needing >= 64 bits to represent.
|
446
|
+
// For range v2, expect an error.
|
447
|
+
.expectError = "Invalid upper bound for double precision."},
|
448
|
+
{.value = 1E9,
|
449
|
+
.max = OPT_DOUBLE_C(1E10),
|
450
|
+
.min = OPT_DOUBLE_C(0),
|
451
|
+
.precision = OPT_I32_C(3),
|
452
|
+
.expect = 1000000000000,
|
453
|
+
.expectMax = OPT_U64_C(17592186044415)},
|
454
|
+
{.value = 1E9,
|
455
|
+
.max = OPT_DOUBLE_C(1E10),
|
456
|
+
.min = OPT_DOUBLE_C(0),
|
457
|
+
.precision = OPT_I32_C(0),
|
458
|
+
.expect = 1000000000,
|
459
|
+
.expectMax = OPT_U64_C(17179869183)},
|
460
|
+
{.value = -5,
|
461
|
+
.max = OPT_DOUBLE_C(10),
|
462
|
+
.min = OPT_DOUBLE_C(-10),
|
463
|
+
.precision = OPT_I32_C(0),
|
464
|
+
.expect = 5,
|
465
|
+
.expectMax = OPT_U64_C(31)},
|
466
|
+
{.value = -5,
|
467
|
+
.max = OPT_DOUBLE_C(10),
|
468
|
+
.min = OPT_DOUBLE_C(-10),
|
469
|
+
.precision = OPT_I32_C(2),
|
470
|
+
.expect = 500,
|
471
|
+
.expectMax = OPT_U64_C(4095)},
|
472
|
+
{.value = 1E-30,
|
473
|
+
.max = OPT_DOUBLE_C(10E-30),
|
474
|
+
.min = OPT_DOUBLE_C(1E-30),
|
475
|
+
.precision = OPT_I32_C(35),
|
476
|
+
// Applying min/max/precision result in a domain needing >= 53 bits to represent.
|
477
|
+
// For range v2, expect an error.
|
478
|
+
.expectError = "Invalid upper bound for double precision."},
|
479
|
+
{.value = 1E-30,
|
480
|
+
.max = OPT_DOUBLE_C(10E-30),
|
481
|
+
.min = OPT_DOUBLE_C(1E-30),
|
482
|
+
.precision = OPT_I32_C(35),
|
483
|
+
// Applying min/max/precision result in a domain needing >= 53 bits to represent.
|
484
|
+
// For range v2, expect an error.
|
485
|
+
.expectError = "Invalid upper bound for double precision."},
|
486
|
+
/* Test max and min integer bounds for doubles */
|
487
|
+
{.value = DOUBLE_MIN_SAFE_INT,
|
488
|
+
.max = OPT_DOUBLE_C(DOUBLE_MAX_SAFE_INT),
|
489
|
+
.min = OPT_DOUBLE_C(DOUBLE_MIN_SAFE_INT),
|
490
|
+
.precision = OPT_I32_C(0),
|
491
|
+
.expect = 0,
|
492
|
+
// Applying min/max/precision result in a domain needing >= 53 bits to represent.
|
493
|
+
// For range v2, expect an error.
|
494
|
+
.expectError = "Invalid upper bound for double precision. Absolute"},
|
495
|
+
{.value = 900719925474099.6,
|
496
|
+
.max = OPT_DOUBLE_C(900719925474100.0),
|
497
|
+
.min = OPT_DOUBLE_C(900719925474099.0),
|
498
|
+
.precision = OPT_I32_C(0),
|
499
|
+
.expect = 0,
|
500
|
+
.expectMax = OPT_U64_C(1)},
|
501
|
+
// Domain size is small but min/max * 10^precision loses precision.
|
502
|
+
{.value = 900719925474099.6,
|
503
|
+
.max = OPT_DOUBLE_C(900719925474100.0),
|
504
|
+
.min = OPT_DOUBLE_C(900719925474099.0),
|
505
|
+
.precision = OPT_I32_C(1),
|
506
|
+
.expectError = "Invalid upper bound for double precision. Absolute"},
|
507
|
+
{.value = -900719925474099.6,
|
508
|
+
.max = OPT_DOUBLE_C(-900719925474099.0),
|
509
|
+
.min = OPT_DOUBLE_C(-900719925474100.0),
|
510
|
+
.precision = OPT_I32_C(1),
|
511
|
+
.expectError = "Invalid lower bound for double precision. Absolute"},
|
512
|
+
// 2^52
|
513
|
+
// The expected values increase by 4503599627370496 * 2^(i-52) + j
|
514
|
+
// i.e. the gaps between integers as the exponent increases since doubles lose precision as
|
515
|
+
// the exponent increases
|
516
|
+
{.value = 0,
|
517
|
+
.max = OPT_DOUBLE_C(4503599627370496),
|
518
|
+
.min = OPT_DOUBLE_C(-4503599627370496),
|
519
|
+
.precision = OPT_I32_C(0),
|
520
|
+
.expect = 0,
|
521
|
+
// Applying min/max/precision result in a domain needing >= 53 bits to represent.
|
522
|
+
// For range v2, expect an error.
|
523
|
+
.expectError = "The domain of double values specified by the min"},
|
524
|
+
/* Test cases copied from Double_Bounds_Precision ... end */
|
525
|
+
{.value = -1,
|
526
|
+
.min = OPT_DOUBLE_C(0),
|
527
|
+
.max = OPT_DOUBLE_C(200),
|
528
|
+
.precision = OPT_I32_C(1),
|
529
|
+
.expectError = "greater than or equal to the minimum value"},
|
530
|
+
{.value = -1,
|
531
|
+
.min = OPT_DOUBLE_C(0),
|
532
|
+
.max = OPT_DOUBLE_C(201),
|
533
|
+
.precision = OPT_I32_C(1),
|
534
|
+
.expectError = "less than or equal to the maximum value"},
|
535
|
+
{// Expect error due to precision exceeding INT32_MAX.
|
536
|
+
.value = 1,
|
537
|
+
.min = OPT_DOUBLE_C(1),
|
538
|
+
.max = OPT_DOUBLE_C(2),
|
539
|
+
.precision = OPT_I32_C(-1),
|
540
|
+
.expectError = "Precision must be non-negative"},
|
541
|
+
{// Expect error due to precision exceeding max finite double.
|
542
|
+
// The largest double value is 1.7976931348623157x10^308. 10^309 results in infinity.
|
543
|
+
.value = 1,
|
544
|
+
.min = OPT_DOUBLE_C(0),
|
545
|
+
.max = OPT_DOUBLE_C(1),
|
546
|
+
.precision = OPT_I32_C(309),
|
547
|
+
.expectError = "Precision is too large"}};
|
548
|
+
|
549
|
+
for (size_t i = 0; i < sizeof(tests) / sizeof(tests[0]); i++) {
|
550
|
+
DoubleTest *test = tests + i;
|
551
|
+
mongocrypt_status_t *const status = mongocrypt_status_new();
|
552
|
+
|
553
|
+
if (test->min.set && test->max.set && test->precision.set) {
|
554
|
+
printf("_test_RangeTest_Encode_Double: value=%f, min=%f, max=%f, "
|
555
|
+
"precision=%" PRIu32 "\n",
|
556
|
+
test->value,
|
557
|
+
test->min.value,
|
558
|
+
test->max.value,
|
559
|
+
test->precision.value);
|
560
|
+
} else {
|
561
|
+
printf("_test_RangeTest_Encode_Double: value=%f\n", test->value);
|
562
|
+
}
|
563
|
+
|
564
|
+
const bool use_range_v2 = !test->use_range_v1;
|
565
|
+
mc_OSTType_Double got;
|
566
|
+
const bool ok = mc_getTypeInfoDouble((mc_getTypeInfoDouble_args_t){.value = test->value,
|
567
|
+
.min = test->min,
|
568
|
+
.max = test->max,
|
569
|
+
.precision = test->precision},
|
570
|
+
&got,
|
571
|
+
status,
|
572
|
+
use_range_v2);
|
573
|
+
if (test->expectError) {
|
574
|
+
ASSERT_OR_PRINT_MSG(!ok, "expected error, but got none");
|
575
|
+
ASSERT_STATUS_CONTAINS(status, test->expectError);
|
576
|
+
} else {
|
577
|
+
ASSERT_OK_STATUS(ok, status);
|
578
|
+
ASSERT_CMPUINT64(got.value, ==, test->expect);
|
579
|
+
ASSERT_CMPUINT64(got.min, ==, 0);
|
580
|
+
ASSERT_CMPUINT64(got.max, ==, test->expectMax.set ? test->expectMax.value : UINT64_MAX);
|
581
|
+
}
|
582
|
+
mongocrypt_status_destroy(status);
|
583
|
+
}
|
584
|
+
}
|
527
585
|
|
528
586
|
#if MONGOCRYPT_HAVE_DECIMAL128_SUPPORT
|
529
587
|
typedef struct {
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
588
|
+
mc_dec128 value;
|
589
|
+
mc_optional_dec128_t min;
|
590
|
+
mc_optional_dec128_t max;
|
591
|
+
mc_optional_int32_t precision;
|
592
|
+
mlib_int128 expect;
|
593
|
+
const char *expectError;
|
594
|
+
bool use_range_v1; // By default, use range v2.
|
536
595
|
} Decimal128Test;
|
537
596
|
|
538
|
-
static void
|
539
|
-
|
540
|
-
{
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
|
645
|
-
|
646
|
-
|
647
|
-
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
|
667
|
-
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
|
684
|
-
|
685
|
-
|
686
|
-
|
687
|
-
|
688
|
-
|
689
|
-
|
690
|
-
|
691
|
-
|
692
|
-
|
693
|
-
|
694
|
-
|
695
|
-
|
696
|
-
|
697
|
-
|
698
|
-
|
597
|
+
static void _test_canUsePrecisionModeDecimal(_mongocrypt_tester_t *tester) {
|
598
|
+
#define CAN_USE_PRECISION_MODE(lb, ub, prc, expected, expected_bits_out) \
|
599
|
+
{ \
|
600
|
+
uint32_t bits_out = 0; \
|
601
|
+
mongocrypt_status_t *const status = mongocrypt_status_new(); \
|
602
|
+
printf("_test_canUsePrecisionModeDecimal, min: %s, max: %s, prc: %" PRIu32, \
|
603
|
+
mc_dec128_to_string(lb).str, \
|
604
|
+
mc_dec128_to_string(ub).str, \
|
605
|
+
prc); \
|
606
|
+
bool result = mc_canUsePrecisionModeDecimal(lb, ub, prc, &bits_out, status); \
|
607
|
+
ASSERT_OK_STATUS(mongocrypt_status_ok(status), status); \
|
608
|
+
ASSERT(result == expected); \
|
609
|
+
ASSERT_CMPINT32(expected_bits_out, ==, bits_out); \
|
610
|
+
mongocrypt_status_destroy(status); \
|
611
|
+
}
|
612
|
+
|
613
|
+
#define CAN_USE_PRECISION_MODE_ERRORS(lb, ub, prc, error) \
|
614
|
+
{ \
|
615
|
+
mongocrypt_status_t *const status = mongocrypt_status_new(); \
|
616
|
+
printf("_test_canUsePrecisionModeDecimal errors, min: %s, max: %s, prc: %" PRIu32, \
|
617
|
+
mc_dec128_to_string(lb).str, \
|
618
|
+
mc_dec128_to_string(ub).str, \
|
619
|
+
prc); \
|
620
|
+
uint32_t bits_out = 0; \
|
621
|
+
bool result = mc_canUsePrecisionModeDecimal(lb, ub, prc, &bits_out, status); \
|
622
|
+
ASSERT_OR_PRINT_MSG(!result, "expected error, but got none"); \
|
623
|
+
ASSERT_STATUS_CONTAINS(status, error); \
|
624
|
+
mongocrypt_status_destroy(status); \
|
625
|
+
}
|
626
|
+
|
627
|
+
CAN_USE_PRECISION_MODE(MC_DEC128(1), MC_DEC128(16), 0, true, 4);
|
628
|
+
CAN_USE_PRECISION_MODE(MC_DEC128(0), MC_DEC128(16), 0, true, 5);
|
629
|
+
|
630
|
+
// It is unclear where Decimal128 looses precision, so we choose an arbitrarily large value
|
631
|
+
// and make sure that max_bits is correct for that boundary.
|
632
|
+
CAN_USE_PRECISION_MODE(MC_DEC128(1), mc_dec128_from_string("324518553658426726783156020576256"), 0, true, 108);
|
633
|
+
CAN_USE_PRECISION_MODE(MC_DEC128(0), mc_dec128_from_string("324518553658426726783156020576256"), 0, true, 109);
|
634
|
+
|
635
|
+
CAN_USE_PRECISION_MODE(mc_dec128_from_string("-100000000000000000000000000000000"),
|
636
|
+
mc_dec128_from_string("170141183460469231731687303715880000000"),
|
637
|
+
0,
|
638
|
+
false,
|
639
|
+
128);
|
640
|
+
|
641
|
+
CAN_USE_PRECISION_MODE_ERRORS(mc_dec128_from_string("788545.12392843"),
|
642
|
+
mc_dec128_from_string("4607431769000000.129834923"),
|
643
|
+
4,
|
644
|
+
"Invalid upper bound for Decimal128 precision. Fractional digits");
|
645
|
+
CAN_USE_PRECISION_MODE_ERRORS(mc_dec128_from_string("788545.12392843"),
|
646
|
+
mc_dec128_from_string("7885451.2"),
|
647
|
+
4,
|
648
|
+
"Invalid lower bound for Decimal128 precision. Fractional digits");
|
649
|
+
CAN_USE_PRECISION_MODE_ERRORS(mc_dec128_from_string("324518553658426726783156020576256"),
|
650
|
+
mc_dec128_from_string("340282366920938463463374607431768211455"),
|
651
|
+
10,
|
652
|
+
"Invalid upper bound for Decimal128 precision. Absolute scaled");
|
653
|
+
|
654
|
+
CAN_USE_PRECISION_MODE_ERRORS(mc_dec128_from_string("-340282366920938463463374607431768211455"),
|
655
|
+
mc_dec128_from_string("-3245185536584267267831560"),
|
656
|
+
10,
|
657
|
+
"Invalid lower bound for Decimal128 precision. Absolute scaled");
|
658
|
+
|
659
|
+
CAN_USE_PRECISION_MODE_ERRORS(mc_dec128_from_string("-17014118346046923173168730371588.0000000"),
|
660
|
+
mc_dec128_from_string("17014118346046923173168730371588.0000000"),
|
661
|
+
7,
|
662
|
+
"Invalid value for precision");
|
663
|
+
|
664
|
+
CAN_USE_PRECISION_MODE_ERRORS(MC_DEC128(788545.000000),
|
665
|
+
mc_dec128_from_string("340282366920938463463374607431769000000.000000"),
|
666
|
+
0,
|
667
|
+
"Invalid upper bound for Decimal128 precision. Absolute scaled");
|
668
|
+
|
669
|
+
#undef CAN_USE_PRECISION_MODE
|
670
|
+
#undef CAN_USE_PRECISION_MODE_ERRORS
|
671
|
+
}
|
672
|
+
|
673
|
+
static void _test_RangeTest_Encode_Decimal128(_mongocrypt_tester_t *tester) {
|
674
|
+
Decimal128Test tests[] = {
|
675
|
+
#define CASE(Value, ExpectStr) \
|
676
|
+
(Decimal128Test){.value = mc_dec128_from_string(#Value), .expect = mlib_int128_from_string(ExpectStr, NULL)}
|
677
|
+
/* Test cases copied from server Decimal128_Bounds test ... begin */
|
678
|
+
// Larger numbers map to larger int128
|
679
|
+
CASE(-1234567890E7, "108549948892579231731687303715884111887"),
|
680
|
+
CASE(-1234567890E6, "108559948892579231731687303715884111886"),
|
681
|
+
CASE(-1234567890E5, "108569948892579231731687303715884111885"),
|
682
|
+
CASE(-1234567890E4, "108579948892579231731687303715884111884"),
|
683
|
+
CASE(-1234567890E3, "108589948892579231731687303715884111883"),
|
684
|
+
CASE(-1234567890E2, "108599948892579231731687303715884111882"),
|
685
|
+
CASE(-1234567890E1, "108609948892579231731687303715884111881"),
|
686
|
+
CASE(-123456789012345, "108569948892579108281687303715884111885"),
|
687
|
+
CASE(-12345678901234, "108579948892579108331687303715884111884"),
|
688
|
+
CASE(-1234567890123, "108589948892579108731687303715884111883"),
|
689
|
+
CASE(-123456789012, "108599948892579111731687303715884111882"),
|
690
|
+
CASE(-12345678901, "108609948892579131731687303715884111881"),
|
691
|
+
CASE(-1234567890, "108619948892579231731687303715884111880"),
|
692
|
+
CASE(-99999999, "108631183460569231731687303715884111878"),
|
693
|
+
CASE(-8888888, "108642294572469231731687303715884111877"),
|
694
|
+
CASE(-777777, "108653405690469231731687303715884111876"),
|
695
|
+
CASE(-66666, "108664516860469231731687303715884111875"),
|
696
|
+
CASE(-5555, "108675628460469231731687303715884111874"),
|
697
|
+
CASE(-444, "108686743460469231731687303715884111873"),
|
698
|
+
CASE(-334, "108687843460469231731687303715884111873"),
|
699
|
+
CASE(-333, "108687853460469231731687303715884111873"),
|
700
|
+
CASE(-44, "108696783460469231731687303715884111872"),
|
701
|
+
CASE(-33, "108697883460469231731687303715884111872"),
|
702
|
+
CASE(-22, "108698983460469231731687303715884111872"),
|
703
|
+
CASE(-5, "108706183460469231731687303715884111871"),
|
704
|
+
CASE(-4, "108707183460469231731687303715884111871"),
|
705
|
+
CASE(-3, "108708183460469231731687303715884111871"),
|
706
|
+
CASE(-2, "108709183460469231731687303715884111871"),
|
707
|
+
CASE(-1, "108710183460469231731687303715884111871"),
|
708
|
+
CASE(0, "170141183460469231731687303715884105728"),
|
709
|
+
CASE(1, "231572183460469231731687303715884099585"),
|
710
|
+
CASE(2, "231573183460469231731687303715884099585"),
|
711
|
+
CASE(3, "231574183460469231731687303715884099585"),
|
712
|
+
CASE(4, "231575183460469231731687303715884099585"),
|
713
|
+
CASE(5, "231576183460469231731687303715884099585"),
|
714
|
+
CASE(22, "231583383460469231731687303715884099584"),
|
715
|
+
CASE(33, "231584483460469231731687303715884099584"),
|
716
|
+
CASE(44, "231585583460469231731687303715884099584"),
|
717
|
+
CASE(333, "231594513460469231731687303715884099583"),
|
718
|
+
CASE(334, "231594523460469231731687303715884099583"),
|
719
|
+
CASE(444, "231595623460469231731687303715884099583"),
|
720
|
+
CASE(5555, "231606738460469231731687303715884099582"),
|
721
|
+
CASE(66666, "231617850060469231731687303715884099581"),
|
722
|
+
CASE(777777, "231628961230469231731687303715884099580"),
|
723
|
+
CASE(8888888, "231640072348469231731687303715884099579"),
|
724
|
+
CASE(33E56, "232144483460469231731687303715884099528"),
|
725
|
+
CASE(22E57, "232153383460469231731687303715884099527"),
|
726
|
+
CASE(11E58, "232162283460469231731687303715884099526"),
|
727
|
+
|
728
|
+
// Smaller exponents map to smaller int128
|
729
|
+
CASE(1E-6, "231512183460469231731687303715884099591"),
|
730
|
+
CASE(1E-7, "231502183460469231731687303715884099592"),
|
731
|
+
CASE(1E-8, "231492183460469231731687303715884099593"),
|
732
|
+
CASE(1E-56, "231012183460469231731687303715884099641"),
|
733
|
+
CASE(1E-57, "231002183460469231731687303715884099642"),
|
734
|
+
CASE(1E-58, "230992183460469231731687303715884099643"),
|
735
|
+
|
736
|
+
// Smaller negative exponents map to smaller int128
|
737
|
+
CASE(-1E-6, "108770183460469231731687303715884111865"),
|
738
|
+
CASE(-1E-7, "108780183460469231731687303715884111864"),
|
739
|
+
CASE(-1E-8, "108790183460469231731687303715884111863"),
|
740
|
+
CASE(-1E-56, "109270183460469231731687303715884111815"),
|
741
|
+
CASE(-1E-57, "109280183460469231731687303715884111814"),
|
742
|
+
CASE(-1E-58, "109290183460469231731687303715884111813"),
|
743
|
+
|
744
|
+
// Larger exponents map to larger int128
|
745
|
+
CASE(-33E56, "108137883460469231731687303715884111928"),
|
746
|
+
CASE(-22E57, "108128983460469231731687303715884111929"),
|
747
|
+
CASE(-11E58, "108120083460469231731687303715884111930"),
|
748
|
+
|
749
|
+
(Decimal128Test){.value = MC_DEC128_LARGEST_POSITIVE,
|
750
|
+
.expect = mlib_int128_from_string("293021183460469231731687303715884093440", NULL)},
|
751
|
+
(Decimal128Test){.value = MC_DEC128_SMALLEST_POSITIVE,
|
752
|
+
.expect = mlib_int128_from_string("170141183460469231731687303715884105729", NULL)},
|
753
|
+
(Decimal128Test){.value = MC_DEC128_LARGEST_NEGATIVE,
|
754
|
+
.expect = mlib_int128_from_string("47261183460469231731687303715884118016", NULL)},
|
755
|
+
(Decimal128Test){.value = MC_DEC128_SMALLEST_NEGATIVE,
|
756
|
+
.expect = mlib_int128_from_string("170141183460469231731687303715884105727", NULL)},
|
757
|
+
(Decimal128Test){.value = MC_DEC128_NORMALIZED_ZERO,
|
758
|
+
.expect = mlib_int128_from_string("170141183460469231731687303715884105728", NULL)},
|
759
|
+
(Decimal128Test){.value = MC_DEC128_NEGATIVE_EXPONENT_ZERO,
|
760
|
+
.expect = mlib_int128_from_string("170141183460469231731687303715884105728", NULL)},
|
761
|
+
/* Test cases copied from server Decimal128_Bounds test ... end */
|
762
|
+
|
763
|
+
#define ERROR_CASE(Value, Min, Max, Precision, ErrorString) \
|
764
|
+
(Decimal128Test){ \
|
765
|
+
.value = Value, \
|
766
|
+
.min = Min, \
|
767
|
+
.max = Max, \
|
768
|
+
.precision = Precision, \
|
769
|
+
.expectError = ErrorString, \
|
770
|
+
}
|
771
|
+
|
772
|
+
ERROR_CASE(MC_DEC128_C(1),
|
773
|
+
OPT_NULLOPT,
|
774
|
+
OPT_MC_DEC128(MC_DEC128_C(2)),
|
775
|
+
OPT_I32(5),
|
776
|
+
"min, max, and precision must all be set or must all be unset"),
|
777
|
+
ERROR_CASE(MC_DEC128_C(1),
|
778
|
+
OPT_MC_DEC128(MC_DEC128_C(0)),
|
779
|
+
OPT_NULLOPT,
|
780
|
+
OPT_I32(5),
|
781
|
+
"min, max, and precision must all be set or must all be unset"),
|
782
|
+
ERROR_CASE(MC_DEC128_C(1),
|
783
|
+
OPT_MC_DEC128(MC_DEC128_C(2)),
|
784
|
+
OPT_MC_DEC128(MC_DEC128_C(1)),
|
785
|
+
OPT_I32(5),
|
786
|
+
"The minimum value must be less than the maximum value"),
|
787
|
+
|
788
|
+
ERROR_CASE(MC_DEC128_C(1),
|
789
|
+
OPT_MC_DEC128(MC_DEC128_C(2)),
|
790
|
+
OPT_MC_DEC128(MC_DEC128_C(3)),
|
791
|
+
OPT_I32(5),
|
792
|
+
"Value must be greater than or equal to the minimum value "
|
793
|
+
"and less than or equal to the maximum value"),
|
794
|
+
ERROR_CASE(MC_DEC128_C(4),
|
795
|
+
OPT_MC_DEC128(MC_DEC128_C(2)),
|
796
|
+
OPT_MC_DEC128(MC_DEC128_C(3)),
|
797
|
+
OPT_I32(5),
|
798
|
+
"Value must be greater than or equal to the minimum value "
|
799
|
+
"and less than or equal to the maximum value"),
|
800
|
+
|
801
|
+
ERROR_CASE(MC_DEC128_POSITIVE_INFINITY,
|
802
|
+
OPT_NULLOPT,
|
803
|
+
OPT_NULLOPT,
|
804
|
+
OPT_NULLOPT,
|
805
|
+
"Infinity and Nan Decimal128 values are not supported."),
|
806
|
+
ERROR_CASE(MC_DEC128_NEGATIVE_INFINITY,
|
807
|
+
OPT_NULLOPT,
|
808
|
+
OPT_NULLOPT,
|
809
|
+
OPT_NULLOPT,
|
810
|
+
"Infinity and Nan Decimal128 values are not supported."),
|
811
|
+
|
812
|
+
ERROR_CASE(MC_DEC128_POSITIVE_NAN,
|
813
|
+
OPT_NULLOPT,
|
814
|
+
OPT_NULLOPT,
|
815
|
+
OPT_NULLOPT,
|
816
|
+
"Infinity and Nan Decimal128 values are not supported."),
|
817
|
+
|
818
|
+
ERROR_CASE(MC_DEC128_NEGATIVE_NAN,
|
819
|
+
OPT_NULLOPT,
|
820
|
+
OPT_NULLOPT,
|
821
|
+
OPT_NULLOPT,
|
822
|
+
"Infinity and Nan Decimal128 values are not supported."),
|
699
823
|
|
700
824
|
/* Test cases copied from Decimal128_Bounds_Precision ... begin */
|
701
|
-
#define ASSERT_EIBP(Value, Precision, Expect)
|
702
|
-
|
703
|
-
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
|
708
|
-
|
709
|
-
|
710
|
-
|
711
|
-
|
712
|
-
|
713
|
-
|
714
|
-
|
715
|
-
|
716
|
-
|
825
|
+
#define ASSERT_EIBP(Value, Precision, Expect) \
|
826
|
+
(Decimal128Test){ \
|
827
|
+
.value = mc_dec128_from_string(Value), \
|
828
|
+
.min = OPT_MC_DEC128(MC_DEC128_C(-100000)), \
|
829
|
+
.max = OPT_MC_DEC128(MC_DEC128_C(100000)), \
|
830
|
+
.precision = OPT_I32(Precision), \
|
831
|
+
.expect = MLIB_INT128(Expect), \
|
832
|
+
}
|
833
|
+
ASSERT_EIBP("3.141592653589E-1", 10, 1000003141592653),
|
834
|
+
ASSERT_EIBP("31.41592653589E-2", 10, 1000003141592653),
|
835
|
+
ASSERT_EIBP("314.1592653589E-3", 10, 1000003141592653),
|
836
|
+
ASSERT_EIBP("3141.592653589E-4", 10, 1000003141592653),
|
837
|
+
ASSERT_EIBP("31415.92653589E-5", 10, 1000003141592653),
|
838
|
+
ASSERT_EIBP("314159.2653589E-6", 10, 1000003141592653),
|
839
|
+
ASSERT_EIBP("3141592.653589E-7", 10, 1000003141592653),
|
840
|
+
ASSERT_EIBP("31415926.53589E-8", 10, 1000003141592653),
|
717
841
|
#undef ASSERT_EIBP
|
718
842
|
|
719
|
-
#define ASSERT_EIBPL(Value, Precision, Expect)
|
720
|
-
|
721
|
-
|
722
|
-
|
723
|
-
|
724
|
-
|
725
|
-
|
726
|
-
|
727
|
-
|
728
|
-
|
729
|
-
|
730
|
-
|
731
|
-
|
732
|
-
|
733
|
-
|
734
|
-
|
735
|
-
ASSERT_EIBPL ("3.1415926535897932384626433832795E20",
|
736
|
-
7,
|
737
|
-
"3141592653589794238462643383"),
|
738
|
-
|
739
|
-
ASSERT_EIBPL ("3.1415926535897932384626433832795E20",
|
740
|
-
8,
|
741
|
-
"31415926535897942384626433832"),
|
843
|
+
#define ASSERT_EIBPL(Value, Precision, Expect) \
|
844
|
+
(Decimal128Test){ \
|
845
|
+
.value = mc_dec128_from_string(Value), \
|
846
|
+
.min = OPT_MC_DEC128(MC_DEC128_C(-100000)), \
|
847
|
+
.max = OPT_MC_DEC128(mc_dec128_from_string("1E22")), \
|
848
|
+
.precision = OPT_I32(Precision), \
|
849
|
+
.expect = mlib_int128_from_string(Expect, NULL), \
|
850
|
+
}
|
851
|
+
|
852
|
+
ASSERT_EIBPL("3.1415926535897932384626433832795E20", 5, "31415926535897942384626433"),
|
853
|
+
ASSERT_EIBPL("3.1415926535897932384626433832795E20", 6, "314159265358979423846264338"),
|
854
|
+
|
855
|
+
ASSERT_EIBPL("3.1415926535897932384626433832795E20", 7, "3141592653589794238462643383"),
|
856
|
+
|
857
|
+
ASSERT_EIBPL("3.1415926535897932384626433832795E20", 8, "31415926535897942384626433832"),
|
742
858
|
#undef ASSERT_EIBPL
|
743
859
|
|
744
|
-
#define ASSERT_EIBP(Value, Precision, Expect)
|
745
|
-
|
746
|
-
|
747
|
-
|
748
|
-
|
749
|
-
|
750
|
-
|
751
|
-
|
752
|
-
|
753
|
-
|
754
|
-
|
755
|
-
|
756
|
-
|
757
|
-
|
758
|
-
|
860
|
+
#define ASSERT_EIBP(Value, Precision, Expect) \
|
861
|
+
(Decimal128Test){ \
|
862
|
+
.value = mc_dec128_from_string(#Value), \
|
863
|
+
.min = OPT_MC_DEC128(MC_DEC128_C(-100000)), \
|
864
|
+
.max = OPT_MC_DEC128(MC_DEC128_C(100000)), \
|
865
|
+
.precision = OPT_I32(Precision), \
|
866
|
+
.expect = MLIB_INT128_CAST(Expect), \
|
867
|
+
}
|
868
|
+
ASSERT_EIBP(3.141592653589, 1, 1000031),
|
869
|
+
ASSERT_EIBP(3.141592653589, 2, 10000314),
|
870
|
+
ASSERT_EIBP(3.141592653589, 3, 100003141),
|
871
|
+
ASSERT_EIBP(3.141592653589, 4, 1000031415),
|
872
|
+
ASSERT_EIBP(3.141592653589, 5, 10000314159),
|
873
|
+
ASSERT_EIBP(3.141592653589, 6, 100003141592),
|
874
|
+
ASSERT_EIBP(3.141592653589, 7, 1000031415926),
|
759
875
|
#undef ASSERT_EIBP
|
760
876
|
|
761
|
-
#define ASSERT_EIBB(Val, Max, Min, Precision, Expect)
|
762
|
-
|
763
|
-
|
764
|
-
|
765
|
-
|
766
|
-
|
767
|
-
|
768
|
-
|
769
|
-
|
770
|
-
|
771
|
-
|
772
|
-
|
773
|
-
|
774
|
-
|
775
|
-
|
776
|
-
|
777
|
-
|
778
|
-
|
779
|
-
|
780
|
-
|
781
|
-
|
782
|
-
|
783
|
-
|
784
|
-
|
785
|
-
|
786
|
-
|
787
|
-
|
788
|
-
|
789
|
-
|
790
|
-
|
791
|
-
|
792
|
-
|
793
|
-
|
794
|
-
|
795
|
-
|
796
|
-
|
797
|
-
|
798
|
-
|
799
|
-
|
800
|
-
|
801
|
-
|
802
|
-
|
803
|
-
|
804
|
-
|
805
|
-
|
806
|
-
|
807
|
-
|
808
|
-
|
809
|
-
|
810
|
-
|
811
|
-
|
812
|
-
|
813
|
-
|
814
|
-
|
815
|
-
|
816
|
-
|
817
|
-
|
818
|
-
|
819
|
-
|
820
|
-
|
821
|
-
|
822
|
-
|
823
|
-
|
824
|
-
|
825
|
-
|
826
|
-
|
827
|
-
|
828
|
-
|
829
|
-
|
830
|
-
|
877
|
+
#define ASSERT_EIBB(Val, Max, Min, Precision, Expect) \
|
878
|
+
(Decimal128Test){ \
|
879
|
+
.value = mc_dec128_from_string(#Val), \
|
880
|
+
.min = OPT_MC_DEC128(mc_dec128_from_string(#Min)), \
|
881
|
+
.max = OPT_MC_DEC128(mc_dec128_from_string(#Max)), \
|
882
|
+
.precision = OPT_I32(Precision), \
|
883
|
+
.expect = MLIB_INT128_CAST(Expect), \
|
884
|
+
}
|
885
|
+
|
886
|
+
// ASSERT_EIBB_OVERFLOW defines cases where applying min/max/precision result in a domain needing >= 128 bits.
|
887
|
+
// For range v1, expect precision to be ignored.
|
888
|
+
// For range v2, expect an error.
|
889
|
+
#define ASSERT_EIBB_OVERFLOW(Val, Max, Min, Precision, Expect) \
|
890
|
+
(Decimal128Test){ \
|
891
|
+
.value = mc_dec128_from_string(#Val), \
|
892
|
+
.min = OPT_MC_DEC128(mc_dec128_from_string(#Min)), \
|
893
|
+
.max = OPT_MC_DEC128(mc_dec128_from_string(#Max)), \
|
894
|
+
.precision = OPT_I32(Precision), \
|
895
|
+
.expect = Expect, \
|
896
|
+
.use_range_v1 = true, \
|
897
|
+
}, \
|
898
|
+
(Decimal128Test) { \
|
899
|
+
.value = mc_dec128_from_string(#Val), .min = OPT_MC_DEC128(mc_dec128_from_string(#Min)), \
|
900
|
+
.max = OPT_MC_DEC128(mc_dec128_from_string(#Max)), .precision = OPT_I32(Precision), \
|
901
|
+
.expectError = "The domain of decimal values specified by the min, max, and precision " \
|
902
|
+
"cannot be represented in fewer than 128 bits" \
|
903
|
+
}
|
904
|
+
|
905
|
+
#define ASSERT_EIBB_ERROR(Val, Max, Min, Precision, Expect, Error) \
|
906
|
+
(Decimal128Test){ \
|
907
|
+
.value = mc_dec128_from_string(#Val), \
|
908
|
+
.min = OPT_MC_DEC128(mc_dec128_from_string(#Min)), \
|
909
|
+
.max = OPT_MC_DEC128(mc_dec128_from_string(#Max)), \
|
910
|
+
.precision = OPT_I32(Precision), \
|
911
|
+
.expect = Expect, \
|
912
|
+
.use_range_v1 = true, \
|
913
|
+
}, \
|
914
|
+
(Decimal128Test) { \
|
915
|
+
.value = mc_dec128_from_string(#Val), .min = OPT_MC_DEC128(mc_dec128_from_string(#Min)), \
|
916
|
+
.max = OPT_MC_DEC128(mc_dec128_from_string(#Max)), .precision = OPT_I32(Precision), .expectError = Error \
|
917
|
+
}
|
918
|
+
|
919
|
+
ASSERT_EIBB(0, 1, -1, 3, 1000),
|
920
|
+
ASSERT_EIBB(0, 1, -1E5, 3, 100000000),
|
921
|
+
|
922
|
+
ASSERT_EIBB(-1E-33, 1, -1E5, 3, 100000000),
|
923
|
+
|
924
|
+
ASSERT_EIBB_ERROR(0,
|
925
|
+
MC_DEC128_LARGEST_POSITIVE,
|
926
|
+
MC_DEC128_LARGEST_NEGATIVE,
|
927
|
+
3,
|
928
|
+
mlib_int128_from_string("170141183460469231731687303715884105728", NULL),
|
929
|
+
"Invalid upper bound for Decimal128 precision. Max is infinite."),
|
930
|
+
|
931
|
+
ASSERT_EIBB_ERROR(0,
|
932
|
+
DBL_MAX,
|
933
|
+
DBL_MIN,
|
934
|
+
3,
|
935
|
+
mlib_int128_from_string("170141183460469231731687303715884105728", NULL),
|
936
|
+
"Invalid upper bound for Decimal128 precision. Max is infinite."),
|
937
|
+
|
938
|
+
ASSERT_EIBB(3.141592653589, 5, 0, 0, 3),
|
939
|
+
ASSERT_EIBB(3.141592653589, 5, 0, 1, 31),
|
940
|
+
|
941
|
+
ASSERT_EIBB(3.141592653589, 5, 0, 2, 314),
|
942
|
+
|
943
|
+
ASSERT_EIBB(3.141592653589, 5, 0, 3, 3141),
|
944
|
+
ASSERT_EIBB(3.141592653589, 5, 0, 16, 31415926535890000),
|
945
|
+
|
946
|
+
ASSERT_EIBB(-5, -1, -10, 3, 5000),
|
947
|
+
|
948
|
+
ASSERT_EIBB_ERROR(1E100,
|
949
|
+
DBL_MAX,
|
950
|
+
DBL_MIN,
|
951
|
+
3,
|
952
|
+
mlib_int128_from_string("232572183460469231731687303715884099485", NULL),
|
953
|
+
"Invalid upper bound for Decimal128 precision. Max is infinite."),
|
954
|
+
|
955
|
+
ASSERT_EIBB(1E9, 1E10, 0, 3, 1000000000000),
|
956
|
+
ASSERT_EIBB(1E9, 1E10, 0, 0, 1000000000),
|
957
|
+
|
958
|
+
ASSERT_EIBB(-5, 10, -10, 0, 5),
|
959
|
+
ASSERT_EIBB(-5, 10, -10, 2, 500),
|
960
|
+
|
961
|
+
ASSERT_EIBB(5E-30, 10E-30, 1E-30, 35, 400000),
|
962
|
+
|
963
|
+
// Test a range that requires > 64 bits.
|
964
|
+
ASSERT_EIBB(5, 18446744073709551616, .1, 1, 49),
|
831
965
|
|
832
966
|
#undef ASSERT_EIBB
|
833
967
|
#undef ASSERT_EIBB_OVERFLOW
|
968
|
+
#undef ASSERT_EIBB_ERROR
|
969
|
+
|
970
|
+
/* Test cases copied from Decimal128_Bounds_Precision ... end */
|
971
|
+
|
972
|
+
{// Expect error due to precision exceeding INT32_MAX.
|
973
|
+
.min = OPT_MC_DEC128(MC_DEC128_C(1)),
|
974
|
+
.max = OPT_MC_DEC128(MC_DEC128_C(2)),
|
975
|
+
.precision = OPT_I32(-1),
|
976
|
+
.expectError = "Precision must be non-negative"},
|
977
|
+
{// Expect error due to precision exceeding max finite Decimal128.
|
978
|
+
// The largest decimal128 value is 9.99999...x10^6144. 10^6145 results in infinity.
|
979
|
+
.min = OPT_MC_DEC128(MC_DEC128_C(0)),
|
980
|
+
.max = OPT_MC_DEC128(MC_DEC128_C(1)),
|
981
|
+
.precision = OPT_I32(6145),
|
982
|
+
.expectError = "Precision is too large"}};
|
983
|
+
|
984
|
+
for (size_t i = 0; i < sizeof(tests) / sizeof(tests[0]); i++) {
|
985
|
+
Decimal128Test *test = tests + i;
|
986
|
+
mongocrypt_status_t *const status = mongocrypt_status_new();
|
987
|
+
|
988
|
+
if (test->min.set && test->max.set && test->precision.set) {
|
989
|
+
printf("_test_RangeTest_Encode_Decimal128: value=%s, min=%s, max=%s, "
|
990
|
+
"precision=%" PRIu32 "\n",
|
991
|
+
mc_dec128_to_string(test->value).str,
|
992
|
+
mc_dec128_to_string(test->min.value).str,
|
993
|
+
mc_dec128_to_string(test->max.value).str,
|
994
|
+
test->precision.value);
|
995
|
+
} else {
|
996
|
+
printf("_test_RangeTest_Encode_Decimal128: value=%s\n", mc_dec128_to_string(test->value).str);
|
997
|
+
}
|
998
|
+
fflush(stdout);
|
999
|
+
mc_OSTType_Decimal128 got;
|
1000
|
+
const bool use_range_v2 = !test->use_range_v1;
|
1001
|
+
const bool ok = mc_getTypeInfoDecimal128(
|
1002
|
+
(mc_getTypeInfoDecimal128_args_t){
|
1003
|
+
.value = test->value,
|
1004
|
+
.min = test->min,
|
1005
|
+
.max = test->max,
|
1006
|
+
.precision = test->precision,
|
1007
|
+
},
|
1008
|
+
&got,
|
1009
|
+
status,
|
1010
|
+
use_range_v2);
|
1011
|
+
if (test->expectError) {
|
1012
|
+
ASSERT_OR_PRINT_MSG(!ok, "expected error, but got none");
|
1013
|
+
ASSERT_STATUS_CONTAINS(status, test->expectError);
|
1014
|
+
} else {
|
1015
|
+
ASSERT_OK_STATUS(ok, status);
|
834
1016
|
|
835
|
-
|
836
|
-
|
837
|
-
|
838
|
-
|
839
|
-
|
840
|
-
mongocrypt_status_t *const status = mongocrypt_status_new ();
|
841
|
-
|
842
|
-
if (test->min.set && test->max.set && test->precision.set) {
|
843
|
-
printf ("_test_RangeTest_Encode_Decimal128: value=%s, min=%s, max=%s, "
|
844
|
-
"precision=%" PRIu32 "\n",
|
845
|
-
mc_dec128_to_string (test->value).str,
|
846
|
-
mc_dec128_to_string (test->min.value).str,
|
847
|
-
mc_dec128_to_string (test->max.value).str,
|
848
|
-
test->precision.value);
|
849
|
-
} else {
|
850
|
-
printf ("_test_RangeTest_Encode_Decimal128: value=%s\n",
|
851
|
-
mc_dec128_to_string (test->value).str);
|
852
|
-
}
|
853
|
-
fflush (stdout);
|
854
|
-
mc_OSTType_Decimal128 got;
|
855
|
-
const bool ok = mc_getTypeInfoDecimal128 (
|
856
|
-
(mc_getTypeInfoDecimal128_args_t){.value = test->value,
|
857
|
-
.min = test->min,
|
858
|
-
.max = test->max,
|
859
|
-
.precision = test->precision},
|
860
|
-
&got,
|
861
|
-
status);
|
862
|
-
if (test->expectError) {
|
863
|
-
ASSERT_OR_PRINT_MSG (!ok, "expected error, but got none");
|
864
|
-
ASSERT_STATUS_CONTAINS (status, test->expectError);
|
865
|
-
} else {
|
866
|
-
ASSERT_OK_STATUS (ok, status);
|
867
|
-
|
868
|
-
ASSERT_CMPINT128_EQ (got.value, test->expect);
|
869
|
-
ASSERT_CMPINT128_EQ (got.min, MLIB_INT128 (0));
|
870
|
-
}
|
871
|
-
mongocrypt_status_destroy (status);
|
872
|
-
}
|
1017
|
+
ASSERT_CMPINT128_EQ(got.value, test->expect);
|
1018
|
+
ASSERT_CMPINT128_EQ(got.min, MLIB_INT128(0));
|
1019
|
+
}
|
1020
|
+
mongocrypt_status_destroy(status);
|
1021
|
+
}
|
873
1022
|
}
|
874
1023
|
|
875
1024
|
#endif // MONGOCRYPT_HAVE_DECIMAL128_SUPPORT
|
876
1025
|
|
877
|
-
void
|
878
|
-
|
879
|
-
|
880
|
-
|
881
|
-
|
882
|
-
INSTALL_TEST (_test_RangeTest_Encode_Double);
|
1026
|
+
void _mongocrypt_tester_install_range_encoding(_mongocrypt_tester_t *tester) {
|
1027
|
+
INSTALL_TEST(_test_RangeTest_Encode_Int32);
|
1028
|
+
INSTALL_TEST(_test_RangeTest_Encode_Int64);
|
1029
|
+
INSTALL_TEST(_test_canUsePrecisionModeDouble);
|
1030
|
+
INSTALL_TEST(_test_RangeTest_Encode_Double);
|
883
1031
|
#if MONGOCRYPT_HAVE_DECIMAL128_SUPPORT
|
884
|
-
|
1032
|
+
INSTALL_TEST(_test_canUsePrecisionModeDecimal);
|
1033
|
+
INSTALL_TEST(_test_RangeTest_Encode_Decimal128);
|
885
1034
|
#endif
|
886
1035
|
}
|