libmongocrypt-helper 1.7.4.0.1002 → 1.8.0.0.1001
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/ext/libmongocrypt/libmongocrypt/CHANGELOG.md +9 -7
- data/ext/libmongocrypt/libmongocrypt/CMakeLists.txt +17 -23
- data/ext/libmongocrypt/libmongocrypt/Earthfile +374 -0
- data/ext/libmongocrypt/libmongocrypt/README.md +7 -7
- data/ext/libmongocrypt/libmongocrypt/VERSION_CURRENT +1 -1
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/CryptClient.cs +25 -6
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/Library.cs +25 -3
- 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/Scripts/build.cake +3 -2
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/cs.sln +79 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/build.gradle.kts +2 -2
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/java/com/mongodb/crypt/capi/MongoCryptTest.java +6 -4
- 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/node/CHANGELOG.md +24 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/README.md +134 -5
- data/ext/libmongocrypt/libmongocrypt/bindings/node/etc/build-static.sh +3 -6
- data/ext/libmongocrypt/libmongocrypt/bindings/node/index.d.ts +203 -77
- data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/autoEncrypter.js +1 -1
- data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/clientEncryption.js +165 -43
- data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/common.js +12 -14
- data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/errors.js +75 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/index.js +34 -3
- data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/providers/aws.js +26 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/providers/azure.js +178 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/providers/gcp.js +24 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/providers/index.js +54 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/providers/utils.js +39 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/stateMachine.js +9 -4
- data/ext/libmongocrypt/libmongocrypt/bindings/node/package-lock.json +4440 -5189
- data/ext/libmongocrypt/libmongocrypt/bindings/node/package.json +27 -8
- data/ext/libmongocrypt/libmongocrypt/bindings/node/src/mongocrypt.cc +65 -38
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/autoEncrypter.test.js +4 -7
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/clientEncryption.test.js +434 -42
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/common.test.js +94 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/cryptoCallbacks.test.js +1 -45
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/index.test.js +45 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/mongocryptdManager.test.js +1 -1
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/providers/credentialsProvider.test.js +551 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/release.test.js +10 -3
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/requirements.helper.js +23 -1
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/stateMachine.test.js +1 -1
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/tools/chai-addons.js +8 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/types/index.test-d.ts +63 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/CHANGELOG.rst +26 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/README.rst +2 -2
- data/ext/libmongocrypt/libmongocrypt/bindings/python/build-manylinux-wheel.sh +1 -1
- data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/binding.py +128 -238
- data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/compat.py +0 -27
- data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/explicit_encrypter.py +1 -1
- data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/mongocrypt.py +5 -21
- data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/version.py +2 -2
- data/ext/libmongocrypt/libmongocrypt/bindings/python/release.sh +5 -5
- data/ext/libmongocrypt/libmongocrypt/bindings/python/setup.py +14 -9
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/__init__.py +1 -10
- 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/test_mongocrypt.py +5 -5
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test-requirements.txt +4 -12
- data/ext/libmongocrypt/libmongocrypt/cmake/ImportBSON.cmake +8 -6
- data/ext/libmongocrypt/libmongocrypt/cmake/IntelDFP.cmake +2 -1
- data/ext/libmongocrypt/libmongocrypt/cmake/Platform.cmake +50 -0
- data/ext/libmongocrypt/libmongocrypt/cmake/mongocrypt-config.cmake +21 -0
- data/ext/libmongocrypt/libmongocrypt/debian/gbp.conf +2 -2
- data/ext/libmongocrypt/libmongocrypt/etc/c6-vault.repo +39 -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/mongo-inteldfp-libmongocrypt-pr-625.patch +13 -0
- 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 +180 -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 +7 -11
- data/ext/libmongocrypt/libmongocrypt/src/mc-efc.c +80 -92
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle-blob-subtype-private.h +18 -10
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-encryption-placeholder-private.h +59 -70
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-encryption-placeholder.c +384 -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 +88 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-range-payload-private.h +24 -27
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-range-payload-v2.c +137 -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 +117 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-insert-update-payload-private.h +28 -36
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-insert-update-payload-v2.c +294 -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 +476 -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 +55 -56
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-rfds.c +517 -580
- data/ext/libmongocrypt/libmongocrypt/src/mc-optional-private.h +36 -66
- data/ext/libmongocrypt/libmongocrypt/src/mc-range-edge-generation-private.h +57 -76
- data/ext/libmongocrypt/libmongocrypt/src/mc-range-edge-generation.c +158 -189
- data/ext/libmongocrypt/libmongocrypt/src/mc-range-encoding-private.h +36 -42
- data/ext/libmongocrypt/libmongocrypt/src/mc-range-encoding.c +515 -558
- data/ext/libmongocrypt/libmongocrypt/src/mc-range-mincover-generator.template.h +155 -191
- data/ext/libmongocrypt/libmongocrypt/src/mc-range-mincover-private.h +43 -53
- data/ext/libmongocrypt/libmongocrypt/src/mc-range-mincover.c +170 -240
- data/ext/libmongocrypt/libmongocrypt/src/mc-rangeopts-private.h +29 -34
- data/ext/libmongocrypt/libmongocrypt/src/mc-rangeopts.c +289 -338
- 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 +55 -49
- data/ext/libmongocrypt/libmongocrypt/src/mc-tokens.c +109 -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 +444 -499
- data/ext/libmongocrypt/libmongocrypt/src/mlib/int128.test.cpp +251 -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 +3 -6
- 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 +444 -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 +103 -132
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache-oauth-private.h +8 -14
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache-oauth.c +78 -90
- 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 +1137 -1565
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx-datakey.c +425 -472
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx-decrypt.c +817 -694
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx-encrypt.c +2394 -2697
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx-private.h +166 -186
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx-rewrap-many-datakey.c +308 -351
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx.c +921 -1138
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-dll-private.h +16 -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 +37 -43
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-kek.c +215 -253
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-key-broker-private.h +73 -108
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-key-broker.c +889 -1034
- 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 +92 -120
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-kms-ctx.c +1397 -1612
- 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 +30 -36
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-marking.c +1821 -1470
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-mutex-private.h +7 -12
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-opts-private.h +80 -108
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-opts.c +354 -424
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-private.h +101 -117
- 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 +96 -135
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt.c +1092 -1320
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt.h +130 -295
- data/ext/libmongocrypt/libmongocrypt/src/os_posix/os_dll.c +66 -78
- data/ext/libmongocrypt/libmongocrypt/src/os_posix/os_mutex.c +20 -28
- data/ext/libmongocrypt/libmongocrypt/src/os_win/os_dll.c +60 -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/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/encrypted-payload.json +2 -2
- 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/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 +27 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/tokens/mc.json +21 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/tokens/server.json +21 -0
- data/ext/libmongocrypt/libmongocrypt/test/example-no-bson.c +4 -4
- data/ext/libmongocrypt/libmongocrypt/test/example-state-machine.c +278 -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 +58 -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 +89 -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 +172 -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 +346 -388
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-range-encoding.c +708 -825
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-range-mincover.c +417 -481
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-rangeopts.c +110 -144
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-reader.c +124 -207
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-tokens.c +223 -213
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-writer.c +176 -0
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-assert-match-bson.c +634 -807
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-assert-match-bson.h +1 -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 +34 -36
- 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-compact.c +331 -445
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-crypto-hooks.c +670 -814
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-crypto-std-hooks.c +102 -135
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-crypto-std-hooks.h +54 -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 +867 -1045
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-ctx-encrypt.c +4349 -4713
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-ctx-rewrap-many-datakey.c +750 -964
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-ctx-setopt.c +991 -1178
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-datakey.c +342 -419
- 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 +286 -370
- 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 +656 -692
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-status.c +46 -58
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-traverse-util.c +377 -451
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-util.c +48 -67
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-util.h +4 -10
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt.c +827 -918
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt.h +111 -172
- data/ext/libmongocrypt/libmongocrypt/test/util/csfle.c +508 -559
- data/ext/libmongocrypt/libmongocrypt/test/util/util.c +735 -881
- data/ext/libmongocrypt/libmongocrypt/test/util/util.h +33 -55
- data/lib/libmongocrypt_helper/version.rb +2 -2
- data.tar.gz.sig +0 -0
- metadata +154 -26
- metadata.gz.sig +0 -0
- 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/lib/credentialsProvider.js +0 -33
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/credentialsProvider.test.js +0 -163
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/fle2-find-range-explicit/int32/encrypted-payload.json +0 -26
- data/ext/libmongocrypt/libmongocrypt/test/data/aes-ctr.cstructs +0 -359
- 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-find-range-explicit/int32-nominmax/value-to-encrypt.json +0 -20
- 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/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/rangeopts.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/rangeopts.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
@@ -22,865 +22,748 @@
|
|
22
22
|
#include <math.h> // INFINITY, NAN
|
23
23
|
|
24
24
|
typedef struct {
|
25
|
-
|
26
|
-
|
27
|
-
|
25
|
+
mc_getTypeInfo32_args_t args;
|
26
|
+
mc_OSTType_Int32 expect;
|
27
|
+
const char *expectError;
|
28
28
|
} Int32Test;
|
29
29
|
|
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
|
-
}
|
30
|
+
static void _test_RangeTest_Encode_Int32(_mongocrypt_tester_t *tester) {
|
31
|
+
Int32Test tests[] = {
|
32
|
+
/* Test cases copied from server Int32_NoBounds test ... begin */
|
33
|
+
{.args = {.value = INT32_C(2147483647)},
|
34
|
+
.expect = {.value = UINT32_C(4294967295), .min = 0, .max = UINT32_MAX}},
|
35
|
+
{.args = {.value = 1}, .expect = {.value = UINT32_C(2147483649), .min = 0, .max = UINT32_MAX}},
|
36
|
+
{.args = {.value = 0}, .expect = {.value = UINT32_C(2147483648), .min = 0, .max = UINT32_MAX}},
|
37
|
+
{.args = {.value = -1}, .expect = {.value = UINT32_C(2147483647), .min = 0, .max = UINT32_MAX}},
|
38
|
+
{.args = {.value = -2}, .expect = {.value = UINT32_C(2147483646), .min = 0, .max = UINT32_MAX}},
|
39
|
+
{.args = {.value = INT32_C(-2147483647)}, .expect = {.value = 1, .min = 0, .max = UINT32_MAX}},
|
40
|
+
{.args = {.value = INT32_MIN}, .expect = {.value = 0, .min = 0, .max = UINT32_MAX}},
|
41
|
+
/* Test cases copied from server Int32_NoBounds test ... end */
|
42
|
+
/* Test cases copied from server Int32_Bounds test .. begin */
|
43
|
+
{.args = {.value = 1, .min = OPT_I32(1), .max = OPT_I32(3)}, .expect = {.value = 0, 0, .max = 2}},
|
44
|
+
{.args = {.value = 0, .min = OPT_I32(0), .max = OPT_I32(1)}, .expect = {.value = 0, .min = 0, .max = 1}},
|
45
|
+
{.args = {.value = -1, .min = OPT_I32(-1), .max = OPT_I32(0)}, .expect = {.value = 0, .min = 0, .max = 1}},
|
46
|
+
{.args = {.value = -2, .min = OPT_I32(-2), .max = OPT_I32(0)}, .expect = {.value = 0, .min = 0, .max = 2}},
|
47
|
+
{.args = {.value = INT32_C(-2147483647), .min = OPT_I32(INT32_MIN), .max = OPT_I32(1)},
|
48
|
+
.expect = {.value = 1, .min = 0, .max = UINT32_C(2147483649)}},
|
49
|
+
{.args = {.value = INT32_MIN, .min = OPT_I32(INT32_MIN), .max = OPT_I32(0)},
|
50
|
+
.expect = {.value = 0, .min = 0, .max = UINT32_C(2147483648)}},
|
51
|
+
{.args = {.value = 0, .min = OPT_I32(INT32_MIN), .max = OPT_I32(1)},
|
52
|
+
.expect = {.value = UINT32_C(2147483648), .min = 0, .max = UINT32_C(2147483649)}},
|
53
|
+
{.args = {.value = 1, .min = OPT_I32(INT32_MIN), .max = OPT_I32(2)},
|
54
|
+
.expect = {.value = UINT32_C(2147483649), .min = 0, .max = UINT32_C(2147483650)}},
|
55
|
+
{.args = {.value = INT32_C(2147483647), .min = OPT_I32(-2147483647), .max = OPT_I32(2147483647)},
|
56
|
+
.expect = {.value = UINT32_C(4294967294), .min = 0, .max = UINT32_C(4294967294)}},
|
57
|
+
{.args = {.value = INT32_C(2147483647), .min = OPT_I32(INT32_MIN), .max = OPT_I32(2147483647)},
|
58
|
+
.expect = {.value = UINT32_C(4294967295), .min = 0, .max = UINT32_C(4294967295)}},
|
59
|
+
{.args = {.value = 15, .min = OPT_I32(10), .max = OPT_I32(26)}, .expect = {.value = 5, .min = 0, .max = 16}},
|
60
|
+
{.args = {.value = 15, .min = OPT_I32(-10), .max = OPT_I32(55)}, .expect = {.value = 25, .min = 0, .max = 65}},
|
61
|
+
/* Test cases copied from server Int32_Bounds test ... end */
|
62
|
+
/* Test cases copied from server Int32_Errors test ... begin */
|
63
|
+
{.args = {.value = 1, .max = OPT_I32(2)},
|
64
|
+
.expectError = "Must specify both a lower and upper bound or no bounds."},
|
65
|
+
{.args = {.value = 1, .min = OPT_I32(0)},
|
66
|
+
.expectError = "Must specify both a lower and upper bound or no bounds."},
|
67
|
+
{.args = {.value = 1, .min = OPT_I32(2), .max = OPT_I32(1)},
|
68
|
+
.expectError = "The minimum value must be less than the maximum value"},
|
69
|
+
{.args = {.value = 1, .min = OPT_I32(2), .max = OPT_I32(3)},
|
70
|
+
.expectError = "Value must be greater than or equal to the minimum "
|
71
|
+
"value and less than or equal to the maximum value"},
|
72
|
+
{.args = {.value = 4, .min = OPT_I32(2), .max = OPT_I32(3)},
|
73
|
+
.expectError = "Value must be greater than or equal to the minimum "
|
74
|
+
"value and less than or equal to the maximum value"},
|
75
|
+
{.args = {.value = 4, .min = OPT_I32(INT32_MIN), .max = OPT_I32(INT32_MIN)},
|
76
|
+
.expectError = "The minimum value must be less than the maximum value"},
|
77
|
+
/* Test cases copied from server Int32_Errors test ... end */
|
78
|
+
};
|
79
|
+
|
80
|
+
for (size_t i = 0; i < sizeof(tests) / sizeof(tests[0]); i++) {
|
81
|
+
Int32Test *test = tests + i;
|
82
|
+
mongocrypt_status_t *const status = mongocrypt_status_new();
|
83
|
+
|
84
|
+
// Print a description of the test case.
|
85
|
+
printf("_test_RangeTest_Encode_Int32: value=%" PRId32, test->args.value);
|
86
|
+
if (test->args.min.set) {
|
87
|
+
printf(" min=%" PRId32, test->args.min.value);
|
88
|
+
}
|
89
|
+
if (test->args.max.set) {
|
90
|
+
printf(" max=%" PRId32, test->args.max.value);
|
91
|
+
}
|
92
|
+
printf("\n");
|
93
|
+
mc_OSTType_Int32 got;
|
94
|
+
const bool ok = mc_getTypeInfo32(test->args, &got, status);
|
95
|
+
if (test->expectError) {
|
96
|
+
ASSERT_OR_PRINT_MSG(!ok, "expected error, but got none");
|
97
|
+
ASSERT_STATUS_CONTAINS(status, test->expectError);
|
98
|
+
} else {
|
99
|
+
ASSERT_OK_STATUS(ok, status);
|
100
|
+
ASSERT_CMPUINT32(got.value, ==, test->expect.value);
|
101
|
+
ASSERT_CMPUINT32(got.min, ==, test->expect.min);
|
102
|
+
ASSERT_CMPUINT32(got.max, ==, test->expect.max);
|
103
|
+
}
|
104
|
+
mongocrypt_status_destroy(status);
|
105
|
+
}
|
140
106
|
}
|
141
107
|
|
142
108
|
typedef struct {
|
143
|
-
|
144
|
-
|
145
|
-
|
109
|
+
mc_getTypeInfo64_args_t args;
|
110
|
+
mc_OSTType_Int64 expect;
|
111
|
+
const char *expectError;
|
146
112
|
} Int64Test;
|
147
113
|
|
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
|
-
.expectError = "The minimum value must be less than the maximum value"},
|
229
|
-
{.args = {.value = 1, .min = OPT_I64 (2), .max = OPT_I64 (3)},
|
230
|
-
.expectError = "Value must be greater than or equal to the minimum "
|
231
|
-
"value and less than or equal to the maximum value"},
|
232
|
-
{.args = {.value = 4, .min = OPT_I64 (2), .max = OPT_I64 (3)},
|
233
|
-
.expectError = "Value must be greater than or equal to the minimum "
|
234
|
-
"value and less than or equal to the maximum value"},
|
235
|
-
{.args = {.value = 4,
|
236
|
-
.min = OPT_I64 (INT64_MIN),
|
237
|
-
.max = OPT_I64 (INT64_MIN)},
|
238
|
-
.expectError = "The minimum value must be less than the maximum value"},
|
239
|
-
/* Test cases copied from server Int64_Errors test ... end */
|
240
|
-
};
|
241
|
-
|
242
|
-
for (size_t i = 0; i < sizeof (tests) / sizeof (tests[0]); i++) {
|
243
|
-
Int64Test *test = tests + i;
|
244
|
-
mongocrypt_status_t *const status = mongocrypt_status_new ();
|
245
|
-
|
246
|
-
// Print a description of the test case.
|
247
|
-
printf ("_test_RangeTest_Encode_Int64: value=%" PRId64, test->args.value);
|
248
|
-
if (test->args.min.set) {
|
249
|
-
printf (" min=%" PRId64, test->args.min.value);
|
250
|
-
}
|
251
|
-
if (test->args.max.set) {
|
252
|
-
printf (" max=%" PRId64, test->args.max.value);
|
253
|
-
}
|
254
|
-
printf ("\n");
|
255
|
-
mc_OSTType_Int64 got;
|
256
|
-
const bool ok = mc_getTypeInfo64 (test->args, &got, status);
|
257
|
-
if (test->expectError) {
|
258
|
-
ASSERT_OR_PRINT_MSG (!ok, "expected error, but got none");
|
259
|
-
ASSERT_STATUS_CONTAINS (status, test->expectError);
|
260
|
-
} else {
|
261
|
-
ASSERT_OK_STATUS (ok, status);
|
262
|
-
ASSERT_CMPUINT64 (got.value, ==, test->expect.value);
|
263
|
-
ASSERT_CMPUINT64 (got.min, ==, test->expect.min);
|
264
|
-
ASSERT_CMPUINT64 (got.max, ==, test->expect.max);
|
265
|
-
}
|
266
|
-
mongocrypt_status_destroy (status);
|
267
|
-
}
|
114
|
+
static void _test_RangeTest_Encode_Int64(_mongocrypt_tester_t *tester) {
|
115
|
+
Int64Test tests[] = {
|
116
|
+
/* Test cases copied from server Int64_NoBounds test ... begin */
|
117
|
+
{.args = {.value = INT64_C(9223372036854775807)},
|
118
|
+
.expect = {.value = UINT64_C(18446744073709551615), .min = 0, .max = UINT64_MAX}},
|
119
|
+
{.args = {.value = 1}, .expect = {.value = UINT64_C(9223372036854775809), .min = 0, .max = UINT64_MAX}},
|
120
|
+
{.args = {.value = 0}, .expect = {.value = UINT64_C(9223372036854775808), .min = 0, .max = UINT64_MAX}},
|
121
|
+
{.args = {.value = -1}, .expect = {.value = UINT64_C(9223372036854775807), .min = 0, .max = UINT64_MAX}},
|
122
|
+
{.args = {.value = -2}, .expect = {.value = UINT64_C(9223372036854775806), .min = 0, .max = UINT64_MAX}},
|
123
|
+
{.args = {.value = INT64_C(-9223372036854775807)}, .expect = {.value = 1, .min = 0, .max = UINT64_MAX}},
|
124
|
+
{.args = {.value = INT64_MIN}, .expect = {.value = 0, .min = 0, .max = UINT64_MAX}},
|
125
|
+
/* Test cases copied from server Int64_NoBounds test ... end */
|
126
|
+
/* Test cases copied from server Int64_Bounds test ... begin */
|
127
|
+
{.args = {.value = 1, .min = OPT_I64(1), .max = OPT_I64(2)}, .expect = {.value = 0, .min = 0, .max = 1}},
|
128
|
+
{.args = {.value = 0, .min = OPT_I64(0), .max = OPT_I64(1)}, .expect = {.value = 0, .min = 0, .max = 1}},
|
129
|
+
{.args = {.value = -1, .min = OPT_I64(-1), .max = OPT_I64(0)}, .expect = {.value = 0, .min = 0, .max = 1}},
|
130
|
+
{.args = {.value = -2, .min = OPT_I64(-2), .max = OPT_I64(0)}, .expect = {.value = 0, .min = 0, .max = 2}},
|
131
|
+
{.args = {.value = INT64_C(-9223372036854775807), .min = OPT_I64(INT64_MIN), .max = OPT_I64(1)},
|
132
|
+
.expect = {.value = 1, .min = 0, .max = UINT64_C(9223372036854775809)}},
|
133
|
+
{.args = {.value = INT64_MIN, .min = OPT_I64(INT64_MIN), .max = OPT_I64(0)},
|
134
|
+
.expect = {.value = 0, .min = 0, .max = UINT64_C(9223372036854775808)}},
|
135
|
+
{.args = {.value = 0, .min = OPT_I64(INT64_MIN), .max = OPT_I64(37)},
|
136
|
+
.expect = {.value = UINT64_C(9223372036854775808), .min = 0, .max = UINT64_C(9223372036854775845)}},
|
137
|
+
{.args = {.value = 1, .min = OPT_I64(INT64_MIN), .max = OPT_I64(42)},
|
138
|
+
.expect = {.value = UINT64_C(9223372036854775809), .min = 0, .max = UINT64_C(9223372036854775850)}},
|
139
|
+
{.args = {.value = INT64_C(9223372036854775807),
|
140
|
+
.min = OPT_I64(-9223372036854775807),
|
141
|
+
.max = OPT_I64(9223372036854775807)},
|
142
|
+
.expect = {.value = UINT64_C(18446744073709551614), .min = 0, .max = UINT64_C(18446744073709551614)}},
|
143
|
+
{.args = {.value = INT64_C(9223372036854775807),
|
144
|
+
.min = OPT_I64(INT64_MIN),
|
145
|
+
.max = OPT_I64(9223372036854775807)},
|
146
|
+
.expect = {.value = UINT64_C(18446744073709551615), .min = 0, .max = UINT64_C(18446744073709551615)}},
|
147
|
+
{.args = {.value = 15, .min = OPT_I64(10), .max = OPT_I64(26)}, .expect = {.value = 5, .min = 0, .max = 16}},
|
148
|
+
{.args = {.value = 15, .min = OPT_I64(-10), .max = OPT_I64(55)}, .expect = {.value = 25, .min = 0, .max = 65}},
|
149
|
+
/* Test cases copied from server Int64_Bounds test ... end */
|
150
|
+
/* Test cases copied from server Int64_Errors test ... begin */
|
151
|
+
{.args = {.value = 1, .max = OPT_I64(2)},
|
152
|
+
.expectError = "Must specify both a lower and upper bound or no bounds."},
|
153
|
+
{.args = {.value = 1, .min = OPT_I64(0)},
|
154
|
+
.expectError = "Must specify both a lower and upper bound or no bounds."},
|
155
|
+
{.args = {.value = 1, .min = OPT_I64(2), .max = OPT_I64(1)},
|
156
|
+
.expectError = "The minimum value must be less than the maximum value"},
|
157
|
+
{.args = {.value = 1, .min = OPT_I64(2), .max = OPT_I64(3)},
|
158
|
+
.expectError = "Value must be greater than or equal to the minimum "
|
159
|
+
"value and less than or equal to the maximum value"},
|
160
|
+
{.args = {.value = 4, .min = OPT_I64(2), .max = OPT_I64(3)},
|
161
|
+
.expectError = "Value must be greater than or equal to the minimum "
|
162
|
+
"value and less than or equal to the maximum value"},
|
163
|
+
{.args = {.value = 4, .min = OPT_I64(INT64_MIN), .max = OPT_I64(INT64_MIN)},
|
164
|
+
.expectError = "The minimum value must be less than the maximum value"},
|
165
|
+
/* Test cases copied from server Int64_Errors test ... end */
|
166
|
+
};
|
167
|
+
|
168
|
+
for (size_t i = 0; i < sizeof(tests) / sizeof(tests[0]); i++) {
|
169
|
+
Int64Test *test = tests + i;
|
170
|
+
mongocrypt_status_t *const status = mongocrypt_status_new();
|
171
|
+
|
172
|
+
// Print a description of the test case.
|
173
|
+
printf("_test_RangeTest_Encode_Int64: value=%" PRId64, test->args.value);
|
174
|
+
if (test->args.min.set) {
|
175
|
+
printf(" min=%" PRId64, test->args.min.value);
|
176
|
+
}
|
177
|
+
if (test->args.max.set) {
|
178
|
+
printf(" max=%" PRId64, test->args.max.value);
|
179
|
+
}
|
180
|
+
printf("\n");
|
181
|
+
mc_OSTType_Int64 got;
|
182
|
+
const bool ok = mc_getTypeInfo64(test->args, &got, status);
|
183
|
+
if (test->expectError) {
|
184
|
+
ASSERT_OR_PRINT_MSG(!ok, "expected error, but got none");
|
185
|
+
ASSERT_STATUS_CONTAINS(status, test->expectError);
|
186
|
+
} else {
|
187
|
+
ASSERT_OK_STATUS(ok, status);
|
188
|
+
ASSERT_CMPUINT64(got.value, ==, test->expect.value);
|
189
|
+
ASSERT_CMPUINT64(got.min, ==, test->expect.min);
|
190
|
+
ASSERT_CMPUINT64(got.max, ==, test->expect.max);
|
191
|
+
}
|
192
|
+
mongocrypt_status_destroy(status);
|
193
|
+
}
|
268
194
|
}
|
269
195
|
|
270
196
|
typedef struct {
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
197
|
+
double value;
|
198
|
+
mc_optional_double_t min;
|
199
|
+
mc_optional_double_t max;
|
200
|
+
mc_optional_uint32_t precision;
|
201
|
+
uint64_t expect;
|
202
|
+
mc_optional_uint64_t expectMax;
|
203
|
+
const char *expectError;
|
278
204
|
} DoubleTest;
|
279
205
|
|
280
|
-
static void
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
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
|
-
}
|
206
|
+
static void _test_RangeTest_Encode_Double(_mongocrypt_tester_t *tester) {
|
207
|
+
DoubleTest tests[] = {/* Test cases copied from server Double_Bounds test ... begin */
|
208
|
+
// Larger numbers map to larger uint64
|
209
|
+
{.value = -1111, .expect = UINT64_C(4570770991734587392)},
|
210
|
+
{.value = -111, .expect = UINT64_C(4585860689314185216)},
|
211
|
+
{.value = -11, .expect = UINT64_C(4600989969312382976)},
|
212
|
+
{.value = -10, .expect = UINT64_C(4601552919265804288)},
|
213
|
+
{.value = -3, .expect = UINT64_C(4609434218613702656)},
|
214
|
+
{.value = -2, .expect = UINT64_C(4611686018427387904)},
|
215
|
+
|
216
|
+
{.value = -1, .expect = UINT64_C(4616189618054758400)},
|
217
|
+
{.value = 1, .expect = UINT64_C(13830554455654793216)},
|
218
|
+
{.value = 22, .expect = UINT64_C(13850257704024539136)},
|
219
|
+
{.value = 333, .expect = UINT64_C(13867937850999177216)},
|
220
|
+
|
221
|
+
// Larger exponents map to larger uint64
|
222
|
+
{.value = 33E56, .expect = UINT64_C(14690973652625833878)},
|
223
|
+
{.value = 22E57, .expect = UINT64_C(14703137697061005818)},
|
224
|
+
{.value = 11E58, .expect = UINT64_C(14713688953586463292)},
|
225
|
+
|
226
|
+
// Smaller exponents map to smaller uint64
|
227
|
+
{.value = 1E-6, .expect = UINT64_C(13740701229962882445)},
|
228
|
+
{.value = 1E-7, .expect = UINT64_C(13725520251343122248)},
|
229
|
+
{.value = 1E-8, .expect = UINT64_C(13710498295186492474)},
|
230
|
+
{.value = 1E-56, .expect = UINT64_C(12992711961033031890)},
|
231
|
+
{.value = 1E-57, .expect = UINT64_C(12977434315086142017)},
|
232
|
+
{.value = 1E-58, .expect = UINT64_C(12962510038552207822)},
|
233
|
+
|
234
|
+
// Smaller negative exponents map to smaller uint64
|
235
|
+
{.value = -1E-06, .expect = UINT64_C(4706042843746669171)},
|
236
|
+
{.value = -1E-07, .expect = UINT64_C(4721223822366429368)},
|
237
|
+
{.value = -1E-08, .expect = UINT64_C(4736245778523059142)},
|
238
|
+
{.value = -1E-56, .expect = UINT64_C(5454032112676519726)},
|
239
|
+
{.value = -1E-57, .expect = UINT64_C(5469309758623409599)},
|
240
|
+
{.value = -1E-58, .expect = UINT64_C(5484234035157343794)},
|
241
|
+
|
242
|
+
// Larger exponents map to larger uint64
|
243
|
+
{.value = -33E+56, .expect = UINT64_C(3755770421083717738)},
|
244
|
+
{.value = -22E+57, .expect = UINT64_C(3743606376648545798)},
|
245
|
+
{.value = -11E+58, .expect = UINT64_C(3733055120123088324)},
|
246
|
+
|
247
|
+
{.value = 0, .expect = UINT64_C(9223372036854775808)},
|
248
|
+
{.value = -0.0, .expect = UINT64_C(9223372036854775808)},
|
249
|
+
/* Test cases copied from server Double_Bounds test ... end */
|
250
|
+
/* Test cases copied from server Double_Errors test ... begin */
|
251
|
+
{.value = INFINITY, .expectError = "Infinity and NaN double values are not supported."},
|
252
|
+
{.value = NAN, .expectError = "Infinity and NaN double values are not supported."},
|
253
|
+
/* Test cases copied from server Double_Errors test ... end */
|
254
|
+
|
255
|
+
/* Test cases copied from Double_Bounds_Precision ... begin */
|
256
|
+
{.value = 3.141592653589,
|
257
|
+
.precision = OPT_U32_C(1),
|
258
|
+
.min = OPT_DOUBLE_C(-100000),
|
259
|
+
.max = OPT_DOUBLE_C(100000),
|
260
|
+
.expect = UINT64_C(1000031),
|
261
|
+
.expectMax = OPT_U64_C(2097151)},
|
262
|
+
{.value = 3.141592653589,
|
263
|
+
.precision = OPT_U32_C(2),
|
264
|
+
.min = OPT_DOUBLE_C(-100000),
|
265
|
+
.max = OPT_DOUBLE_C(100000),
|
266
|
+
.expect = 10000314,
|
267
|
+
.expectMax = OPT_U64_C(33554431)},
|
268
|
+
{.value = 3.141592653589,
|
269
|
+
.precision = OPT_U32_C(3),
|
270
|
+
.min = OPT_DOUBLE_C(-100000),
|
271
|
+
.max = OPT_DOUBLE_C(100000),
|
272
|
+
.expect = 100003141,
|
273
|
+
.expectMax = OPT_U64_C(268435455)},
|
274
|
+
{.value = 3.141592653589,
|
275
|
+
.precision = OPT_U32_C(4),
|
276
|
+
.min = OPT_DOUBLE_C(-100000),
|
277
|
+
.max = OPT_DOUBLE_C(100000),
|
278
|
+
.expect = 1000031415,
|
279
|
+
.expectMax = OPT_U64_C(2147483647)},
|
280
|
+
{.value = 3.141592653589,
|
281
|
+
.precision = OPT_U32_C(5),
|
282
|
+
.min = OPT_DOUBLE_C(-100000),
|
283
|
+
.max = OPT_DOUBLE_C(100000),
|
284
|
+
.expect = 10000314159,
|
285
|
+
.expectMax = OPT_U64_C(34359738367)},
|
286
|
+
{.value = 3.141592653589,
|
287
|
+
.precision = OPT_U32_C(6),
|
288
|
+
.min = OPT_DOUBLE_C(-100000),
|
289
|
+
.max = OPT_DOUBLE_C(100000),
|
290
|
+
.expect = 100003141592,
|
291
|
+
.expectMax = OPT_U64_C(274877906943)},
|
292
|
+
{.value = 3.141592653589,
|
293
|
+
.precision = OPT_U32_C(7),
|
294
|
+
.min = OPT_DOUBLE_C(-100000),
|
295
|
+
.max = OPT_DOUBLE_C(100000),
|
296
|
+
.expect = 1000031415926,
|
297
|
+
.expectMax = OPT_U64_C(2199023255551)},
|
298
|
+
{.value = 0,
|
299
|
+
.max = OPT_DOUBLE_C(1),
|
300
|
+
.min = OPT_DOUBLE_C(-1),
|
301
|
+
.precision = OPT_U32_C(3),
|
302
|
+
.expect = 1000,
|
303
|
+
.expectMax = OPT_U64_C(4095)},
|
304
|
+
{.value = 0,
|
305
|
+
.max = OPT_DOUBLE_C(1),
|
306
|
+
.min = OPT_DOUBLE_C(-1E5),
|
307
|
+
.precision = OPT_U32_C(3),
|
308
|
+
.expect = 100000000,
|
309
|
+
.expectMax = OPT_U64_C(134217727)},
|
310
|
+
{.value = -1E-33,
|
311
|
+
.max = OPT_DOUBLE_C(1),
|
312
|
+
.min = OPT_DOUBLE_C(-1E5),
|
313
|
+
.precision = OPT_U32_C(3),
|
314
|
+
.expect = 100000000,
|
315
|
+
.expectMax = OPT_U64_C(134217727)},
|
316
|
+
{.value = 0,
|
317
|
+
.max = OPT_DOUBLE_C(DBL_MAX),
|
318
|
+
.min = OPT_DOUBLE_C(-DBL_MAX),
|
319
|
+
.precision = OPT_U32_C(3),
|
320
|
+
.expect = UINT64_C(9223372036854775808),
|
321
|
+
// Expect precision not to be used.
|
322
|
+
.expectMax = OPT_U64_C(UINT64_MAX)},
|
323
|
+
{.value = 3.141592653589,
|
324
|
+
.max = OPT_DOUBLE_C(5),
|
325
|
+
.min = OPT_DOUBLE_C(0),
|
326
|
+
.precision = OPT_U32_C(0),
|
327
|
+
.expect = 3,
|
328
|
+
.expectMax = OPT_U64_C(7)},
|
329
|
+
{.value = 3.141592653589,
|
330
|
+
.max = OPT_DOUBLE_C(5),
|
331
|
+
.min = OPT_DOUBLE_C(0),
|
332
|
+
.precision = OPT_U32_C(1),
|
333
|
+
.expect = 31,
|
334
|
+
.expectMax = OPT_U64_C(63)},
|
335
|
+
{.value = 3.141592653589,
|
336
|
+
.max = OPT_DOUBLE_C(5),
|
337
|
+
.min = OPT_DOUBLE_C(0),
|
338
|
+
.precision = OPT_U32_C(2),
|
339
|
+
.expect = 314,
|
340
|
+
.expectMax = OPT_U64_C(1023)},
|
341
|
+
{.value = 3.141592653589,
|
342
|
+
.max = OPT_DOUBLE_C(5),
|
343
|
+
.min = OPT_DOUBLE_C(0),
|
344
|
+
.precision = OPT_U32_C(3),
|
345
|
+
.expect = 3141,
|
346
|
+
.expectMax = OPT_U64_C(8191)},
|
347
|
+
{.value = 3.141592653589,
|
348
|
+
.max = OPT_DOUBLE_C(5),
|
349
|
+
.min = OPT_DOUBLE_C(0),
|
350
|
+
.precision = OPT_U32_C(16),
|
351
|
+
.expect = 31415926535890000,
|
352
|
+
.expectMax = OPT_U64_C(72057594037927935)},
|
353
|
+
{.value = -5,
|
354
|
+
.max = OPT_DOUBLE_C(-1),
|
355
|
+
.min = OPT_DOUBLE_C(-10),
|
356
|
+
.precision = OPT_U32_C(3),
|
357
|
+
.expect = 5000,
|
358
|
+
.expectMax = OPT_U64_C(16383)},
|
359
|
+
{.value = 1E100,
|
360
|
+
.max = OPT_DOUBLE_C(DBL_MAX),
|
361
|
+
.min = OPT_DOUBLE_C(-DBL_MAX),
|
362
|
+
.precision = OPT_U32_C(3),
|
363
|
+
.expect = 15326393489903895421ULL,
|
364
|
+
// Expect precision not to be used.
|
365
|
+
.expectMax = OPT_U64_C(UINT64_MAX)},
|
366
|
+
{.value = 1E9,
|
367
|
+
.max = OPT_DOUBLE_C(1E10),
|
368
|
+
.min = OPT_DOUBLE_C(0),
|
369
|
+
.precision = OPT_U32_C(3),
|
370
|
+
.expect = 1000000000000,
|
371
|
+
.expectMax = OPT_U64_C(17592186044415)},
|
372
|
+
{.value = 1E9,
|
373
|
+
.max = OPT_DOUBLE_C(1E10),
|
374
|
+
.min = OPT_DOUBLE_C(0),
|
375
|
+
.precision = OPT_U32_C(0),
|
376
|
+
.expect = 1000000000,
|
377
|
+
.expectMax = OPT_U64_C(17179869183)},
|
378
|
+
{.value = -5,
|
379
|
+
.max = OPT_DOUBLE_C(10),
|
380
|
+
.min = OPT_DOUBLE_C(-10),
|
381
|
+
.precision = OPT_U32_C(0),
|
382
|
+
.expect = 5,
|
383
|
+
.expectMax = OPT_U64_C(31)},
|
384
|
+
{.value = -5,
|
385
|
+
.max = OPT_DOUBLE_C(10),
|
386
|
+
.min = OPT_DOUBLE_C(-10),
|
387
|
+
.precision = OPT_U32_C(2),
|
388
|
+
.expect = 500,
|
389
|
+
.expectMax = OPT_U64_C(4095)},
|
390
|
+
{.value = 1E-30,
|
391
|
+
.max = OPT_DOUBLE_C(10E-30),
|
392
|
+
.min = OPT_DOUBLE_C(1E-30),
|
393
|
+
.precision = OPT_U32_C(35),
|
394
|
+
.expect = 13381399884061196960ULL,
|
395
|
+
// Expect precision not to be used.
|
396
|
+
.expectMax = OPT_U64_C(UINT64_MAX)},
|
397
|
+
/* Test cases copied from Double_Bounds_Precision ... end */
|
398
|
+
{.value = -1,
|
399
|
+
.min = OPT_DOUBLE_C(0),
|
400
|
+
.max = OPT_DOUBLE_C(200),
|
401
|
+
.precision = OPT_U32_C(1),
|
402
|
+
.expectError = "greater than or equal to the minimum value"},
|
403
|
+
{.value = -1,
|
404
|
+
.min = OPT_DOUBLE_C(0),
|
405
|
+
.max = OPT_DOUBLE_C(201),
|
406
|
+
.precision = OPT_U32_C(1),
|
407
|
+
.expectError = "less than or equal to the maximum value"}};
|
408
|
+
|
409
|
+
for (size_t i = 0; i < sizeof(tests) / sizeof(tests[0]); i++) {
|
410
|
+
DoubleTest *test = tests + i;
|
411
|
+
mongocrypt_status_t *const status = mongocrypt_status_new();
|
412
|
+
|
413
|
+
if (test->min.set && test->max.set && test->precision.set) {
|
414
|
+
printf("_test_RangeTest_Encode_Double: value=%f, min=%f, max=%f, "
|
415
|
+
"precision=%" PRIu32 "\n",
|
416
|
+
test->value,
|
417
|
+
test->min.value,
|
418
|
+
test->max.value,
|
419
|
+
test->precision.value);
|
420
|
+
} else {
|
421
|
+
printf("_test_RangeTest_Encode_Double: value=%f\n", test->value);
|
422
|
+
}
|
423
|
+
|
424
|
+
mc_OSTType_Double got;
|
425
|
+
const bool ok = mc_getTypeInfoDouble((mc_getTypeInfoDouble_args_t){.value = test->value,
|
426
|
+
.min = test->min,
|
427
|
+
.max = test->max,
|
428
|
+
.precision = test->precision},
|
429
|
+
&got,
|
430
|
+
status);
|
431
|
+
if (test->expectError) {
|
432
|
+
ASSERT_OR_PRINT_MSG(!ok, "expected error, but got none");
|
433
|
+
ASSERT_STATUS_CONTAINS(status, test->expectError);
|
434
|
+
} else {
|
435
|
+
ASSERT_OK_STATUS(ok, status);
|
436
|
+
ASSERT_CMPUINT64(got.value, ==, test->expect);
|
437
|
+
ASSERT_CMPUINT64(got.min, ==, 0);
|
438
|
+
ASSERT_CMPUINT64(got.max, ==, test->expectMax.set ? test->expectMax.value : UINT64_MAX);
|
439
|
+
}
|
440
|
+
mongocrypt_status_destroy(status);
|
441
|
+
}
|
525
442
|
}
|
526
443
|
|
527
|
-
|
528
444
|
#if MONGOCRYPT_HAVE_DECIMAL128_SUPPORT
|
529
445
|
typedef struct {
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
446
|
+
mc_dec128 value;
|
447
|
+
mc_optional_dec128_t min;
|
448
|
+
mc_optional_dec128_t max;
|
449
|
+
mc_optional_uint32_t precision;
|
450
|
+
mlib_int128 expect;
|
451
|
+
const char *expectError;
|
536
452
|
} Decimal128Test;
|
537
453
|
|
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
|
-
ERROR_CASE (MC_DEC128_POSITIVE_NAN,
|
689
|
-
OPT_NULLOPT,
|
690
|
-
OPT_NULLOPT,
|
691
|
-
OPT_NULLOPT,
|
692
|
-
"Infinity and Nan Decimal128 values are not supported."),
|
693
|
-
|
694
|
-
ERROR_CASE (MC_DEC128_NEGATIVE_NAN,
|
695
|
-
OPT_NULLOPT,
|
696
|
-
OPT_NULLOPT,
|
697
|
-
OPT_NULLOPT,
|
698
|
-
"Infinity and Nan Decimal128 values are not supported."),
|
454
|
+
static void _test_RangeTest_Encode_Decimal128(_mongocrypt_tester_t *tester) {
|
455
|
+
Decimal128Test tests[] = {
|
456
|
+
#define CASE(Value, ExpectStr) \
|
457
|
+
(Decimal128Test){.value = mc_dec128_from_string(#Value), .expect = mlib_int128_from_string(ExpectStr, NULL)}
|
458
|
+
/* Test cases copied from server Decimal128_Bounds test ... begin */
|
459
|
+
// Larger numbers map to larger int128
|
460
|
+
CASE(-1234567890E7, "108549948892579231731687303715884111887"),
|
461
|
+
CASE(-1234567890E6, "108559948892579231731687303715884111886"),
|
462
|
+
CASE(-1234567890E5, "108569948892579231731687303715884111885"),
|
463
|
+
CASE(-1234567890E4, "108579948892579231731687303715884111884"),
|
464
|
+
CASE(-1234567890E3, "108589948892579231731687303715884111883"),
|
465
|
+
CASE(-1234567890E2, "108599948892579231731687303715884111882"),
|
466
|
+
CASE(-1234567890E1, "108609948892579231731687303715884111881"),
|
467
|
+
CASE(-123456789012345, "108569948892579108281687303715884111885"),
|
468
|
+
CASE(-12345678901234, "108579948892579108331687303715884111884"),
|
469
|
+
CASE(-1234567890123, "108589948892579108731687303715884111883"),
|
470
|
+
CASE(-123456789012, "108599948892579111731687303715884111882"),
|
471
|
+
CASE(-12345678901, "108609948892579131731687303715884111881"),
|
472
|
+
CASE(-1234567890, "108619948892579231731687303715884111880"),
|
473
|
+
CASE(-99999999, "108631183460569231731687303715884111878"),
|
474
|
+
CASE(-8888888, "108642294572469231731687303715884111877"),
|
475
|
+
CASE(-777777, "108653405690469231731687303715884111876"),
|
476
|
+
CASE(-66666, "108664516860469231731687303715884111875"),
|
477
|
+
CASE(-5555, "108675628460469231731687303715884111874"),
|
478
|
+
CASE(-444, "108686743460469231731687303715884111873"),
|
479
|
+
CASE(-334, "108687843460469231731687303715884111873"),
|
480
|
+
CASE(-333, "108687853460469231731687303715884111873"),
|
481
|
+
CASE(-44, "108696783460469231731687303715884111872"),
|
482
|
+
CASE(-33, "108697883460469231731687303715884111872"),
|
483
|
+
CASE(-22, "108698983460469231731687303715884111872"),
|
484
|
+
CASE(-5, "108706183460469231731687303715884111871"),
|
485
|
+
CASE(-4, "108707183460469231731687303715884111871"),
|
486
|
+
CASE(-3, "108708183460469231731687303715884111871"),
|
487
|
+
CASE(-2, "108709183460469231731687303715884111871"),
|
488
|
+
CASE(-1, "108710183460469231731687303715884111871"),
|
489
|
+
CASE(0, "170141183460469231731687303715884105728"),
|
490
|
+
CASE(1, "231572183460469231731687303715884099585"),
|
491
|
+
CASE(2, "231573183460469231731687303715884099585"),
|
492
|
+
CASE(3, "231574183460469231731687303715884099585"),
|
493
|
+
CASE(4, "231575183460469231731687303715884099585"),
|
494
|
+
CASE(5, "231576183460469231731687303715884099585"),
|
495
|
+
CASE(22, "231583383460469231731687303715884099584"),
|
496
|
+
CASE(33, "231584483460469231731687303715884099584"),
|
497
|
+
CASE(44, "231585583460469231731687303715884099584"),
|
498
|
+
CASE(333, "231594513460469231731687303715884099583"),
|
499
|
+
CASE(334, "231594523460469231731687303715884099583"),
|
500
|
+
CASE(444, "231595623460469231731687303715884099583"),
|
501
|
+
CASE(5555, "231606738460469231731687303715884099582"),
|
502
|
+
CASE(66666, "231617850060469231731687303715884099581"),
|
503
|
+
CASE(777777, "231628961230469231731687303715884099580"),
|
504
|
+
CASE(8888888, "231640072348469231731687303715884099579"),
|
505
|
+
CASE(33E56, "232144483460469231731687303715884099528"),
|
506
|
+
CASE(22E57, "232153383460469231731687303715884099527"),
|
507
|
+
CASE(11E58, "232162283460469231731687303715884099526"),
|
508
|
+
|
509
|
+
// Smaller exponents map to smaller int128
|
510
|
+
CASE(1E-6, "231512183460469231731687303715884099591"),
|
511
|
+
CASE(1E-7, "231502183460469231731687303715884099592"),
|
512
|
+
CASE(1E-8, "231492183460469231731687303715884099593"),
|
513
|
+
CASE(1E-56, "231012183460469231731687303715884099641"),
|
514
|
+
CASE(1E-57, "231002183460469231731687303715884099642"),
|
515
|
+
CASE(1E-58, "230992183460469231731687303715884099643"),
|
516
|
+
|
517
|
+
// Smaller negative exponents map to smaller int128
|
518
|
+
CASE(-1E-6, "108770183460469231731687303715884111865"),
|
519
|
+
CASE(-1E-7, "108780183460469231731687303715884111864"),
|
520
|
+
CASE(-1E-8, "108790183460469231731687303715884111863"),
|
521
|
+
CASE(-1E-56, "109270183460469231731687303715884111815"),
|
522
|
+
CASE(-1E-57, "109280183460469231731687303715884111814"),
|
523
|
+
CASE(-1E-58, "109290183460469231731687303715884111813"),
|
524
|
+
|
525
|
+
// Larger exponents map to larger int128
|
526
|
+
CASE(-33E56, "108137883460469231731687303715884111928"),
|
527
|
+
CASE(-22E57, "108128983460469231731687303715884111929"),
|
528
|
+
CASE(-11E58, "108120083460469231731687303715884111930"),
|
529
|
+
|
530
|
+
(Decimal128Test){.value = MC_DEC128_LARGEST_POSITIVE,
|
531
|
+
.expect = mlib_int128_from_string("293021183460469231731687303715884093440", NULL)},
|
532
|
+
(Decimal128Test){.value = MC_DEC128_SMALLEST_POSITIVE,
|
533
|
+
.expect = mlib_int128_from_string("170141183460469231731687303715884105729", NULL)},
|
534
|
+
(Decimal128Test){.value = MC_DEC128_LARGEST_NEGATIVE,
|
535
|
+
.expect = mlib_int128_from_string("47261183460469231731687303715884118016", NULL)},
|
536
|
+
(Decimal128Test){.value = MC_DEC128_SMALLEST_NEGATIVE,
|
537
|
+
.expect = mlib_int128_from_string("170141183460469231731687303715884105727", NULL)},
|
538
|
+
(Decimal128Test){.value = MC_DEC128_NORMALIZED_ZERO,
|
539
|
+
.expect = mlib_int128_from_string("170141183460469231731687303715884105728", NULL)},
|
540
|
+
(Decimal128Test){.value = MC_DEC128_NEGATIVE_EXPONENT_ZERO,
|
541
|
+
.expect = mlib_int128_from_string("170141183460469231731687303715884105728", NULL)},
|
542
|
+
/* Test cases copied from server Decimal128_Bounds test ... end */
|
543
|
+
|
544
|
+
#define ERROR_CASE(Value, Min, Max, Precision, ErrorString) \
|
545
|
+
(Decimal128Test){ \
|
546
|
+
.value = Value, \
|
547
|
+
.min = Min, \
|
548
|
+
.max = Max, \
|
549
|
+
.precision = Precision, \
|
550
|
+
.expectError = ErrorString, \
|
551
|
+
}
|
552
|
+
|
553
|
+
ERROR_CASE(MC_DEC128_C(1),
|
554
|
+
OPT_NULLOPT,
|
555
|
+
OPT_MC_DEC128(MC_DEC128_C(2)),
|
556
|
+
OPT_U32(5),
|
557
|
+
"min, max, and precision must all be set or must all be unset"),
|
558
|
+
ERROR_CASE(MC_DEC128_C(1),
|
559
|
+
OPT_MC_DEC128(MC_DEC128_C(0)),
|
560
|
+
OPT_NULLOPT,
|
561
|
+
OPT_U32(5),
|
562
|
+
"min, max, and precision must all be set or must all be unset"),
|
563
|
+
ERROR_CASE(MC_DEC128_C(1),
|
564
|
+
OPT_MC_DEC128(MC_DEC128_C(2)),
|
565
|
+
OPT_MC_DEC128(MC_DEC128_C(1)),
|
566
|
+
OPT_U32(5),
|
567
|
+
"The minimum value must be less than the maximum value"),
|
568
|
+
|
569
|
+
ERROR_CASE(MC_DEC128_C(1),
|
570
|
+
OPT_MC_DEC128(MC_DEC128_C(2)),
|
571
|
+
OPT_MC_DEC128(MC_DEC128_C(3)),
|
572
|
+
OPT_U32(5),
|
573
|
+
"Value must be greater than or equal to the minimum value "
|
574
|
+
"and less than or equal to the maximum value"),
|
575
|
+
ERROR_CASE(MC_DEC128_C(4),
|
576
|
+
OPT_MC_DEC128(MC_DEC128_C(2)),
|
577
|
+
OPT_MC_DEC128(MC_DEC128_C(3)),
|
578
|
+
OPT_U32(5),
|
579
|
+
"Value must be greater than or equal to the minimum value "
|
580
|
+
"and less than or equal to the maximum value"),
|
581
|
+
|
582
|
+
ERROR_CASE(MC_DEC128_POSITIVE_INFINITY,
|
583
|
+
OPT_NULLOPT,
|
584
|
+
OPT_NULLOPT,
|
585
|
+
OPT_NULLOPT,
|
586
|
+
"Infinity and Nan Decimal128 values are not supported."),
|
587
|
+
ERROR_CASE(MC_DEC128_NEGATIVE_INFINITY,
|
588
|
+
OPT_NULLOPT,
|
589
|
+
OPT_NULLOPT,
|
590
|
+
OPT_NULLOPT,
|
591
|
+
"Infinity and Nan Decimal128 values are not supported."),
|
592
|
+
|
593
|
+
ERROR_CASE(MC_DEC128_POSITIVE_NAN,
|
594
|
+
OPT_NULLOPT,
|
595
|
+
OPT_NULLOPT,
|
596
|
+
OPT_NULLOPT,
|
597
|
+
"Infinity and Nan Decimal128 values are not supported."),
|
598
|
+
|
599
|
+
ERROR_CASE(MC_DEC128_NEGATIVE_NAN,
|
600
|
+
OPT_NULLOPT,
|
601
|
+
OPT_NULLOPT,
|
602
|
+
OPT_NULLOPT,
|
603
|
+
"Infinity and Nan Decimal128 values are not supported."),
|
699
604
|
|
700
605
|
/* 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
|
-
|
606
|
+
#define ASSERT_EIBP(Value, Precision, Expect) \
|
607
|
+
(Decimal128Test){ \
|
608
|
+
.value = mc_dec128_from_string(Value), \
|
609
|
+
.min = OPT_MC_DEC128(MC_DEC128_C(-100000)), \
|
610
|
+
.max = OPT_MC_DEC128(MC_DEC128_C(100000)), \
|
611
|
+
.precision = OPT_U32(Precision), \
|
612
|
+
.expect = MLIB_INT128(Expect), \
|
613
|
+
}
|
614
|
+
ASSERT_EIBP("3.141592653589E-1", 10, 1000003141592653),
|
615
|
+
ASSERT_EIBP("31.41592653589E-2", 10, 1000003141592653),
|
616
|
+
ASSERT_EIBP("314.1592653589E-3", 10, 1000003141592653),
|
617
|
+
ASSERT_EIBP("3141.592653589E-4", 10, 1000003141592653),
|
618
|
+
ASSERT_EIBP("31415.92653589E-5", 10, 1000003141592653),
|
619
|
+
ASSERT_EIBP("314159.2653589E-6", 10, 1000003141592653),
|
620
|
+
ASSERT_EIBP("3141592.653589E-7", 10, 1000003141592653),
|
621
|
+
ASSERT_EIBP("31415926.53589E-8", 10, 1000003141592653),
|
717
622
|
#undef ASSERT_EIBP
|
718
623
|
|
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"),
|
624
|
+
#define ASSERT_EIBPL(Value, Precision, Expect) \
|
625
|
+
(Decimal128Test){ \
|
626
|
+
.value = mc_dec128_from_string(Value), \
|
627
|
+
.min = OPT_MC_DEC128(MC_DEC128_C(-100000)), \
|
628
|
+
.max = OPT_MC_DEC128(mc_dec128_from_string("1E22")), \
|
629
|
+
.precision = OPT_U32(Precision), \
|
630
|
+
.expect = mlib_int128_from_string(Expect, NULL), \
|
631
|
+
}
|
632
|
+
|
633
|
+
ASSERT_EIBPL("3.1415926535897932384626433832795E20", 5, "31415926535897942384626433"),
|
634
|
+
ASSERT_EIBPL("3.1415926535897932384626433832795E20", 6, "314159265358979423846264338"),
|
635
|
+
|
636
|
+
ASSERT_EIBPL("3.1415926535897932384626433832795E20", 7, "3141592653589794238462643383"),
|
637
|
+
|
638
|
+
ASSERT_EIBPL("3.1415926535897932384626433832795E20", 8, "31415926535897942384626433832"),
|
742
639
|
#undef ASSERT_EIBPL
|
743
640
|
|
744
|
-
#define ASSERT_EIBP(Value, Precision, Expect)
|
745
|
-
|
746
|
-
|
747
|
-
|
748
|
-
|
749
|
-
|
750
|
-
|
751
|
-
|
752
|
-
|
753
|
-
|
754
|
-
|
755
|
-
|
756
|
-
|
757
|
-
|
758
|
-
|
641
|
+
#define ASSERT_EIBP(Value, Precision, Expect) \
|
642
|
+
(Decimal128Test){ \
|
643
|
+
.value = mc_dec128_from_string(#Value), \
|
644
|
+
.min = OPT_MC_DEC128(MC_DEC128_C(-100000)), \
|
645
|
+
.max = OPT_MC_DEC128(MC_DEC128_C(100000)), \
|
646
|
+
.precision = OPT_U32(Precision), \
|
647
|
+
.expect = MLIB_INT128_CAST(Expect), \
|
648
|
+
}
|
649
|
+
ASSERT_EIBP(3.141592653589, 1, 1000031),
|
650
|
+
ASSERT_EIBP(3.141592653589, 2, 10000314),
|
651
|
+
ASSERT_EIBP(3.141592653589, 3, 100003141),
|
652
|
+
ASSERT_EIBP(3.141592653589, 4, 1000031415),
|
653
|
+
ASSERT_EIBP(3.141592653589, 5, 10000314159),
|
654
|
+
ASSERT_EIBP(3.141592653589, 6, 100003141592),
|
655
|
+
ASSERT_EIBP(3.141592653589, 7, 1000031415926),
|
759
656
|
#undef ASSERT_EIBP
|
760
657
|
|
761
|
-
#define ASSERT_EIBB(Val, Max, Min, Precision, Expect)
|
762
|
-
|
763
|
-
|
764
|
-
|
765
|
-
|
766
|
-
|
767
|
-
|
768
|
-
|
769
|
-
|
770
|
-
#define ASSERT_EIBB_OVERFLOW(Val, Max, Min, Precision, Expect)
|
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
|
-
ASSERT_EIBB (-5, 10, -10, 0, 5),
|
822
|
-
ASSERT_EIBB (-5, 10, -10, 2, 500),
|
823
|
-
|
824
|
-
ASSERT_EIBB (5E-30, 10E-30, 1E-30, 35, 400000),
|
825
|
-
|
826
|
-
// Test a range that requires > 64 bits.
|
827
|
-
ASSERT_EIBB (5, 18446744073709551616, .1, 1, 49),
|
828
|
-
// Test a range that requires > 64 bits.
|
829
|
-
// min has more places after the decimal than precision.
|
830
|
-
ASSERT_EIBB (5, 18446744073709551616, .01, 1, 49),
|
658
|
+
#define ASSERT_EIBB(Val, Max, Min, Precision, Expect) \
|
659
|
+
(Decimal128Test){ \
|
660
|
+
.value = mc_dec128_from_string(#Val), \
|
661
|
+
.min = OPT_MC_DEC128(mc_dec128_from_string(#Min)), \
|
662
|
+
.max = OPT_MC_DEC128(mc_dec128_from_string(#Max)), \
|
663
|
+
.precision = OPT_U32(Precision), \
|
664
|
+
.expect = MLIB_INT128_CAST(Expect), \
|
665
|
+
}
|
666
|
+
|
667
|
+
#define ASSERT_EIBB_OVERFLOW(Val, Max, Min, Precision, Expect) \
|
668
|
+
(Decimal128Test) { \
|
669
|
+
.value = mc_dec128_from_string(#Val), .min = OPT_MC_DEC128(mc_dec128_from_string(#Min)), \
|
670
|
+
.max = OPT_MC_DEC128(mc_dec128_from_string(#Max)), .precision = OPT_U32(Precision), .expect = Expect, \
|
671
|
+
}
|
672
|
+
|
673
|
+
ASSERT_EIBB(0, 1, -1, 3, 1000),
|
674
|
+
ASSERT_EIBB(0, 1, -1E5, 3, 100000000),
|
675
|
+
|
676
|
+
ASSERT_EIBB(-1E-33, 1, -1E5, 3, 100000000),
|
677
|
+
|
678
|
+
ASSERT_EIBB_OVERFLOW(0,
|
679
|
+
MC_DEC128_LARGEST_POSITIVE,
|
680
|
+
MC_DEC128_LARGEST_NEGATIVE,
|
681
|
+
3,
|
682
|
+
mlib_int128_from_string("170141183460469231731687303715884105728", NULL)),
|
683
|
+
ASSERT_EIBB_OVERFLOW(0,
|
684
|
+
DBL_MAX,
|
685
|
+
DBL_MIN,
|
686
|
+
3,
|
687
|
+
mlib_int128_from_string("170141183460469231731687303715884105728", NULL)),
|
688
|
+
|
689
|
+
ASSERT_EIBB(3.141592653589, 5, 0, 0, 3),
|
690
|
+
ASSERT_EIBB(3.141592653589, 5, 0, 1, 31),
|
691
|
+
|
692
|
+
ASSERT_EIBB(3.141592653589, 5, 0, 2, 314),
|
693
|
+
|
694
|
+
ASSERT_EIBB(3.141592653589, 5, 0, 3, 3141),
|
695
|
+
ASSERT_EIBB(3.141592653589, 5, 0, 16, 31415926535890000),
|
696
|
+
|
697
|
+
ASSERT_EIBB(-5, -1, -10, 3, 5000),
|
698
|
+
|
699
|
+
ASSERT_EIBB_OVERFLOW(1E100,
|
700
|
+
DBL_MAX,
|
701
|
+
DBL_MIN,
|
702
|
+
3,
|
703
|
+
mlib_int128_from_string("232572183460469231731687303715884099485", NULL)),
|
704
|
+
|
705
|
+
ASSERT_EIBB(1E9, 1E10, 0, 3, 1000000000000),
|
706
|
+
ASSERT_EIBB(1E9, 1E10, 0, 0, 1000000000),
|
707
|
+
|
708
|
+
ASSERT_EIBB(-5, 10, -10, 0, 5),
|
709
|
+
ASSERT_EIBB(-5, 10, -10, 2, 500),
|
710
|
+
|
711
|
+
ASSERT_EIBB(5E-30, 10E-30, 1E-30, 35, 400000),
|
712
|
+
|
713
|
+
// Test a range that requires > 64 bits.
|
714
|
+
ASSERT_EIBB(5, 18446744073709551616, .1, 1, 49),
|
715
|
+
// Test a range that requires > 64 bits.
|
716
|
+
// min has more places after the decimal than precision.
|
717
|
+
ASSERT_EIBB(5, 18446744073709551616, .01, 1, 49),
|
831
718
|
|
832
719
|
#undef ASSERT_EIBB
|
833
720
|
#undef ASSERT_EIBB_OVERFLOW
|
834
721
|
|
835
|
-
|
836
|
-
|
837
|
-
|
838
|
-
|
839
|
-
|
840
|
-
|
841
|
-
|
842
|
-
|
843
|
-
|
844
|
-
|
845
|
-
|
846
|
-
|
847
|
-
|
848
|
-
|
849
|
-
|
850
|
-
|
851
|
-
|
852
|
-
|
853
|
-
|
854
|
-
|
855
|
-
|
856
|
-
|
857
|
-
|
858
|
-
|
859
|
-
|
860
|
-
|
861
|
-
|
862
|
-
|
863
|
-
|
864
|
-
|
865
|
-
|
866
|
-
|
867
|
-
|
868
|
-
|
869
|
-
|
870
|
-
|
871
|
-
mongocrypt_status_destroy (status);
|
872
|
-
}
|
722
|
+
/* Test cases copied from Decimal128_Bounds_Precision ... end */
|
723
|
+
};
|
724
|
+
|
725
|
+
for (size_t i = 0; i < sizeof(tests) / sizeof(tests[0]); i++) {
|
726
|
+
Decimal128Test *test = tests + i;
|
727
|
+
mongocrypt_status_t *const status = mongocrypt_status_new();
|
728
|
+
|
729
|
+
if (test->min.set && test->max.set && test->precision.set) {
|
730
|
+
printf("_test_RangeTest_Encode_Decimal128: value=%s, min=%s, max=%s, "
|
731
|
+
"precision=%" PRIu32 "\n",
|
732
|
+
mc_dec128_to_string(test->value).str,
|
733
|
+
mc_dec128_to_string(test->min.value).str,
|
734
|
+
mc_dec128_to_string(test->max.value).str,
|
735
|
+
test->precision.value);
|
736
|
+
} else {
|
737
|
+
printf("_test_RangeTest_Encode_Decimal128: value=%s\n", mc_dec128_to_string(test->value).str);
|
738
|
+
}
|
739
|
+
fflush(stdout);
|
740
|
+
mc_OSTType_Decimal128 got;
|
741
|
+
const bool ok = mc_getTypeInfoDecimal128((mc_getTypeInfoDecimal128_args_t){.value = test->value,
|
742
|
+
.min = test->min,
|
743
|
+
.max = test->max,
|
744
|
+
.precision = test->precision},
|
745
|
+
&got,
|
746
|
+
status);
|
747
|
+
if (test->expectError) {
|
748
|
+
ASSERT_OR_PRINT_MSG(!ok, "expected error, but got none");
|
749
|
+
ASSERT_STATUS_CONTAINS(status, test->expectError);
|
750
|
+
} else {
|
751
|
+
ASSERT_OK_STATUS(ok, status);
|
752
|
+
|
753
|
+
ASSERT_CMPINT128_EQ(got.value, test->expect);
|
754
|
+
ASSERT_CMPINT128_EQ(got.min, MLIB_INT128(0));
|
755
|
+
}
|
756
|
+
mongocrypt_status_destroy(status);
|
757
|
+
}
|
873
758
|
}
|
874
759
|
|
875
760
|
#endif // MONGOCRYPT_HAVE_DECIMAL128_SUPPORT
|
876
761
|
|
877
|
-
void
|
878
|
-
|
879
|
-
|
880
|
-
|
881
|
-
INSTALL_TEST (_test_RangeTest_Encode_Int64);
|
882
|
-
INSTALL_TEST (_test_RangeTest_Encode_Double);
|
762
|
+
void _mongocrypt_tester_install_range_encoding(_mongocrypt_tester_t *tester) {
|
763
|
+
INSTALL_TEST(_test_RangeTest_Encode_Int32);
|
764
|
+
INSTALL_TEST(_test_RangeTest_Encode_Int64);
|
765
|
+
INSTALL_TEST(_test_RangeTest_Encode_Double);
|
883
766
|
#if MONGOCRYPT_HAVE_DECIMAL128_SUPPORT
|
884
|
-
|
767
|
+
INSTALL_TEST(_test_RangeTest_Encode_Decimal128);
|
885
768
|
#endif
|
886
769
|
}
|