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.
Files changed (396) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/ext/libmongocrypt/libmongocrypt/CHANGELOG.md +9 -7
  4. data/ext/libmongocrypt/libmongocrypt/CMakeLists.txt +17 -23
  5. data/ext/libmongocrypt/libmongocrypt/Earthfile +374 -0
  6. data/ext/libmongocrypt/libmongocrypt/README.md +7 -7
  7. data/ext/libmongocrypt/libmongocrypt/VERSION_CURRENT +1 -1
  8. data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/CryptClient.cs +25 -6
  9. data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/Library.cs +25 -3
  10. data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt.Example/MongoDB.Libmongocrypt.Example.csproj +1 -1
  11. data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt.Test/BasicTests.cs +1 -1
  12. data/ext/libmongocrypt/libmongocrypt/bindings/cs/Scripts/build.cake +3 -2
  13. data/ext/libmongocrypt/libmongocrypt/bindings/cs/cs.sln +79 -0
  14. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/build.gradle.kts +2 -2
  15. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/java/com/mongodb/crypt/capi/MongoCryptTest.java +6 -4
  16. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/fle2-find-range-explicit-v2/int32/encrypted-payload.json +26 -0
  17. data/ext/libmongocrypt/libmongocrypt/bindings/node/CHANGELOG.md +24 -0
  18. data/ext/libmongocrypt/libmongocrypt/bindings/node/README.md +134 -5
  19. data/ext/libmongocrypt/libmongocrypt/bindings/node/etc/build-static.sh +3 -6
  20. data/ext/libmongocrypt/libmongocrypt/bindings/node/index.d.ts +203 -77
  21. data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/autoEncrypter.js +1 -1
  22. data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/clientEncryption.js +165 -43
  23. data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/common.js +12 -14
  24. data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/errors.js +75 -0
  25. data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/index.js +34 -3
  26. data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/providers/aws.js +26 -0
  27. data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/providers/azure.js +178 -0
  28. data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/providers/gcp.js +24 -0
  29. data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/providers/index.js +54 -0
  30. data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/providers/utils.js +39 -0
  31. data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/stateMachine.js +9 -4
  32. data/ext/libmongocrypt/libmongocrypt/bindings/node/package-lock.json +4440 -5189
  33. data/ext/libmongocrypt/libmongocrypt/bindings/node/package.json +27 -8
  34. data/ext/libmongocrypt/libmongocrypt/bindings/node/src/mongocrypt.cc +65 -38
  35. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/autoEncrypter.test.js +4 -7
  36. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/clientEncryption.test.js +434 -42
  37. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/common.test.js +94 -0
  38. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/cryptoCallbacks.test.js +1 -45
  39. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/index.test.js +45 -0
  40. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/mongocryptdManager.test.js +1 -1
  41. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/providers/credentialsProvider.test.js +551 -0
  42. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/release.test.js +10 -3
  43. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/requirements.helper.js +23 -1
  44. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/stateMachine.test.js +1 -1
  45. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/tools/chai-addons.js +8 -0
  46. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/types/index.test-d.ts +63 -0
  47. data/ext/libmongocrypt/libmongocrypt/bindings/python/CHANGELOG.rst +26 -0
  48. data/ext/libmongocrypt/libmongocrypt/bindings/python/README.rst +2 -2
  49. data/ext/libmongocrypt/libmongocrypt/bindings/python/build-manylinux-wheel.sh +1 -1
  50. data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/binding.py +128 -238
  51. data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/compat.py +0 -27
  52. data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/explicit_encrypter.py +1 -1
  53. data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/mongocrypt.py +5 -21
  54. data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/version.py +2 -2
  55. data/ext/libmongocrypt/libmongocrypt/bindings/python/release.sh +5 -5
  56. data/ext/libmongocrypt/libmongocrypt/bindings/python/setup.py +14 -9
  57. data/ext/libmongocrypt/libmongocrypt/bindings/python/test/__init__.py +1 -10
  58. data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/fle2-find-range-explicit-v2/int32/encrypted-payload.json +26 -0
  59. data/ext/libmongocrypt/libmongocrypt/bindings/python/test/test_mongocrypt.py +5 -5
  60. data/ext/libmongocrypt/libmongocrypt/bindings/python/test-requirements.txt +4 -12
  61. data/ext/libmongocrypt/libmongocrypt/cmake/ImportBSON.cmake +8 -6
  62. data/ext/libmongocrypt/libmongocrypt/cmake/IntelDFP.cmake +2 -1
  63. data/ext/libmongocrypt/libmongocrypt/cmake/Platform.cmake +50 -0
  64. data/ext/libmongocrypt/libmongocrypt/cmake/mongocrypt-config.cmake +21 -0
  65. data/ext/libmongocrypt/libmongocrypt/debian/gbp.conf +2 -2
  66. data/ext/libmongocrypt/libmongocrypt/etc/c6-vault.repo +39 -0
  67. data/ext/libmongocrypt/libmongocrypt/etc/fle2_aead_generate_tests.py +15 -24
  68. data/ext/libmongocrypt/libmongocrypt/etc/fle2_crypto.py +66 -54
  69. data/ext/libmongocrypt/libmongocrypt/etc/fle2_generate_tests.py +14 -23
  70. data/ext/libmongocrypt/libmongocrypt/etc/fle2v2_aead_generate_tests.py +32 -0
  71. data/ext/libmongocrypt/libmongocrypt/etc/format-all.sh +12 -0
  72. data/ext/libmongocrypt/libmongocrypt/etc/format.sh +16 -0
  73. data/ext/libmongocrypt/libmongocrypt/etc/install-package.sh +48 -0
  74. data/ext/libmongocrypt/libmongocrypt/etc/mongo-inteldfp-libmongocrypt-pr-625.patch +13 -0
  75. data/ext/libmongocrypt/libmongocrypt/src/crypto/cng.c +381 -436
  76. data/ext/libmongocrypt/libmongocrypt/src/crypto/commoncrypto.c +162 -227
  77. data/ext/libmongocrypt/libmongocrypt/src/crypto/libcrypto.c +180 -248
  78. data/ext/libmongocrypt/libmongocrypt/src/crypto/none.c +33 -55
  79. data/ext/libmongocrypt/libmongocrypt/src/csfle-markup.cpp +175 -205
  80. data/ext/libmongocrypt/libmongocrypt/src/mc-array-private.h +10 -21
  81. data/ext/libmongocrypt/libmongocrypt/src/mc-array.c +44 -56
  82. data/ext/libmongocrypt/libmongocrypt/src/mc-check-conversions-private.h +4 -8
  83. data/ext/libmongocrypt/libmongocrypt/src/mc-dec128.h +351 -463
  84. data/ext/libmongocrypt/libmongocrypt/src/mc-dec128.test.cpp +59 -66
  85. data/ext/libmongocrypt/libmongocrypt/src/mc-efc-private.h +7 -11
  86. data/ext/libmongocrypt/libmongocrypt/src/mc-efc.c +80 -92
  87. data/ext/libmongocrypt/libmongocrypt/src/mc-fle-blob-subtype-private.h +18 -10
  88. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-encryption-placeholder-private.h +59 -70
  89. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-encryption-placeholder.c +384 -439
  90. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-equality-payload-private-v2.h +41 -0
  91. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-equality-payload-private.h +11 -18
  92. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-equality-payload-v2.c +135 -0
  93. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-equality-payload.c +109 -126
  94. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-range-payload-private-v2.h +88 -0
  95. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-range-payload-private.h +24 -27
  96. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-range-payload-v2.c +137 -0
  97. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-range-payload.c +106 -125
  98. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-insert-update-payload-private-v2.h +117 -0
  99. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-insert-update-payload-private.h +28 -36
  100. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-insert-update-payload-v2.c +294 -0
  101. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-insert-update-payload.c +237 -278
  102. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-iev-private-v2.h +133 -0
  103. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-iev-private.h +67 -56
  104. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-iev-v2.c +437 -0
  105. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-iev.c +476 -325
  106. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-uev-common-private.h +69 -0
  107. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-uev-common.c +182 -0
  108. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-uev-private.h +23 -31
  109. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-uev-v2-private.h +85 -0
  110. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-uev-v2.c +142 -0
  111. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-uev.c +104 -231
  112. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-range-operator-private.h +8 -7
  113. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-rfds-private.h +55 -56
  114. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-rfds.c +517 -580
  115. data/ext/libmongocrypt/libmongocrypt/src/mc-optional-private.h +36 -66
  116. data/ext/libmongocrypt/libmongocrypt/src/mc-range-edge-generation-private.h +57 -76
  117. data/ext/libmongocrypt/libmongocrypt/src/mc-range-edge-generation.c +158 -189
  118. data/ext/libmongocrypt/libmongocrypt/src/mc-range-encoding-private.h +36 -42
  119. data/ext/libmongocrypt/libmongocrypt/src/mc-range-encoding.c +515 -558
  120. data/ext/libmongocrypt/libmongocrypt/src/mc-range-mincover-generator.template.h +155 -191
  121. data/ext/libmongocrypt/libmongocrypt/src/mc-range-mincover-private.h +43 -53
  122. data/ext/libmongocrypt/libmongocrypt/src/mc-range-mincover.c +170 -240
  123. data/ext/libmongocrypt/libmongocrypt/src/mc-rangeopts-private.h +29 -34
  124. data/ext/libmongocrypt/libmongocrypt/src/mc-rangeopts.c +289 -338
  125. data/ext/libmongocrypt/libmongocrypt/src/mc-reader-private.h +36 -71
  126. data/ext/libmongocrypt/libmongocrypt/src/mc-reader.c +111 -164
  127. data/ext/libmongocrypt/libmongocrypt/src/mc-tokens-private.h +55 -49
  128. data/ext/libmongocrypt/libmongocrypt/src/mc-tokens.c +109 -125
  129. data/ext/libmongocrypt/libmongocrypt/src/mc-writer-private.h +66 -0
  130. data/ext/libmongocrypt/libmongocrypt/src/mc-writer.c +141 -0
  131. data/ext/libmongocrypt/libmongocrypt/src/mlib/check.hpp +37 -55
  132. data/ext/libmongocrypt/libmongocrypt/src/mlib/endian.h +11 -11
  133. data/ext/libmongocrypt/libmongocrypt/src/mlib/error.h +27 -32
  134. data/ext/libmongocrypt/libmongocrypt/src/mlib/int128.h +444 -499
  135. data/ext/libmongocrypt/libmongocrypt/src/mlib/int128.test.cpp +251 -334
  136. data/ext/libmongocrypt/libmongocrypt/src/mlib/macros.h +4 -5
  137. data/ext/libmongocrypt/libmongocrypt/src/mlib/path.h +196 -231
  138. data/ext/libmongocrypt/libmongocrypt/src/mlib/path.test.c +56 -79
  139. data/ext/libmongocrypt/libmongocrypt/src/mlib/str.h +411 -530
  140. data/ext/libmongocrypt/libmongocrypt/src/mlib/str.test.c +116 -131
  141. data/ext/libmongocrypt/libmongocrypt/src/mlib/thread.h +17 -26
  142. data/ext/libmongocrypt/libmongocrypt/src/mlib/user-check.h +2 -2
  143. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-binary-private.h +3 -6
  144. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-binary.c +31 -48
  145. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-buffer-private.h +55 -131
  146. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-buffer.c +444 -565
  147. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache-collinfo-private.h +1 -2
  148. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache-collinfo.c +28 -45
  149. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache-key-private.h +11 -17
  150. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache-key.c +103 -132
  151. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache-oauth-private.h +8 -14
  152. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache-oauth.c +78 -90
  153. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache-private.h +26 -45
  154. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache.c +220 -273
  155. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ciphertext-private.h +13 -25
  156. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ciphertext.c +147 -166
  157. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-compat.h +2 -2
  158. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-crypto-private.h +110 -204
  159. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-crypto.c +1137 -1565
  160. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx-datakey.c +425 -472
  161. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx-decrypt.c +817 -694
  162. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx-encrypt.c +2394 -2697
  163. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx-private.h +166 -186
  164. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx-rewrap-many-datakey.c +308 -351
  165. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx.c +921 -1138
  166. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-dll-private.h +16 -24
  167. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-endian-private.h +44 -58
  168. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-endpoint-private.h +21 -25
  169. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-endpoint.c +167 -181
  170. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-kek-private.h +37 -43
  171. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-kek.c +215 -253
  172. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-key-broker-private.h +73 -108
  173. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-key-broker.c +889 -1034
  174. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-key-private.h +27 -44
  175. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-key.c +349 -402
  176. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-kms-ctx-private.h +92 -120
  177. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-kms-ctx.c +1397 -1612
  178. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-log-private.h +35 -67
  179. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-log.c +49 -83
  180. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-marking-private.h +30 -36
  181. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-marking.c +1821 -1470
  182. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-mutex-private.h +7 -12
  183. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-opts-private.h +80 -108
  184. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-opts.c +354 -424
  185. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-private.h +101 -117
  186. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-status-private.h +3 -8
  187. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-status.c +92 -119
  188. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-traverse-util-private.h +19 -29
  189. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-traverse-util.c +136 -176
  190. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-util-private.h +11 -21
  191. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-util.c +96 -135
  192. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt.c +1092 -1320
  193. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt.h +130 -295
  194. data/ext/libmongocrypt/libmongocrypt/src/os_posix/os_dll.c +66 -78
  195. data/ext/libmongocrypt/libmongocrypt/src/os_posix/os_mutex.c +20 -28
  196. data/ext/libmongocrypt/libmongocrypt/src/os_win/os_dll.c +60 -73
  197. data/ext/libmongocrypt/libmongocrypt/src/os_win/os_mutex.c +8 -16
  198. data/ext/libmongocrypt/libmongocrypt/test/crypt_shared-stub.cpp +57 -87
  199. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-delete/empty/encrypted-payload-v2.json +60 -0
  200. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-delete/success/encrypted-payload-v2.json +67 -0
  201. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-explain/with-csfle/encrypted-payload.json +2 -2
  202. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-explicit/find-indexed-contentionFactor1-v2.json +8 -0
  203. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-explicit/find-indexed-v2.json +8 -0
  204. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-explicit/insert-indexed-contentionFactor1-v2.json +8 -0
  205. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-explicit/insert-indexed-same-user-and-index-key-v2.json +8 -0
  206. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-explicit/insert-indexed-v2.json +8 -0
  207. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-equality-v2/cmd.json +6 -0
  208. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-equality-v2/encrypted-field-map.json +22 -0
  209. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-equality-v2/encrypted-payload.json +40 -0
  210. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-equality-v2/mongocryptd-reply.json +19 -0
  211. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/date-v2/cmd.json +10 -0
  212. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/date-v2/encrypted-field-map.json +27 -0
  213. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/date-v2/encrypted-payload.json +41 -0
  214. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/date-v2/mongocryptd-reply.json +49 -0
  215. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128-precision-v2/cmd.json +6 -0
  216. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128-precision-v2/encrypted-field-map.json +30 -0
  217. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128-precision-v2/encrypted-payload.json +50 -0
  218. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128-precision-v2/mongocryptd-reply.json +58 -0
  219. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128-v2/cmd.json +6 -0
  220. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128-v2/encrypted-field-map.json +27 -0
  221. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128-v2/encrypted-payload.json +41 -0
  222. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128-v2/mongocryptd-reply.json +49 -0
  223. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double-precision-v2/cmd.json +8 -0
  224. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double-precision-v2/encrypted-field-map.json +30 -0
  225. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double-precision-v2/encrypted-payload.json +44 -0
  226. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double-precision-v2/mongocryptd-reply.json +52 -0
  227. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double-v2/cmd.json +8 -0
  228. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double-v2/encrypted-field-map.json +27 -0
  229. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double-v2/encrypted-payload.json +41 -0
  230. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double-v2/mongocryptd-reply.json +49 -0
  231. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int32-v2/cmd.json +8 -0
  232. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int32-v2/encrypted-field-map.json +27 -0
  233. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int32-v2/encrypted-payload.json +41 -0
  234. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int32-v2/mongocryptd-reply.json +49 -0
  235. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int64-v2/cmd.json +8 -0
  236. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int64-v2/encrypted-field-map.json +27 -0
  237. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int64-v2/encrypted-payload.json +41 -0
  238. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int64-v2/mongocryptd-reply.json +49 -0
  239. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/double/encrypted-payload-v2.json +26 -0
  240. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/double-precision/encrypted-payload-v2.json +26 -0
  241. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/int32/encrypted-payload-v2.json +26 -0
  242. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/int32-nominmax/encrypted-payload-v2.json +26 -0
  243. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/int32-openinterval/encrypted-payload-v2.json +16 -0
  244. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert/cmd.json +1 -1
  245. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/date/RNG_DATA.h +65 -65
  246. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/date-v2/cmd.json +13 -0
  247. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/date-v2/encrypted-field-map.json +27 -0
  248. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/date-v2/encrypted-payload.json +44 -0
  249. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/date-v2/mongocryptd-reply.json +52 -0
  250. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128/RNG_DATA.h +132 -132
  251. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-precision/RNG_DATA.h +71 -71
  252. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-precision-v2/cmd.json +9 -0
  253. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-precision-v2/encrypted-field-map.json +30 -0
  254. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-precision-v2/encrypted-payload.json +53 -0
  255. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-precision-v2/mongocryptd-reply.json +61 -0
  256. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-v2/cmd.json +9 -0
  257. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-v2/encrypted-field-map.json +27 -0
  258. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-v2/encrypted-payload.json +44 -0
  259. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-v2/mongocryptd-reply.json +52 -0
  260. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double/RNG_DATA.h +68 -68
  261. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-precision/RNG_DATA.h +19 -19
  262. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-precision-v2/cmd.json +11 -0
  263. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-precision-v2/encrypted-field-map.json +30 -0
  264. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-precision-v2/encrypted-payload.json +47 -0
  265. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-precision-v2/mongocryptd-reply.json +55 -0
  266. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-v2/cmd.json +11 -0
  267. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-v2/encrypted-field-map.json +27 -0
  268. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-v2/encrypted-payload.json +44 -0
  269. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-v2/mongocryptd-reply.json +52 -0
  270. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int32/RNG_DATA.h +25 -25
  271. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int32-v2/cmd.json +11 -0
  272. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int32-v2/encrypted-field-map.json +27 -0
  273. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int32-v2/encrypted-payload.json +44 -0
  274. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int32-v2/mongocryptd-reply.json +52 -0
  275. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int64/RNG_DATA.h +65 -65
  276. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int64-v2/cmd.json +11 -0
  277. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int64-v2/encrypted-field-map.json +27 -0
  278. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int64-v2/encrypted-payload.json +44 -0
  279. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int64-v2/mongocryptd-reply.json +52 -0
  280. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/double/RNG_DATA.h +68 -68
  281. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/double/encrypted-payload-v2.json +8 -0
  282. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/double-precision/RNG_DATA.h +19 -19
  283. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/double-precision/encrypted-payload-v2.json +8 -0
  284. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/int32/RNG_DATA.h +25 -25
  285. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/int32/encrypted-payload-v2.json +8 -0
  286. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/int32-nominmax/encrypted-payload-v2.json +8 -0
  287. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/sparsity-2/RNG_DATA.h +15 -15
  288. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/sparsity-2/encrypted-payload-v2.json +8 -0
  289. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-unindexed-v2/cmd.json +9 -0
  290. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-unindexed-v2/encrypted-field-map.json +18 -0
  291. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-unindexed-v2/encrypted-payload.json +14 -0
  292. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-unindexed-v2/mongocryptd-reply.json +41 -0
  293. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-v2/cmd.json +9 -0
  294. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-v2/encrypted-field-map.json +22 -0
  295. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-v2/encrypted-payload.json +39 -0
  296. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-v2/mongocryptd-reply.json +49 -0
  297. data/ext/libmongocrypt/libmongocrypt/test/data/iev-v2/FLECrudTest-insertOneRangeV2.json +10 -0
  298. data/ext/libmongocrypt/libmongocrypt/test/data/iev-v2/FLECrudTest-insertOneV2.json +10 -0
  299. data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/README.md +17 -0
  300. data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/aes-ctr.json +29 -0
  301. data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/fle2-fixed.json +10 -0
  302. data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/fle2-generated.json +38 -0
  303. data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/fle2aead-decrypt.json +35 -0
  304. data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/fle2aead-fixed.json +29 -0
  305. data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/fle2aead-generated.json +122 -0
  306. data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/fle2v2-aead-fixed.json +29 -0
  307. data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/fle2v2-aead-generated.json +122 -0
  308. data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/mcgrew.json +12 -0
  309. data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/nist.json +20 -0
  310. data/ext/libmongocrypt/libmongocrypt/test/data/tokens/README.md +27 -0
  311. data/ext/libmongocrypt/libmongocrypt/test/data/tokens/mc.json +21 -0
  312. data/ext/libmongocrypt/libmongocrypt/test/data/tokens/server.json +21 -0
  313. data/ext/libmongocrypt/libmongocrypt/test/example-no-bson.c +4 -4
  314. data/ext/libmongocrypt/libmongocrypt/test/example-state-machine.c +278 -323
  315. data/ext/libmongocrypt/libmongocrypt/test/fuzz_kms.c +8 -7
  316. data/ext/libmongocrypt/libmongocrypt/test/test-dll.cpp +6 -7
  317. data/ext/libmongocrypt/libmongocrypt/test/test-gcp-auth.c +221 -283
  318. data/ext/libmongocrypt/libmongocrypt/test/test-mc-efc.c +58 -73
  319. data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-find-equality-payload-v2.c +78 -0
  320. data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-find-range-payload-v2.c +89 -0
  321. data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-payload-iev-v2.c +248 -0
  322. data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-payload-iev.c +467 -414
  323. data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-payload-iup-v2.c +172 -0
  324. data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-payload-iup.c +141 -159
  325. data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-payload-uev-v2.c +338 -0
  326. data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-payload-uev.c +238 -176
  327. data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-rfds.c +373 -474
  328. data/ext/libmongocrypt/libmongocrypt/test/test-mc-range-edge-generation.c +346 -388
  329. data/ext/libmongocrypt/libmongocrypt/test/test-mc-range-encoding.c +708 -825
  330. data/ext/libmongocrypt/libmongocrypt/test/test-mc-range-mincover.c +417 -481
  331. data/ext/libmongocrypt/libmongocrypt/test/test-mc-rangeopts.c +110 -144
  332. data/ext/libmongocrypt/libmongocrypt/test/test-mc-reader.c +124 -207
  333. data/ext/libmongocrypt/libmongocrypt/test/test-mc-tokens.c +223 -213
  334. data/ext/libmongocrypt/libmongocrypt/test/test-mc-writer.c +176 -0
  335. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-assert-match-bson.c +634 -807
  336. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-assert-match-bson.h +1 -2
  337. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-assert.h +168 -189
  338. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-buffer.c +187 -211
  339. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-cache-oauth.c +34 -36
  340. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-cache.c +210 -233
  341. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-ciphertext.c +185 -220
  342. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-compact.c +331 -445
  343. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-crypto-hooks.c +670 -814
  344. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-crypto-std-hooks.c +102 -135
  345. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-crypto-std-hooks.h +54 -71
  346. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-crypto.c +394 -846
  347. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-csfle-lib.c +159 -183
  348. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-ctx-decrypt.c +867 -1045
  349. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-ctx-encrypt.c +4349 -4713
  350. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-ctx-rewrap-many-datakey.c +750 -964
  351. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-ctx-setopt.c +991 -1178
  352. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-datakey.c +342 -419
  353. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-dll.c +23 -30
  354. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-endpoint.c +98 -111
  355. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-kek.c +49 -52
  356. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-key-broker.c +770 -920
  357. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-key-cache.c +354 -407
  358. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-key.c +197 -245
  359. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-kms-ctx.c +286 -370
  360. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-kms-responses.c +147 -166
  361. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-local-kms.c +50 -61
  362. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-log.c +85 -100
  363. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-marking.c +656 -692
  364. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-status.c +46 -58
  365. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-traverse-util.c +377 -451
  366. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-util.c +48 -67
  367. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-util.h +4 -10
  368. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt.c +827 -918
  369. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt.h +111 -172
  370. data/ext/libmongocrypt/libmongocrypt/test/util/csfle.c +508 -559
  371. data/ext/libmongocrypt/libmongocrypt/test/util/util.c +735 -881
  372. data/ext/libmongocrypt/libmongocrypt/test/util/util.h +33 -55
  373. data/lib/libmongocrypt_helper/version.rb +2 -2
  374. data.tar.gz.sig +0 -0
  375. metadata +154 -26
  376. metadata.gz.sig +0 -0
  377. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/fle2-find-range-explicit/int32/encrypted-payload.json +0 -26
  378. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/fle2-find-range-explicit/int32/key-document.json +0 -0
  379. data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/credentialsProvider.js +0 -33
  380. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/credentialsProvider.test.js +0 -163
  381. data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/fle2-find-range-explicit/int32/encrypted-payload.json +0 -26
  382. data/ext/libmongocrypt/libmongocrypt/test/data/aes-ctr.cstructs +0 -359
  383. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-aead.cstructs +0 -109
  384. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/int32-nominmax/encrypted-payload.json +0 -26
  385. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/int32-nominmax/rangeopts.json +0 -5
  386. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/int32-nominmax/value-to-encrypt.json +0 -20
  387. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/int32-nominmax/RNG_DATA.h +0 -70
  388. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/int32-nominmax/encrypted-payload.json +0 -8
  389. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/int32-nominmax/rangeopts.json +0 -5
  390. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/int32-nominmax/value-to-encrypt.json +0 -5
  391. data/ext/libmongocrypt/libmongocrypt/test/data/fle2.cstructs +0 -33
  392. /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
  393. /data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/{fle2-find-range-explicit → fle2-find-range-explicit-v2}/int32/rangeopts.json +0 -0
  394. /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
  395. /data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/{fle2-find-range-explicit → fle2-find-range-explicit-v2}/int32/rangeopts.json +0 -0
  396. /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
- mc_getTypeInfo32_args_t args;
26
- mc_OSTType_Int32 expect;
27
- const char *expectError;
25
+ mc_getTypeInfo32_args_t args;
26
+ mc_OSTType_Int32 expect;
27
+ const char *expectError;
28
28
  } Int32Test;
29
29
 
30
- static void
31
- _test_RangeTest_Encode_Int32 (_mongocrypt_tester_t *tester)
32
- {
33
- Int32Test tests[] = {
34
- /* Test cases copied from server Int32_NoBounds test ... begin */
35
- {.args = {.value = INT32_C (2147483647)},
36
- .expect = {.value = UINT32_C (4294967295), .min = 0, .max = UINT32_MAX}},
37
- {.args = {.value = 1},
38
- .expect = {.value = UINT32_C (2147483649), .min = 0, .max = UINT32_MAX}},
39
- {.args = {.value = 0},
40
- .expect = {.value = UINT32_C (2147483648), .min = 0, .max = UINT32_MAX}},
41
- {.args = {.value = -1},
42
- .expect = {.value = UINT32_C (2147483647), .min = 0, .max = UINT32_MAX}},
43
- {.args = {.value = -2},
44
- .expect = {.value = UINT32_C (2147483646), .min = 0, .max = UINT32_MAX}},
45
- {.args = {.value = INT32_C (-2147483647)},
46
- .expect = {.value = 1, .min = 0, .max = UINT32_MAX}},
47
- {.args = {.value = INT32_MIN},
48
- .expect = {.value = 0, .min = 0, .max = UINT32_MAX}},
49
- /* Test cases copied from server Int32_NoBounds test ... end */
50
- /* Test cases copied from server Int32_Bounds test .. begin */
51
- {.args = {.value = 1, .min = OPT_I32 (1), .max = OPT_I32 (3)},
52
- .expect = {.value = 0, 0, .max = 2}},
53
- {.args = {.value = 0, .min = OPT_I32 (0), .max = OPT_I32 (1)},
54
- .expect = {.value = 0, .min = 0, .max = 1}},
55
- {.args = {.value = -1, .min = OPT_I32 (-1), .max = OPT_I32 (0)},
56
- .expect = {.value = 0, .min = 0, .max = 1}},
57
- {.args = {.value = -2, .min = OPT_I32 (-2), .max = OPT_I32 (0)},
58
- .expect = {.value = 0, .min = 0, .max = 2}},
59
- {.args = {.value = INT32_C (-2147483647),
60
- .min = OPT_I32 (INT32_MIN),
61
- .max = OPT_I32 (1)},
62
- .expect = {.value = 1, .min = 0, .max = UINT32_C (2147483649)}},
63
- {.args = {.value = INT32_MIN,
64
- .min = OPT_I32 (INT32_MIN),
65
- .max = OPT_I32 (0)},
66
- .expect = {.value = 0, .min = 0, .max = UINT32_C (2147483648)}},
67
- {.args = {.value = 0, .min = OPT_I32 (INT32_MIN), .max = OPT_I32 (1)},
68
- .expect = {.value = UINT32_C (2147483648),
69
- .min = 0,
70
- .max = UINT32_C (2147483649)}},
71
- {.args = {.value = 1, .min = OPT_I32 (INT32_MIN), .max = OPT_I32 (2)},
72
- .expect = {.value = UINT32_C (2147483649),
73
- .min = 0,
74
- .max = UINT32_C (2147483650)}},
75
- {.args = {.value = INT32_C (2147483647),
76
- .min = OPT_I32 (-2147483647),
77
- .max = OPT_I32 (2147483647)},
78
- .expect = {.value = UINT32_C (4294967294),
79
- .min = 0,
80
- .max = UINT32_C (4294967294)}},
81
- {.args = {.value = INT32_C (2147483647),
82
- .min = OPT_I32 (INT32_MIN),
83
- .max = OPT_I32 (2147483647)},
84
- .expect = {.value = UINT32_C (4294967295),
85
- .min = 0,
86
- .max = UINT32_C (4294967295)}},
87
- {.args = {.value = 15, .min = OPT_I32 (10), .max = OPT_I32 (26)},
88
- .expect = {.value = 5, .min = 0, .max = 16}},
89
- {.args = {.value = 15, .min = OPT_I32 (-10), .max = OPT_I32 (55)},
90
- .expect = {.value = 25, .min = 0, .max = 65}},
91
- /* Test cases copied from server Int32_Bounds test ... end */
92
- /* Test cases copied from server Int32_Errors test ... begin */
93
- {.args = {.value = 1, .max = OPT_I32 (2)},
94
- .expectError =
95
- "Must specify both a lower and upper bound or no bounds."},
96
- {.args = {.value = 1, .min = OPT_I32 (0)},
97
- .expectError =
98
- "Must specify both a lower and upper bound or no bounds."},
99
- {.args = {.value = 1, .min = OPT_I32 (2), .max = OPT_I32 (1)},
100
- .expectError = "The minimum value must be less than the maximum value"},
101
- {.args = {.value = 1, .min = OPT_I32 (2), .max = OPT_I32 (3)},
102
- .expectError = "Value must be greater than or equal to the minimum "
103
- "value and less than or equal to the maximum value"},
104
- {.args = {.value = 4, .min = OPT_I32 (2), .max = OPT_I32 (3)},
105
- .expectError = "Value must be greater than or equal to the minimum "
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
- mc_getTypeInfo64_args_t args;
144
- mc_OSTType_Int64 expect;
145
- const char *expectError;
109
+ mc_getTypeInfo64_args_t args;
110
+ mc_OSTType_Int64 expect;
111
+ const char *expectError;
146
112
  } Int64Test;
147
113
 
148
- static void
149
- _test_RangeTest_Encode_Int64 (_mongocrypt_tester_t *tester)
150
- {
151
- Int64Test tests[] = {
152
- /* Test cases copied from server Int64_NoBounds test ... begin */
153
- {.args = {.value = INT64_C (9223372036854775807)},
154
- .expect = {.value = UINT64_C (18446744073709551615),
155
- .min = 0,
156
- .max = UINT64_MAX}},
157
- {.args = {.value = 1},
158
- .expect = {.value = UINT64_C (9223372036854775809),
159
- .min = 0,
160
- .max = UINT64_MAX}},
161
- {.args = {.value = 0},
162
- .expect = {.value = UINT64_C (9223372036854775808),
163
- .min = 0,
164
- .max = UINT64_MAX}},
165
- {.args = {.value = -1},
166
- .expect = {.value = UINT64_C (9223372036854775807),
167
- .min = 0,
168
- .max = UINT64_MAX}},
169
- {.args = {.value = -2},
170
- .expect = {.value = UINT64_C (9223372036854775806),
171
- .min = 0,
172
- .max = UINT64_MAX}},
173
- {.args = {.value = INT64_C (-9223372036854775807)},
174
- .expect = {.value = 1, .min = 0, .max = UINT64_MAX}},
175
- {.args = {.value = INT64_MIN},
176
- .expect = {.value = 0, .min = 0, .max = UINT64_MAX}},
177
- /* Test cases copied from server Int64_NoBounds test ... end */
178
- /* Test cases copied from server Int64_Bounds test ... begin */
179
- {.args = {.value = 1, .min = OPT_I64 (1), .max = OPT_I64 (2)},
180
- .expect = {.value = 0, .min = 0, .max = 1}},
181
- {.args = {.value = 0, .min = OPT_I64 (0), .max = OPT_I64 (1)},
182
- .expect = {.value = 0, .min = 0, .max = 1}},
183
- {.args = {.value = -1, .min = OPT_I64 (-1), .max = OPT_I64 (0)},
184
- .expect = {.value = 0, .min = 0, .max = 1}},
185
- {.args = {.value = -2, .min = OPT_I64 (-2), .max = OPT_I64 (0)},
186
- .expect = {.value = 0, .min = 0, .max = 2}},
187
- {.args = {.value = INT64_C (-9223372036854775807),
188
- .min = OPT_I64 (INT64_MIN),
189
- .max = OPT_I64 (1)},
190
- .expect = {.value = 1, .min = 0, .max = UINT64_C (9223372036854775809)}},
191
- {.args = {.value = INT64_MIN,
192
- .min = OPT_I64 (INT64_MIN),
193
- .max = OPT_I64 (0)},
194
- .expect = {.value = 0, .min = 0, .max = UINT64_C (9223372036854775808)}},
195
- {.args = {.value = 0, .min = OPT_I64 (INT64_MIN), .max = OPT_I64 (37)},
196
- .expect = {.value = UINT64_C (9223372036854775808),
197
- .min = 0,
198
- .max = UINT64_C (9223372036854775845)}},
199
- {.args = {.value = 1, .min = OPT_I64 (INT64_MIN), .max = OPT_I64 (42)},
200
- .expect = {.value = UINT64_C (9223372036854775809),
201
- .min = 0,
202
- .max = UINT64_C (9223372036854775850)}},
203
- {.args = {.value = INT64_C (9223372036854775807),
204
- .min = OPT_I64 (-9223372036854775807),
205
- .max = OPT_I64 (9223372036854775807)},
206
- .expect = {.value = UINT64_C (18446744073709551614),
207
- .min = 0,
208
- .max = UINT64_C (18446744073709551614)}},
209
- {.args = {.value = INT64_C (9223372036854775807),
210
- .min = OPT_I64 (INT64_MIN),
211
- .max = OPT_I64 (9223372036854775807)},
212
- .expect = {.value = UINT64_C (18446744073709551615),
213
- .min = 0,
214
- .max = UINT64_C (18446744073709551615)}},
215
- {.args = {.value = 15, .min = OPT_I64 (10), .max = OPT_I64 (26)},
216
- .expect = {.value = 5, .min = 0, .max = 16}},
217
- {.args = {.value = 15, .min = OPT_I64 (-10), .max = OPT_I64 (55)},
218
- .expect = {.value = 25, .min = 0, .max = 65}},
219
- /* Test cases copied from server Int64_Bounds test ... end */
220
- /* Test cases copied from server Int64_Errors test ... begin */
221
- {.args = {.value = 1, .max = OPT_I64 (2)},
222
- .expectError =
223
- "Must specify both a lower and upper bound or no bounds."},
224
- {.args = {.value = 1, .min = OPT_I64 (0)},
225
- .expectError =
226
- "Must specify both a lower and upper bound or no bounds."},
227
- {.args = {.value = 1, .min = OPT_I64 (2), .max = OPT_I64 (1)},
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
- double value;
272
- mc_optional_double_t min;
273
- mc_optional_double_t max;
274
- mc_optional_uint32_t precision;
275
- uint64_t expect;
276
- mc_optional_uint64_t expectMax;
277
- const char *expectError;
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
- _test_RangeTest_Encode_Double (_mongocrypt_tester_t *tester)
282
- {
283
- DoubleTest tests[] = {
284
- /* Test cases copied from server Double_Bounds test ... begin */
285
- // Larger numbers map to larger uint64
286
- {.value = -1111, .expect = UINT64_C (4570770991734587392)},
287
- {.value = -111, .expect = UINT64_C (4585860689314185216)},
288
- {.value = -11, .expect = UINT64_C (4600989969312382976)},
289
- {.value = -10, .expect = UINT64_C (4601552919265804288)},
290
- {.value = -3, .expect = UINT64_C (4609434218613702656)},
291
- {.value = -2, .expect = UINT64_C (4611686018427387904)},
292
-
293
- {.value = -1, .expect = UINT64_C (4616189618054758400)},
294
- {.value = 1, .expect = UINT64_C (13830554455654793216)},
295
- {.value = 22, .expect = UINT64_C (13850257704024539136)},
296
- {.value = 333, .expect = UINT64_C (13867937850999177216)},
297
-
298
- // Larger exponents map to larger uint64
299
- {.value = 33E56, .expect = UINT64_C (14690973652625833878)},
300
- {.value = 22E57, .expect = UINT64_C (14703137697061005818)},
301
- {.value = 11E58, .expect = UINT64_C (14713688953586463292)},
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
- }
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
- mc_dec128 value;
531
- mc_optional_dec128_t min;
532
- mc_optional_dec128_t max;
533
- mc_optional_uint32_t precision;
534
- mlib_int128 expect;
535
- const char *expectError;
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
- _test_RangeTest_Encode_Decimal128 (_mongocrypt_tester_t *tester)
540
- {
541
- Decimal128Test tests[] = {
542
- #define CASE(Value, ExpectStr) \
543
- (Decimal128Test){.value = mc_dec128_from_string (#Value), \
544
- .expect = mlib_int128_from_string (ExpectStr, NULL)}
545
- /* Test cases copied from server Decimal128_Bounds test ... begin */
546
- // Larger numbers map to larger int128
547
- CASE (-1234567890E7, "108549948892579231731687303715884111887"),
548
- CASE (-1234567890E6, "108559948892579231731687303715884111886"),
549
- CASE (-1234567890E5, "108569948892579231731687303715884111885"),
550
- CASE (-1234567890E4, "108579948892579231731687303715884111884"),
551
- CASE (-1234567890E3, "108589948892579231731687303715884111883"),
552
- CASE (-1234567890E2, "108599948892579231731687303715884111882"),
553
- CASE (-1234567890E1, "108609948892579231731687303715884111881"),
554
- CASE (-123456789012345, "108569948892579108281687303715884111885"),
555
- CASE (-12345678901234, "108579948892579108331687303715884111884"),
556
- CASE (-1234567890123, "108589948892579108731687303715884111883"),
557
- CASE (-123456789012, "108599948892579111731687303715884111882"),
558
- CASE (-12345678901, "108609948892579131731687303715884111881"),
559
- CASE (-1234567890, "108619948892579231731687303715884111880"),
560
- CASE (-99999999, "108631183460569231731687303715884111878"),
561
- CASE (-8888888, "108642294572469231731687303715884111877"),
562
- CASE (-777777, "108653405690469231731687303715884111876"),
563
- CASE (-66666, "108664516860469231731687303715884111875"),
564
- CASE (-5555, "108675628460469231731687303715884111874"),
565
- CASE (-444, "108686743460469231731687303715884111873"),
566
- CASE (-334, "108687843460469231731687303715884111873"),
567
- CASE (-333, "108687853460469231731687303715884111873"),
568
- CASE (-44, "108696783460469231731687303715884111872"),
569
- CASE (-33, "108697883460469231731687303715884111872"),
570
- CASE (-22, "108698983460469231731687303715884111872"),
571
- CASE (-5, "108706183460469231731687303715884111871"),
572
- CASE (-4, "108707183460469231731687303715884111871"),
573
- CASE (-3, "108708183460469231731687303715884111871"),
574
- CASE (-2, "108709183460469231731687303715884111871"),
575
- CASE (-1, "108710183460469231731687303715884111871"),
576
- CASE (0, "170141183460469231731687303715884105728"),
577
- CASE (1, "231572183460469231731687303715884099585"),
578
- CASE (2, "231573183460469231731687303715884099585"),
579
- CASE (3, "231574183460469231731687303715884099585"),
580
- CASE (4, "231575183460469231731687303715884099585"),
581
- CASE (5, "231576183460469231731687303715884099585"),
582
- CASE (22, "231583383460469231731687303715884099584"),
583
- CASE (33, "231584483460469231731687303715884099584"),
584
- CASE (44, "231585583460469231731687303715884099584"),
585
- CASE (333, "231594513460469231731687303715884099583"),
586
- CASE (334, "231594523460469231731687303715884099583"),
587
- CASE (444, "231595623460469231731687303715884099583"),
588
- CASE (5555, "231606738460469231731687303715884099582"),
589
- CASE (66666, "231617850060469231731687303715884099581"),
590
- CASE (777777, "231628961230469231731687303715884099580"),
591
- CASE (8888888, "231640072348469231731687303715884099579"),
592
- CASE (33E56, "232144483460469231731687303715884099528"),
593
- CASE (22E57, "232153383460469231731687303715884099527"),
594
- CASE (11E58, "232162283460469231731687303715884099526"),
595
-
596
- // Smaller exponents map to smaller int128
597
- CASE (1E-6, "231512183460469231731687303715884099591"),
598
- CASE (1E-7, "231502183460469231731687303715884099592"),
599
- CASE (1E-8, "231492183460469231731687303715884099593"),
600
- CASE (1E-56, "231012183460469231731687303715884099641"),
601
- CASE (1E-57, "231002183460469231731687303715884099642"),
602
- CASE (1E-58, "230992183460469231731687303715884099643"),
603
-
604
- // Smaller negative exponents map to smaller int128
605
- CASE (-1E-6, "108770183460469231731687303715884111865"),
606
- CASE (-1E-7, "108780183460469231731687303715884111864"),
607
- CASE (-1E-8, "108790183460469231731687303715884111863"),
608
- CASE (-1E-56, "109270183460469231731687303715884111815"),
609
- CASE (-1E-57, "109280183460469231731687303715884111814"),
610
- CASE (-1E-58, "109290183460469231731687303715884111813"),
611
-
612
- // Larger exponents map to larger int128
613
- CASE (-33E56, "108137883460469231731687303715884111928"),
614
- CASE (-22E57, "108128983460469231731687303715884111929"),
615
- CASE (-11E58, "108120083460469231731687303715884111930"),
616
-
617
- (Decimal128Test){.value = MC_DEC128_LARGEST_POSITIVE,
618
- .expect = mlib_int128_from_string (
619
- "293021183460469231731687303715884093440", NULL)},
620
- (Decimal128Test){.value = MC_DEC128_SMALLEST_POSITIVE,
621
- .expect = mlib_int128_from_string (
622
- "170141183460469231731687303715884105729", NULL)},
623
- (Decimal128Test){.value = MC_DEC128_LARGEST_NEGATIVE,
624
- .expect = mlib_int128_from_string (
625
- "47261183460469231731687303715884118016", NULL)},
626
- (Decimal128Test){.value = MC_DEC128_SMALLEST_NEGATIVE,
627
- .expect = mlib_int128_from_string (
628
- "170141183460469231731687303715884105727", NULL)},
629
- (Decimal128Test){.value = MC_DEC128_NORMALIZED_ZERO,
630
- .expect = mlib_int128_from_string (
631
- "170141183460469231731687303715884105728", NULL)},
632
- (Decimal128Test){.value = MC_DEC128_NEGATIVE_EXPONENT_ZERO,
633
- .expect = mlib_int128_from_string (
634
- "170141183460469231731687303715884105728", NULL)},
635
- /* Test cases copied from server Decimal128_Bounds test ... end */
636
-
637
- #define ERROR_CASE(Value, Min, Max, Precision, ErrorString) \
638
- (Decimal128Test){ \
639
- .value = Value, \
640
- .min = Min, \
641
- .max = Max, \
642
- .precision = Precision, \
643
- .expectError = ErrorString, \
644
- }
645
-
646
- ERROR_CASE (
647
- MC_DEC128_C (1),
648
- OPT_NULLOPT,
649
- OPT_MC_DEC128 (MC_DEC128_C (2)),
650
- OPT_U32 (5),
651
- "min, max, and precision must all be set or must all be unset"),
652
- ERROR_CASE (
653
- MC_DEC128_C (1),
654
- OPT_MC_DEC128 (MC_DEC128_C (0)),
655
- OPT_NULLOPT,
656
- OPT_U32 (5),
657
- "min, max, and precision must all be set or must all be unset"),
658
- ERROR_CASE (MC_DEC128_C (1),
659
- OPT_MC_DEC128 (MC_DEC128_C (2)),
660
- OPT_MC_DEC128 (MC_DEC128_C (1)),
661
- OPT_U32 (5),
662
- "The minimum value must be less than the maximum value"),
663
-
664
- ERROR_CASE (MC_DEC128_C (1),
665
- OPT_MC_DEC128 (MC_DEC128_C (2)),
666
- OPT_MC_DEC128 (MC_DEC128_C (3)),
667
- OPT_U32 (5),
668
- "Value must be greater than or equal to the minimum value "
669
- "and less than or equal to the maximum value"),
670
- ERROR_CASE (MC_DEC128_C (4),
671
- OPT_MC_DEC128 (MC_DEC128_C (2)),
672
- OPT_MC_DEC128 (MC_DEC128_C (3)),
673
- OPT_U32 (5),
674
- "Value must be greater than or equal to the minimum value "
675
- "and less than or equal to the maximum value"),
676
-
677
- ERROR_CASE (MC_DEC128_POSITIVE_INFINITY,
678
- OPT_NULLOPT,
679
- OPT_NULLOPT,
680
- OPT_NULLOPT,
681
- "Infinity and Nan Decimal128 values are not supported."),
682
- ERROR_CASE (MC_DEC128_NEGATIVE_INFINITY,
683
- OPT_NULLOPT,
684
- OPT_NULLOPT,
685
- OPT_NULLOPT,
686
- "Infinity and Nan Decimal128 values are not supported."),
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
- (Decimal128Test){ \
703
- .value = mc_dec128_from_string (Value), \
704
- .min = OPT_MC_DEC128 (MC_DEC128_C (-100000)), \
705
- .max = OPT_MC_DEC128 (MC_DEC128_C (100000)), \
706
- .precision = OPT_U32 (Precision), \
707
- .expect = MLIB_INT128 (Expect), \
708
- }
709
- ASSERT_EIBP ("3.141592653589E-1", 10, 1000003141592653),
710
- ASSERT_EIBP ("31.41592653589E-2", 10, 1000003141592653),
711
- ASSERT_EIBP ("314.1592653589E-3", 10, 1000003141592653),
712
- ASSERT_EIBP ("3141.592653589E-4", 10, 1000003141592653),
713
- ASSERT_EIBP ("31415.92653589E-5", 10, 1000003141592653),
714
- ASSERT_EIBP ("314159.2653589E-6", 10, 1000003141592653),
715
- ASSERT_EIBP ("3141592.653589E-7", 10, 1000003141592653),
716
- ASSERT_EIBP ("31415926.53589E-8", 10, 1000003141592653),
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
- (Decimal128Test){ \
721
- .value = mc_dec128_from_string (Value), \
722
- .min = OPT_MC_DEC128 (MC_DEC128_C (-100000)), \
723
- .max = OPT_MC_DEC128 (mc_dec128_from_string ("1E22")), \
724
- .precision = OPT_U32 (Precision), \
725
- .expect = mlib_int128_from_string (Expect, NULL), \
726
- }
727
-
728
- ASSERT_EIBPL ("3.1415926535897932384626433832795E20",
729
- 5,
730
- "31415926535897942384626433"),
731
- ASSERT_EIBPL ("3.1415926535897932384626433832795E20",
732
- 6,
733
- "314159265358979423846264338"),
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
- (Decimal128Test){ \
746
- .value = mc_dec128_from_string (#Value), \
747
- .min = OPT_MC_DEC128 (MC_DEC128_C (-100000)), \
748
- .max = OPT_MC_DEC128 (MC_DEC128_C (100000)), \
749
- .precision = OPT_U32 (Precision), \
750
- .expect = MLIB_INT128_CAST (Expect), \
751
- }
752
- ASSERT_EIBP (3.141592653589, 1, 1000031),
753
- ASSERT_EIBP (3.141592653589, 2, 10000314),
754
- ASSERT_EIBP (3.141592653589, 3, 100003141),
755
- ASSERT_EIBP (3.141592653589, 4, 1000031415),
756
- ASSERT_EIBP (3.141592653589, 5, 10000314159),
757
- ASSERT_EIBP (3.141592653589, 6, 100003141592),
758
- ASSERT_EIBP (3.141592653589, 7, 1000031415926),
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
- (Decimal128Test){ \
763
- .value = mc_dec128_from_string (#Val), \
764
- .min = OPT_MC_DEC128 (mc_dec128_from_string (#Min)), \
765
- .max = OPT_MC_DEC128 (mc_dec128_from_string (#Max)), \
766
- .precision = OPT_U32 (Precision), \
767
- .expect = MLIB_INT128_CAST (Expect), \
768
- }
769
-
770
- #define ASSERT_EIBB_OVERFLOW(Val, Max, Min, Precision, Expect) \
771
- (Decimal128Test) \
772
- { \
773
- .value = mc_dec128_from_string (#Val), \
774
- .min = OPT_MC_DEC128 (mc_dec128_from_string (#Min)), \
775
- .max = OPT_MC_DEC128 (mc_dec128_from_string (#Max)), \
776
- .precision = OPT_U32 (Precision), .expect = Expect, \
777
- }
778
-
779
- ASSERT_EIBB (0, 1, -1, 3, 1000),
780
- ASSERT_EIBB (0, 1, -1E5, 3, 100000000),
781
-
782
- ASSERT_EIBB (-1E-33, 1, -1E5, 3, 100000000),
783
-
784
- ASSERT_EIBB_OVERFLOW (
785
- 0,
786
- MC_DEC128_LARGEST_POSITIVE,
787
- MC_DEC128_LARGEST_NEGATIVE,
788
- 3,
789
- mlib_int128_from_string ("170141183460469231731687303715884105728",
790
- NULL)),
791
- ASSERT_EIBB_OVERFLOW (
792
- 0,
793
- DBL_MAX,
794
- DBL_MIN,
795
- 3,
796
- mlib_int128_from_string ("170141183460469231731687303715884105728",
797
- NULL)),
798
-
799
- ASSERT_EIBB (3.141592653589, 5, 0, 0, 3),
800
- ASSERT_EIBB (3.141592653589, 5, 0, 1, 31),
801
-
802
- ASSERT_EIBB (3.141592653589, 5, 0, 2, 314),
803
-
804
- ASSERT_EIBB (3.141592653589, 5, 0, 3, 3141),
805
- ASSERT_EIBB (3.141592653589, 5, 0, 16, 31415926535890000),
806
-
807
- ASSERT_EIBB (-5, -1, -10, 3, 5000),
808
-
809
- ASSERT_EIBB_OVERFLOW (
810
- 1E100,
811
- DBL_MAX,
812
- DBL_MIN,
813
- 3,
814
- mlib_int128_from_string ("232572183460469231731687303715884099485",
815
- NULL)),
816
-
817
- ASSERT_EIBB (1E9, 1E10, 0, 3, 1000000000000),
818
- ASSERT_EIBB (1E9, 1E10, 0, 0, 1000000000),
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
- /* Test cases copied from Decimal128_Bounds_Precision ... end */
836
- };
837
-
838
- for (size_t i = 0; i < sizeof (tests) / sizeof (tests[0]); i++) {
839
- Decimal128Test *test = tests + i;
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
- }
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
- _mongocrypt_tester_install_range_encoding (_mongocrypt_tester_t *tester)
879
- {
880
- INSTALL_TEST (_test_RangeTest_Encode_Int32);
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
- INSTALL_TEST (_test_RangeTest_Encode_Decimal128);
767
+ INSTALL_TEST(_test_RangeTest_Encode_Decimal128);
885
768
  #endif
886
769
  }