PYTHON-1297 Implement Extended JSON Spec 2.0

Add JSONOptions.json_mode to control encoding Relaxed and Canonical
Extended JSON.
Add json_util.LEGACY_JSON_OPTIONS to encode PyMongo 3.4's default JSON output.
Deprecate json_util.STRICT_JSON_OPTIONS.
Move Decimal128 spec tests to bson_corpus runner.
This commit is contained in:
Shane Harvey 2017-07-07 16:33:45 -07:00
parent 473e25b2f6
commit 054a01aaff
38 changed files with 3940 additions and 3564 deletions

View File

@ -14,14 +14,15 @@
"""Tools for using Python's :mod:`json` module with BSON documents.
This module provides two helper methods `dumps` and `loads` that wrap the native
:mod:`json` methods and provide explicit BSON conversion to and from
JSON. :class:`~bson.json_util.JSONOptions` provides a way to control how JSON is
emitted and parsed, with the default being the legacy PyMongo format.
:mod:`~bson.json_util` can also generate and parse `canonical extended JSON`_ when
:data:`~bson.json_util.CANONICAL_JSON_OPTIONS` is provided.
This module provides two helper methods `dumps` and `loads` that wrap the
native :mod:`json` methods and provide explicit BSON conversion to and from
JSON. :class:`~bson.json_util.JSONOptions` provides a way to control how JSON
is emitted and parsed, with the default being the legacy PyMongo format.
:mod:`~bson.json_util` can also generate Canonical or Relaxed `Extended JSON`_
when :const:`CANONICAL_JSON_OPTIONS` or :const:`RELAXED_JSON_OPTIONS` is
provided, respectively.
.. _canonical extended JSON: https://github.com/mongodb/specifications/blob/master/source/extended-json.rst
.. _Extended JSON: https://github.com/mongodb/specifications/blob/master/source/extended-json.rst
Example usage (serialization):
@ -40,8 +41,8 @@ Example usage (deserialization):
.. doctest::
>>> from bson.json_util import loads
>>> loads('[{"foo": [1, 2]}, {"bar": {"hello": "world"}}, {"code": {"$scope": {}, "$code": "function x() { return 1; }"}}, {"bin": {"$type": "00", "$binary": "AQIDBA=="}}]')
[{u'foo': [1, 2]}, {u'bar': {u'hello': u'world'}}, {u'code': Code('function x() { return 1; }', {})}, {u'bin': Binary('...', 0)}]
>>> loads('[{"foo": [1, 2]}, {"bar": {"hello": "world"}}, {"code": {"$scope": {}, "$code": "function x() { return 1; }"}}, {"bin": {"$type": "80", "$binary": "AQIDBA=="}}]')
[{u'foo': [1, 2]}, {u'bar': {u'hello': u'world'}}, {u'code': Code('function x() { return 1; }', {})}, {u'bin': Binary('...', 128)}]
Example usage (with a :class:`~bson.json_util.JSONOptions` given):
@ -54,7 +55,7 @@ Example usage (with a :class:`~bson.json_util.JSONOptions` given):
... {'code': Code("function x() { return 1; }")},
... {'bin': Binary(b"\x01\x02\x03\x04")}],
... json_options=CANONICAL_JSON_OPTIONS)
'[{"foo": [{"$numberInt": "1"}, {"$numberInt": "2"}]}, {"bar": {"hello": "world"}}, {"code": {"$code": "function x() { return 1; }"}}, {"bin": {"$binary": "AQIDBA==", "$type": "00"}}]'
'[{"foo": [{"$numberInt": "1"}, {"$numberInt": "2"}]}, {"bar": {"hello": "world"}}, {"code": {"$code": "function x() { return 1; }"}}, {"bin": {"$binary": {"base64": "AQIDBA==", "subType": "00"}}}]'
Alternatively, you can manually pass the `default` to :func:`json.dumps`.
It won't handle :class:`~bson.binary.Binary` and :class:`~bson.code.Code`
@ -92,7 +93,6 @@ but it will be faster as there is less recursion.
"""
import base64
import collections
import datetime
import math
import re
@ -114,7 +114,7 @@ else:
from pymongo.errors import ConfigurationError
import bson
from bson import EPOCH_AWARE, RE_TYPE, SON
from bson import EPOCH_AWARE, EPOCH_NAIVE, RE_TYPE, SON
from bson.binary import (Binary, JAVA_LEGACY, CSHARP_LEGACY, OLD_UUID_SUBTYPE,
UUID_SUBTYPE)
from bson.code import Code
@ -125,7 +125,8 @@ from bson.int64 import Int64
from bson.max_key import MaxKey
from bson.min_key import MinKey
from bson.objectid import ObjectId
from bson.py3compat import PY3, iteritems, integer_types, string_type, text_type
from bson.py3compat import (PY3, iteritems, integer_types, string_type,
text_type)
from bson.regex import Regex
from bson.timestamp import Timestamp
from bson.tz_util import utc
@ -180,6 +181,30 @@ class DatetimeRepresentation:
"""
class JSONMode:
LEGACY = 0
"""Legacy Extended JSON representation.
.. versionadded:: 3.5
"""
RELAXED = 1
"""Relaxed Extended JSON representation.
.. seealso:: The specification for Relaxed `Extended JSON`_.
.. versionadded:: 3.5
"""
CANONICAL = 2
"""Canonical Extended JSON representation.
.. seealso:: The specification for Canonical `Extended JSON`_.
.. versionadded:: 3.5
"""
class JSONOptions(CodecOptions):
"""Encapsulates JSON options for :func:`dumps` and :func:`loads`.
@ -198,11 +223,8 @@ class JSONOptions(CodecOptions):
- `strict_uuid`: If ``True``, :class:`uuid.UUID` object are encoded to
MongoDB Extended JSON's *Strict mode* type `Binary`. Otherwise it
will be encoded as ``'{"$uuid": "<hex>" }'``. Defaults to ``False``.
- `canonical_extended_json`: If ``True``, use Canonical Extended JSON
representations for all BSON values. This option implies
``strict_number_long=True``,
``datetime_representation=DatetimeRepresentation.NUMBERLONG``, and
``strict_uuid=True``.
- `json_mode`: The JSON representation to use for encoding and
decoding Extended JSON`. Defaults to :const:`~JSONMode.LEGACY`.
- `document_class`: BSON documents returned by :func:`loads` will be
decoded to an instance of this class. Must be a subclass of
:class:`collections.MutableMapping`. Defaults to :class:`dict`.
@ -219,19 +241,21 @@ class JSONOptions(CodecOptions):
- `args`: arguments to :class:`~bson.codec_options.CodecOptions`
- `kwargs`: arguments to :class:`~bson.codec_options.CodecOptions`
.. seealso:: The `Extended JSON`_ specification.
.. seealso:: The documentation for `MongoDB Extended JSON
<http://www.mongodb.org/display/DOCS/Mongo+Extended+JSON>`_.
.. versionadded:: 3.4
.. versionchanged:: 3.5
Accepts the optional parameter `canonical_extended_json`.
Accepts the optional parameter `json_mode`.
"""
def __new__(cls, strict_number_long=False,
datetime_representation=DatetimeRepresentation.LEGACY,
strict_uuid=False, canonical_extended_json=False,
strict_uuid=False, json_mode=JSONMode.LEGACY,
*args, **kwargs):
kwargs["tz_aware"] = kwargs.get("tz_aware", True)
if kwargs["tz_aware"]:
@ -240,7 +264,7 @@ class JSONOptions(CodecOptions):
DatetimeRepresentation.NUMBERLONG,
DatetimeRepresentation.ISO8601):
raise ConfigurationError(
"JSONOptions.datetime_representation must be one of LEGACY,"
"JSONOptions.datetime_representation must be one of LEGACY, "
"NUMBERLONG, or ISO8601 from DatetimeRepresentation.")
self = super(JSONOptions, cls).__new__(cls, *args, **kwargs)
if not _HAS_OBJECT_PAIRS_HOOK and self.document_class != dict:
@ -248,8 +272,18 @@ class JSONOptions(CodecOptions):
"Support for JSONOptions.document_class on Python 2.6 "
"requires simplejson "
"(https://pypi.python.org/pypi/simplejson) to be installed.")
self.canonical_extended_json = canonical_extended_json
if self.canonical_extended_json:
if json_mode not in (JSONMode.LEGACY,
JSONMode.RELAXED,
JSONMode.CANONICAL):
raise ConfigurationError(
"JSONOptions.json_mode must be one of LEGACY, RELAXED, "
"or CANONICAL from JSONMode.")
self.json_mode = json_mode
if self.json_mode == JSONMode.RELAXED:
self.strict_number_long = False
self.datetime_representation = DatetimeRepresentation.ISO8601
self.strict_uuid = True
elif self.json_mode == JSONMode.CANONICAL:
self.strict_number_long = True
self.datetime_representation = DatetimeRepresentation.NUMBERLONG
self.strict_uuid = True
@ -262,33 +296,53 @@ class JSONOptions(CodecOptions):
def _arguments_repr(self):
return ('strict_number_long=%r, '
'datetime_representation=%r, '
'strict_uuid=%r, canonical_extended_json=%r, %s' % (
'strict_uuid=%r, json_mode=%r, %s' % (
self.strict_number_long,
self.datetime_representation,
self.strict_uuid,
self.canonical_extended_json,
self.json_mode,
super(JSONOptions, self)._arguments_repr()))
DEFAULT_JSON_OPTIONS = JSONOptions()
LEGACY_JSON_OPTIONS = JSONOptions(json_mode=JSONMode.LEGACY)
""":class:`JSONOptions` for encoding to PyMongo's legacy JSON format.
.. versionadded:: 3.5
"""
DEFAULT_JSON_OPTIONS = LEGACY_JSON_OPTIONS
"""The default :class:`JSONOptions` for JSON encoding/decoding.
The same as :const:`LEGACY_JSON_OPTIONS`. This will change to
:const:`RELAXED_JSON_OPTIONS` in a future release.
.. versionadded:: 3.4
"""
CANONICAL_JSON_OPTIONS = JSONOptions(json_mode=JSONMode.CANONICAL)
""":class:`JSONOptions` for Canonical `Extended JSON`_.
.. versionadded:: 3.5
"""
RELAXED_JSON_OPTIONS = JSONOptions(json_mode=JSONMode.RELAXED)
""":class:`JSONOptions` for Relaxed `Extended JSON`_.
.. versionadded:: 3.5
"""
STRICT_JSON_OPTIONS = JSONOptions(
strict_number_long=True,
datetime_representation=DatetimeRepresentation.ISO8601,
strict_uuid=True)
""":class:`JSONOptions` for MongoDB Extended JSON's *Strict mode* encoding.
"""DEPRECATED :class:`JSONOptions` for MongoDB Extended JSON's *Strict mode*
encoding.
.. versionadded:: 3.4
"""
CANONICAL_JSON_OPTIONS = JSONOptions(canonical_extended_json=True)
""":class:`JSONOptions` for `canonical extended JSON`_.
.. versionadded:: 3.5
.. versionchanged:: 3.5
Deprecated. Use :const:`RELAXED_JSON_OPTIONS` or
:const:`CANONICAL_JSON_OPTIONS` instead.
"""
@ -332,10 +386,7 @@ def loads(s, *args, **kwargs):
kwargs["object_pairs_hook"] = lambda pairs: object_pairs_hook(
pairs, json_options)
else:
kwargs["object_hook"] = lambda obj: (
canonical_object_hook(obj, json_options)
if json_options.canonical_extended_json
else object_hook(obj, json_options))
kwargs["object_hook"] = lambda obj: object_hook(obj, json_options)
return json.loads(s, *args, **kwargs)
@ -355,54 +406,73 @@ def _json_convert(obj, json_options=DEFAULT_JSON_OPTIONS):
def object_pairs_hook(pairs, json_options=DEFAULT_JSON_OPTIONS):
document = json_options.document_class(pairs)
if json_options.canonical_extended_json:
return canonical_object_hook(document, json_options)
return object_hook(document, json_options)
return object_hook(json_options.document_class(pairs), json_options)
def object_hook(dct, json_options=DEFAULT_JSON_OPTIONS):
if "$oid" in dct:
return ObjectId(str(dct["$oid"]))
return _parse_canonical_oid(dct)
if "$ref" in dct:
return DBRef(dct["$ref"], dct["$id"], dct.get("$db", None))
return _parse_canonical_dbref(dct)
if "$date" in dct:
return _get_date(dct, json_options)
return _parse_canonical_datetime(dct, json_options)
if "$regex" in dct:
flags = 0
# PyMongo always adds $options but some other tools may not.
for opt in dct.get("$options", ""):
flags |= _RE_OPT_TABLE.get(opt, 0)
return Regex(dct["$regex"], flags)
return _parse_legacy_regex(dct)
if "$minKey" in dct:
return MinKey()
return _parse_canonical_minkey(dct)
if "$maxKey" in dct:
return MaxKey()
return _parse_canonical_maxkey(dct)
if "$binary" in dct:
return _get_binary(dct, json_options)
if "$type" in dct:
return _parse_legacy_binary(dct, json_options)
else:
return _parse_canonical_binary(dct, json_options)
if "$code" in dct:
return Code(dct["$code"], dct.get("$scope"))
return _parse_canonical_code(dct)
if "$uuid" in dct:
return uuid.UUID(dct["$uuid"])
return _parse_legacy_uuid(dct)
if "$undefined" in dct:
return None
if "$numberLong" in dct:
return Int64(dct["$numberLong"])
return _parse_canonical_int64(dct)
if "$timestamp" in dct:
tsp = dct["$timestamp"]
return Timestamp(tsp["t"], tsp["i"])
if "$numberDecimal" in dct:
return Decimal128(dct["$numberDecimal"])
return _parse_canonical_decimal128(dct)
if "$dbPointer" in dct:
return _parse_canonical_dbpointer(dct)
if "$regularExpression" in dct:
return _parse_canonical_regex(dct)
if "$symbol" in dct:
return _parse_canonical_symbol(dct)
if "$numberInt" in dct:
return _parse_canonical_int32(dct)
if "$numberDouble" in dct:
return _parse_canonical_double(dct)
return dct
def _get_binary(doc, json_options):
if isinstance(doc["$type"], int):
doc["$type"] = "%02x" % doc["$type"]
subtype = int(doc["$type"], 16)
if subtype >= 0xffffff80: # Handle mongoexport values
subtype = int(doc["$type"][6:], 16)
data = base64.b64decode(doc["$binary"].encode())
def _parse_legacy_regex(doc):
pattern = doc["$regex"]
# Check if this is the $regex query operator.
if isinstance(pattern, Regex):
return doc
flags = 0
# PyMongo always adds $options but some other tools may not.
for opt in doc.get("$options", ""):
flags |= _RE_OPT_TABLE.get(opt, 0)
return Regex(pattern, flags)
def _parse_legacy_uuid(doc):
"""Decode a JSON legacy $uuid to Python UUID."""
if len(doc) != 1:
raise TypeError('Bad $uuid, extra field(s): %s' % (doc,))
return uuid.UUID(doc["$uuid"])
def _binary_or_uuid(data, subtype, json_options):
# special handling for UUID
if subtype == OLD_UUID_SUBTYPE:
if json_options.uuid_representation == CSHARP_LEGACY:
@ -417,8 +487,38 @@ def _get_binary(doc, json_options):
return Binary(data, subtype)
def _get_date(doc, json_options):
def _parse_legacy_binary(doc, json_options):
if isinstance(doc["$type"], int):
doc["$type"] = "%02x" % doc["$type"]
subtype = int(doc["$type"], 16)
if subtype >= 0xffffff80: # Handle mongoexport values
subtype = int(doc["$type"][6:], 16)
data = base64.b64decode(doc["$binary"].encode())
return _binary_or_uuid(data, subtype, json_options)
def _parse_canonical_binary(doc, json_options):
binary = doc["$binary"]
b64 = binary["base64"]
subtype = binary["subType"]
if not isinstance(b64, string_type):
raise TypeError('$binary base64 must be a string: %s' % (doc,))
if not isinstance(subtype, string_type) or len(subtype) > 2:
raise TypeError('$binary subType must be a string at most 2 '
'characters: %s' % (doc,))
if len(binary) != 2:
raise TypeError('$binary must include only "base64" and "subType" '
'components: %s' % (doc,))
data = base64.b64decode(b64.encode())
return _binary_or_uuid(data, int(subtype, 16), json_options)
def _parse_canonical_datetime(doc, json_options):
"""Decode a JSON datetime to python datetime.datetime."""
dtm = doc["$date"]
if len(doc) != 1:
raise TypeError('Bad $date, extra field(s): %s' % (doc,))
# mongoexport 2.6 and newer
if isinstance(dtm, string_type):
# Parse offset
@ -441,8 +541,16 @@ def _get_date(doc, json_options):
dt = dtm
offset = ''
# Parse the optional factional seconds portion.
dot_index = dt.rfind('.')
microsecond = 0
if dot_index != -1:
microsecond = int(float(dt[dot_index:]) * 1000000)
dt = dt[:dot_index]
aware = datetime.datetime.strptime(
dt, "%Y-%m-%dT%H:%M:%S.%f").replace(tzinfo=utc)
dt, "%Y-%m-%dT%H:%M:%S").replace(microsecond=microsecond,
tzinfo=utc)
if offset and offset != 'Z':
if len(offset) == 6:
@ -462,68 +570,139 @@ def _get_date(doc, json_options):
return aware
else:
return aware.replace(tzinfo=None)
# mongoexport 2.6 and newer, time before the epoch (SERVER-15275)
elif isinstance(dtm, collections.Mapping):
millis = int(dtm["$numberLong"])
# mongoexport before 2.6
else:
millis = int(dtm)
return bson._millis_to_datetime(millis, json_options)
return bson._millis_to_datetime(int(dtm), json_options)
def _get_dbpointer(doc, json_options):
dbref = doc['$dbPointer']
if isinstance(dbref, DBRef):
# DBPointer must not contain $db in its value.
if dbref.database is None:
return dbref
# Otherwise, this is just a regular document.
return json_options.document_class(
[('$dbPointer', json_options.document_class(dbref.as_doc()))])
return doc
def _parse_canonical_oid(doc):
"""Decode a JSON ObjectId to bson.objectid.ObjectId."""
if len(doc) != 1:
raise TypeError('Bad $oid, extra field(s): %s' % (doc,))
return ObjectId(doc['$oid'])
_CANONICAL_JSON_TABLE = {
frozenset(['$oid']): lambda d, _: ObjectId(d['$oid']),
frozenset(['$numberDecimal']): lambda d, _: Decimal128(d['$numberDecimal']),
frozenset(['$symbol']): lambda d, _: text_type(d['$symbol']),
frozenset(['$numberInt']): lambda d, _: int(d['$numberInt']),
frozenset(['$numberDouble']): lambda d, _: float(d['$numberDouble']),
frozenset(['$numberLong']): lambda d, _: Int64(d['$numberLong']),
frozenset(['$date']): _get_date,
frozenset(['$minKey']): lambda dummy0, dummy1: MinKey(),
frozenset(['$maxKey']): lambda dummy0, dummy1: MaxKey(),
frozenset(['$undefined']): lambda dummy0, dummy1: None,
frozenset(['$dbPointer']): _get_dbpointer,
frozenset(['$ref', '$id']): lambda d, _: DBRef(
d.pop('$ref'), d.pop('$id'), **d),
frozenset(['$ref', '$id', '$db']): lambda d, _: DBRef(
d.pop('$ref'), d.pop('$id'), d.pop('$db'), **d),
frozenset(['$regex', '$options']): lambda d, _: Regex(
d['$regex'], d['$options']),
frozenset(['$binary', '$type']): _get_binary,
frozenset(['$code']): lambda d, _: Code(d['$code']),
frozenset(['$code', '$scope']): lambda d, _: Code(
d['$code'], d['$scope']),
frozenset(['$timestamp']): lambda d, _: Timestamp(
int(d['$timestamp']) >> 32, int(d['$timestamp']) & 0xffffffff)
}
def _parse_canonical_symbol(doc):
"""Decode a JSON symbol to Python string."""
symbol = doc['$symbol']
if len(doc) != 1:
raise TypeError('Bad $symbol, extra field(s): %s' % (doc,))
return text_type(symbol)
def canonical_object_hook(dct, json_options=CANONICAL_JSON_OPTIONS):
keyset = frozenset(key for key in dct if key.startswith('$'))
converter = _CANONICAL_JSON_TABLE.get(keyset)
if converter:
return converter(dct, json_options)
elif '$ref' in dct and '$id' in dct:
# DBRef may contain other keys that don't start with $.
if keyset - _DBREF_KEYS:
def _parse_canonical_code(doc):
"""Decode a JSON code to bson.code.Code."""
for key in doc:
if key not in ('$code', '$scope'):
raise TypeError('Bad $code, extra field(s): %s' % (doc,))
return Code(doc['$code'], scope=doc.get('$scope'))
def _parse_canonical_regex(doc):
"""Decode a JSON regex to bson.regex.Regex."""
regex = doc['$regularExpression']
if len(doc) != 1:
raise TypeError('Bad $regularExpression, extra field(s): %s' % (doc,))
if len(regex) != 2:
raise TypeError('Bad $regularExpression must include only "pattern"'
'and "options" components: %s' % (doc,))
return Regex(regex['pattern'], regex['options'])
def _parse_canonical_dbref(doc):
"""Decode a JSON DBRef to bson.dbref.DBRef."""
for key in doc:
if key.startswith('$') and key not in _DBREF_KEYS:
# Other keys start with $, so dct cannot be parsed as a DBRef.
return dct
else:
return DBRef(dct.pop('$ref'), dct.pop('$id'),
dct.pop('$db', None), **dct)
return dct
return doc
return DBRef(doc.pop('$ref'), doc.pop('$id'),
database=doc.pop('$db', None), **doc)
def _parse_canonical_dbpointer(doc):
"""Decode a JSON (deprecated) DBPointer to bson.dbref.DBRef."""
dbref = doc['$dbPointer']
if len(doc) != 1:
raise TypeError('Bad $dbPointer, extra field(s): %s' % (doc,))
if isinstance(dbref, DBRef):
dbref_doc = dbref.as_doc()
# DBPointer must not contain $db in its value.
if dbref.database is not None:
raise TypeError(
'Bad $dbPointer, extra field $db: %s' % (dbref_doc,))
if not isinstance(dbref.id, ObjectId):
raise TypeError(
'Bad $dbPointer, $id must be an ObjectId: %s' % (dbref_doc,))
if len(dbref_doc) != 2:
raise TypeError(
'Bad $dbPointer, extra field(s) in DBRef: %s' % (dbref_doc,))
return dbref
else:
raise TypeError('Bad $dbPointer, expected a DBRef: %s' % (doc,))
def _parse_canonical_int32(doc):
"""Decode a JSON int32 to python int."""
i_str = doc['$numberInt']
if len(doc) != 1:
raise TypeError('Bad $numberInt, extra field(s): %s' % (doc,))
if not isinstance(i_str, string_type):
raise TypeError('$numberInt must be string: %s' % (doc,))
return int(i_str)
def _parse_canonical_int64(doc):
"""Decode a JSON int64 to bson.int64.Int64."""
l_str = doc['$numberLong']
if len(doc) != 1:
raise TypeError('Bad $numberLong, extra field(s): %s' % (doc,))
return Int64(l_str)
def _parse_canonical_double(doc):
"""Decode a JSON double to python float."""
d_str = doc['$numberDouble']
if len(doc) != 1:
raise TypeError('Bad $numberDouble, extra field(s): %s' % (doc,))
if not isinstance(d_str, string_type):
raise TypeError('$numberDouble must be string: %s' % (doc,))
return float(d_str)
def _parse_canonical_decimal128(doc):
"""Decode a JSON decimal128 to bson.decimal128.Decimal128."""
d_str = doc['$numberDecimal']
if len(doc) != 1:
raise TypeError('Bad $numberDecimal, extra field(s): %s' % (doc,))
if not isinstance(d_str, string_type):
raise TypeError('$numberDecimal must be string: %s' % (doc,))
return Decimal128(d_str)
def _parse_canonical_minkey(doc):
"""Decode a JSON MinKey to bson.min_key.MinKey."""
if doc['$minKey'] is not 1:
raise TypeError('$minKey value must be 1: %s' % (doc,))
if len(doc) != 1:
raise TypeError('Bad $minKey, extra field(s): %s' % (doc,))
return MinKey()
def _parse_canonical_maxkey(doc):
"""Decode a JSON MaxKey to bson.max_key.MaxKey."""
if doc['$maxKey'] is not 1:
raise TypeError('$maxKey value must be 1: %s', (doc,))
if len(doc) != 1:
raise TypeError('Bad $minKey, extra field(s): %s' % (doc,))
return MaxKey()
def _encode_binary(data, subtype, json_options):
if json_options.json_mode == JSONMode.LEGACY:
return SON([
('$binary', base64.b64encode(data).decode()),
('$type', "%02x" % subtype)])
return {'$binary': SON([
('base64', base64.b64encode(data).decode()),
('subType', "%02x" % subtype)])}
def default(obj, json_options=DEFAULT_JSON_OPTIONS):
@ -544,10 +723,10 @@ def default(obj, json_options=DEFAULT_JSON_OPTIONS):
tz_string = 'Z'
else:
tz_string = obj.strftime('%z')
return {"$date": "%s.%03d%s" % (
obj.strftime("%Y-%m-%dT%H:%M:%S"),
int(obj.microsecond / 1000),
tz_string)}
millis = int(obj.microsecond / 1000)
fracsecs = ".%03d" % (millis,) if millis else ""
return {"$date": "%s%s%s" % (
obj.strftime("%Y-%m-%dT%H:%M:%S"), fracsecs, tz_string)}
millis = bson._datetime_to_millis(obj)
if (json_options.datetime_representation ==
@ -574,29 +753,26 @@ def default(obj, json_options=DEFAULT_JSON_OPTIONS):
pattern = obj.pattern
else:
pattern = obj.pattern.decode('utf-8')
return SON([("$regex", pattern), ("$options", flags)])
if json_options.json_mode == JSONMode.LEGACY:
return SON([("$regex", pattern), ("$options", flags)])
return {'$regularExpression': SON([("pattern", pattern),
("options", flags)])}
if isinstance(obj, MinKey):
return {"$minKey": 1}
if isinstance(obj, MaxKey):
return {"$maxKey": 1}
if isinstance(obj, Timestamp):
if json_options.canonical_extended_json:
return {'$timestamp': str((obj.time << 32) + obj.inc)}
return {"$timestamp": SON([("t", obj.time), ("i", obj.inc)])}
if isinstance(obj, Code):
if obj.scope is None:
return SON([('$code', str(obj))])
return {'$code': str(obj)}
return SON([
('$code', str(obj)),
('$scope', _json_convert(obj.scope, json_options))])
if isinstance(obj, Binary):
return SON([
('$binary', base64.b64encode(obj).decode()),
('$type', "%02x" % obj.subtype)])
return _encode_binary(obj, obj.subtype, json_options)
if PY3 and isinstance(obj, bytes):
return SON([
('$binary', base64.b64encode(obj).decode()),
('$type', "00")])
return _encode_binary(obj, 0, json_options)
if isinstance(obj, uuid.UUID):
if json_options.strict_uuid:
data = obj.bytes
@ -607,28 +783,27 @@ def default(obj, json_options=DEFAULT_JSON_OPTIONS):
data = data[7::-1] + data[:7:-1]
elif json_options.uuid_representation == UUID_SUBTYPE:
subtype = UUID_SUBTYPE
return SON([
('$binary', base64.b64encode(data).decode()),
('$type', "%02x" % subtype)])
return _encode_binary(data, subtype, json_options)
else:
return {"$uuid": obj.hex}
if isinstance(obj, Decimal128):
return {"$numberDecimal": str(obj)}
if isinstance(obj, bool):
return obj
if json_options.canonical_extended_json and isinstance(obj, integer_types):
if (json_options.json_mode == JSONMode.CANONICAL and
isinstance(obj, integer_types)):
if -2 ** 31 <= obj < 2 ** 31:
return {'$numberInt': text_type(obj)}
return {'$numberLong': text_type(obj)}
if json_options.canonical_extended_json and isinstance(obj, float):
if json_options.json_mode != JSONMode.LEGACY and isinstance(obj, float):
if math.isnan(obj):
representation = 'NaN'
return {'$numberDouble': 'NaN'}
elif math.isinf(obj):
representation = 'Infinity' if obj > 0 else '-Infinity'
else:
return {'$numberDouble': representation}
elif json_options.json_mode == JSONMode.CANONICAL:
# repr() will return the shortest string guaranteed to produce the
# original value, when float() is called on it. str produces a
# shorter string in Python 2.
representation = text_type(repr(obj))
return {'$numberDouble': representation}
return {'$numberDouble': text_type(repr(obj))}
raise TypeError("%r is not JSON serializable" % obj)

View File

@ -37,6 +37,9 @@ Changes and Deprecations:
and disabling it is not recommended, see `does TCP keepalive time affect
MongoDB Deployments?
<https://docs.mongodb.com/manual/faq/diagnostics/#does-tcp-keepalive-time-affect-mongodb-deployments>`_
- Deprecated :const:`~bson.json_util.STRICT_JSON_OPTIONS`. Use
:const:`~bson.json_util.RELAXED_JSON_OPTIONS` or
:const:`~bson.json_util.CANONICAL_JSON_OPTIONS` instead.
- If a custom :class:`~bson.codec_options.CodecOptions` is passed to
:class:`RawBSONDocument`, its `document_class` must be
:class:`RawBSONDocument`.

View File

@ -5,25 +5,25 @@
"valid": [
{
"description": "Empty",
"bson": "0D000000046100050000000000",
"extjson": "{\"a\" : []}"
"canonical_bson": "0D000000046100050000000000",
"canonical_extjson": "{\"a\" : []}"
},
{
"description": "Single Element Array",
"bson": "140000000461000C0000001030000A0000000000",
"extjson": "{\"a\" : [{\"$numberInt\": \"10\"}]}"
"canonical_bson": "140000000461000C0000001030000A0000000000",
"canonical_extjson": "{\"a\" : [{\"$numberInt\": \"10\"}]}"
},
{
"description": "Single Element Array with index set incorrectly",
"bson": "130000000461000B00000010000A0000000000",
"degenerate_bson": "130000000461000B00000010000A0000000000",
"canonical_bson": "140000000461000C0000001030000A0000000000",
"extjson": "{\"a\" : [{\"$numberInt\": \"10\"}]}"
"canonical_extjson": "{\"a\" : [{\"$numberInt\": \"10\"}]}"
},
{
"description": "Single Element Array with index set incorrectly",
"bson": "150000000461000D000000106162000A0000000000",
"degenerate_bson": "150000000461000D000000106162000A0000000000",
"canonical_bson": "140000000461000C0000001030000A0000000000",
"extjson": "{\"a\" : [{\"$numberInt\": \"10\"}]}"
"canonical_extjson": "{\"a\" : [{\"$numberInt\": \"10\"}]}"
}
],
"decodeErrors": [

View File

@ -5,43 +5,59 @@
"valid": [
{
"description": "subtype 0x00 (Zero-length)",
"bson": "0D000000057800000000000000",
"extjson": "{\"x\" : {\"$binary\" : \"\", \"$type\" : \"00\"}}"
"canonical_bson": "0D000000057800000000000000",
"canonical_extjson": "{\"x\" : { \"$binary\" : {\"base64\" : \"\", \"subType\" : \"00\"}}}"
},
{
"description": "subtype 0x00 (Zero-length, keys reversed)",
"canonical_bson": "0D000000057800000000000000",
"canonical_extjson": "{\"x\" : { \"$binary\" : {\"base64\" : \"\", \"subType\" : \"00\"}}}",
"degenerate_extjson": "{\"x\" : { \"$binary\" : {\"subType\" : \"00\", \"base64\" : \"\"}}}"
},
{
"description": "subtype 0x00",
"bson": "0F0000000578000200000000FFFF00",
"extjson": "{\"x\" : {\"$binary\" : \"//8=\", \"$type\" : \"00\"}}"
"canonical_bson": "0F0000000578000200000000FFFF00",
"canonical_extjson": "{\"x\" : { \"$binary\" : {\"base64\" : \"//8=\", \"subType\" : \"00\"}}}"
},
{
"description": "subtype 0x01",
"bson": "0F0000000578000200000001FFFF00",
"extjson": "{\"x\" : {\"$binary\" : \"//8=\", \"$type\" : \"01\"}}"
"canonical_bson": "0F0000000578000200000001FFFF00",
"canonical_extjson": "{\"x\" : { \"$binary\" : {\"base64\" : \"//8=\", \"subType\" : \"01\"}}}"
},
{
"description": "subtype 0x02",
"bson": "13000000057800060000000202000000ffff00",
"extjson": "{\"x\" : {\"$binary\" : \"//8=\", \"$type\" : \"02\"}}"
"canonical_bson": "13000000057800060000000202000000FFFF00",
"canonical_extjson": "{\"x\" : { \"$binary\" : {\"base64\" : \"//8=\", \"subType\" : \"02\"}}}"
},
{
"description": "subtype 0x03",
"bson": "1D000000057800100000000373FFD26444B34C6990E8E7D1DFC035D400",
"extjson": "{\"x\" : {\"$binary\" : \"c//SZESzTGmQ6OfR38A11A==\", \"$type\" : \"03\"}}"
"canonical_bson": "1D000000057800100000000373FFD26444B34C6990E8E7D1DFC035D400",
"canonical_extjson": "{\"x\" : { \"$binary\" : {\"base64\" : \"c//SZESzTGmQ6OfR38A11A==\", \"subType\" : \"03\"}}}"
},
{
"description": "subtype 0x04",
"bson": "1D000000057800100000000473FFD26444B34C6990E8E7D1DFC035D400",
"extjson": "{\"x\" : {\"$binary\" : \"c//SZESzTGmQ6OfR38A11A==\", \"$type\" : \"04\"}}"
"canonical_bson": "1D000000057800100000000473FFD26444B34C6990E8E7D1DFC035D400",
"canonical_extjson": "{\"x\" : { \"$binary\" : {\"base64\" : \"c//SZESzTGmQ6OfR38A11A==\", \"subType\" : \"04\"}}}"
},
{
"description": "subtype 0x05",
"bson": "1D000000057800100000000573FFD26444B34C6990E8E7D1DFC035D400",
"extjson": "{\"x\" : {\"$binary\" : \"c//SZESzTGmQ6OfR38A11A==\", \"$type\" : \"05\"}}"
"canonical_bson": "1D000000057800100000000573FFD26444B34C6990E8E7D1DFC035D400",
"canonical_extjson": "{\"x\" : { \"$binary\" : {\"base64\" : \"c//SZESzTGmQ6OfR38A11A==\", \"subType\" : \"05\"}}}"
},
{
"description": "subtype 0x80",
"bson": "0F0000000578000200000080FFFF00",
"extjson": "{\"x\" : {\"$binary\" : \"//8=\", \"$type\" : \"80\"}}"
"canonical_bson": "0F0000000578000200000080FFFF00",
"canonical_extjson": "{\"x\" : { \"$binary\" : {\"base64\" : \"//8=\", \"subType\" : \"80\"}}}"
},
{
"description": "$type query operator (conflicts with legacy $binary form with $type field)",
"canonical_bson": "1F000000037800170000000224747970650007000000737472696E67000000",
"canonical_extjson": "{\"x\" : { \"$type\" : \"string\"}}"
},
{
"description": "$type query operator (conflicts with legacy $binary form with $type field)",
"canonical_bson": "180000000378001000000010247479706500020000000000",
"canonical_extjson": "{\"x\" : { \"$type\" : {\"$numberInt\": \"2\"}}}"
}
],
"decodeErrors": [

View File

@ -5,13 +5,13 @@
"valid": [
{
"description": "True",
"bson": "090000000862000100",
"extjson": "{\"b\" : true}"
"canonical_bson": "090000000862000100",
"canonical_extjson": "{\"b\" : true}"
},
{
"description": "False",
"bson": "090000000862000000",
"extjson": "{\"b\" : false}"
"canonical_bson": "090000000862000000",
"canonical_extjson": "{\"b\" : false}"
}
],
"decodeErrors": [

View File

@ -5,33 +5,33 @@
"valid": [
{
"description": "Empty string",
"bson": "0D0000000D6100010000000000",
"extjson": "{\"a\" : {\"$code\" : \"\"}}"
"canonical_bson": "0D0000000D6100010000000000",
"canonical_extjson": "{\"a\" : {\"$code\" : \"\"}}"
},
{
"description": "Single character",
"bson": "0E0000000D610002000000620000",
"extjson": "{\"a\" : {\"$code\" : \"b\"}}"
"canonical_bson": "0E0000000D610002000000620000",
"canonical_extjson": "{\"a\" : {\"$code\" : \"b\"}}"
},
{
"description": "Multi-character",
"bson": "190000000D61000D0000006162616261626162616261620000",
"extjson": "{\"a\" : {\"$code\" : \"abababababab\"}}"
"canonical_bson": "190000000D61000D0000006162616261626162616261620000",
"canonical_extjson": "{\"a\" : {\"$code\" : \"abababababab\"}}"
},
{
"description": "two-byte UTF-8 (\u00e9)",
"bson": "190000000261000D000000C3A9C3A9C3A9C3A9C3A9C3A90000",
"extjson": "{\"a\" : \"\\u00e9\\u00e9\\u00e9\\u00e9\\u00e9\\u00e9\"}"
"canonical_bson": "190000000261000D000000C3A9C3A9C3A9C3A9C3A9C3A90000",
"canonical_extjson": "{\"a\" : \"\\u00e9\\u00e9\\u00e9\\u00e9\\u00e9\\u00e9\"}"
},
{
"description": "three-byte UTF-8 (\u2606)",
"bson": "190000000261000D000000E29886E29886E29886E298860000",
"extjson": "{\"a\" : \"\\u2606\\u2606\\u2606\\u2606\"}"
"canonical_bson": "190000000261000D000000E29886E29886E29886E298860000",
"canonical_extjson": "{\"a\" : \"\\u2606\\u2606\\u2606\\u2606\"}"
},
{
"description": "Embedded nulls",
"bson": "190000000261000D0000006162006261620062616261620000",
"extjson": "{\"a\" : \"ab\\u0000bab\\u0000babab\"}"
"canonical_bson": "190000000261000D0000006162006261620062616261620000",
"canonical_extjson": "{\"a\" : \"ab\\u0000bab\\u0000babab\"}"
}
],
"decodeErrors": [

View File

@ -5,28 +5,28 @@
"valid": [
{
"description": "Empty code string, empty scope",
"bson": "160000000F61000E0000000100000000050000000000",
"extjson": "{\"a\" : {\"$code\" : \"\", \"$scope\" : {}}}"
"canonical_bson": "160000000F61000E0000000100000000050000000000",
"canonical_extjson": "{\"a\" : {\"$code\" : \"\", \"$scope\" : {}}}"
},
{
"description": "Non-empty code string, empty scope",
"bson": "1A0000000F610012000000050000006162636400050000000000",
"extjson": "{\"a\" : {\"$code\" : \"abcd\", \"$scope\" : {}}}"
"canonical_bson": "1A0000000F610012000000050000006162636400050000000000",
"canonical_extjson": "{\"a\" : {\"$code\" : \"abcd\", \"$scope\" : {}}}"
},
{
"description": "Empty code string, non-empty scope",
"bson": "1D0000000F61001500000001000000000C000000107800010000000000",
"extjson": "{\"a\" : {\"$code\" : \"\", \"$scope\" : {\"x\" : {\"$numberInt\": \"1\"}}}}"
"canonical_bson": "1D0000000F61001500000001000000000C000000107800010000000000",
"canonical_extjson": "{\"a\" : {\"$code\" : \"\", \"$scope\" : {\"x\" : {\"$numberInt\": \"1\"}}}}"
},
{
"description": "Non-empty code string and non-empty scope",
"bson": "210000000F6100190000000500000061626364000C000000107800010000000000",
"extjson": "{\"a\" : {\"$code\" : \"abcd\", \"$scope\" : {\"x\" : {\"$numberInt\": \"1\"}}}}"
"canonical_bson": "210000000F6100190000000500000061626364000C000000107800010000000000",
"canonical_extjson": "{\"a\" : {\"$code\" : \"abcd\", \"$scope\" : {\"x\" : {\"$numberInt\": \"1\"}}}}"
},
{
"description": "Unicode and embedded null in code string, empty scope",
"bson": "1A0000000F61001200000005000000C3A9006400050000000000",
"extjson": "{\"a\" : {\"$code\" : \"\\u00e9\\u0000d\", \"$scope\" : {}}}"
"canonical_bson": "1A0000000F61001200000005000000C3A9006400050000000000",
"canonical_extjson": "{\"a\" : {\"$code\" : \"\\u00e9\\u0000d\", \"$scope\" : {}}}"
}
],
"decodeErrors": [

View File

@ -5,21 +5,26 @@
"valid": [
{
"description": "epoch",
"bson": "10000000096100000000000000000000",
"extjson": "{\"a\" : {\"$date\" : \"1970-01-01T00:00:00.000Z\"}}",
"canonical_bson": "10000000096100000000000000000000",
"relaxed_extjson": "{\"a\" : {\"$date\" : \"1970-01-01T00:00:00Z\"}}",
"canonical_extjson": "{\"a\" : {\"$date\" : {\"$numberLong\" : \"0\"}}}"
},
{
"description": "positive ms",
"bson": "10000000096100C4D8D6CC3B01000000",
"extjson": "{\"a\" : {\"$date\" : \"2012-12-24T12:15:30.500Z\"}}",
"canonical_extjson": "{\"a\" : {\"$date\" : {\"$numberLong\" : \"1356351330500\"}}}"
"canonical_bson": "10000000096100C5D8D6CC3B01000000",
"relaxed_extjson": "{\"a\" : {\"$date\" : \"2012-12-24T12:15:30.501Z\"}}",
"canonical_extjson": "{\"a\" : {\"$date\" : {\"$numberLong\" : \"1356351330501\"}}}"
},
{
"description": "negative",
"bson": "10000000096100C43CE7B9BDFFFFFF00",
"extjson": "{\"a\" : {\"$date\" : \"1960-12-24T12:15:30.500Z\"}}",
"canonical_extjson": "{\"a\" : {\"$date\" : {\"$numberLong\" : \"-284643869500\"}}}"
"canonical_bson": "10000000096100C33CE7B9BDFFFFFF00",
"relaxed_extjson": "{\"a\" : {\"$date\" : {\"$numberLong\" : \"-284643869501\"}}}",
"canonical_extjson": "{\"a\" : {\"$date\" : {\"$numberLong\" : \"-284643869501\"}}}"
},
{
"description" : "Y10K",
"canonical_bson" : "1000000009610000DC1FD277E6000000",
"canonical_extjson" : "{\"a\":{\"$date\":{\"$numberLong\":\"253402300800000\"}}}"
}
],
"decodeErrors": [

View File

@ -6,25 +6,25 @@
"valid": [
{
"description": "DBpointer",
"bson": "1A0000000C610002000000620056E1FC72E0C917E9C471416100",
"extjson": "{\"a\": {\"$dbPointer\": {\"$ref\": \"b\", \"$id\": {\"$oid\": \"56e1fc72e0c917e9c4714161\"}}}}"
"canonical_bson": "1A0000000C610002000000620056E1FC72E0C917E9C471416100",
"canonical_extjson": "{\"a\": {\"$dbPointer\": {\"$ref\": \"b\", \"$id\": {\"$oid\": \"56e1fc72e0c917e9c4714161\"}}}}",
"converted_bson": "2a00000003610022000000022472656600020000006200072469640056e1fc72e0c917e9c47141610000",
"converted_extjson": "{\"a\": {\"$ref\": \"b\", \"$id\": {\"$oid\": \"56e1fc72e0c917e9c4714161\"}}}"
},
{
"description": "DBpointer with opposite key order",
"bson": "1A0000000C610002000000620056E1FC72E0C917E9C471416100",
"extjson": "{\"a\": {\"$dbPointer\": {\"$id\": {\"$oid\": \"56e1fc72e0c917e9c4714161\"}, \"$ref\": \"b\"}}}",
"canonical_extjson": "{\"a\": {\"$dbPointer\": {\"$ref\": \"b\", \"$id\": {\"$oid\": \"56e1fc72e0c917e9c4714161\"}}}}"
},
{
"description": "DBpointer with extra keys",
"bson": "1A0000000C610002000000620056E1FC72E0C917E9C471416100",
"extjson": "{\"a\": {\"$dbPointer\": {\"a\": 1, \"$id\": {\"$oid\": \"56e1fc72e0c917e9c4714161\"}, \"c\": 1, \"$ref\": \"b\", \"c\": 1}}}",
"canonical_extjson": "{\"a\": {\"$dbPointer\": {\"$ref\": \"b\", \"$id\": {\"$oid\": \"56e1fc72e0c917e9c4714161\"}}}}"
"canonical_bson": "1A0000000C610002000000620056E1FC72E0C917E9C471416100",
"canonical_extjson": "{\"a\": {\"$dbPointer\": {\"$ref\": \"b\", \"$id\": {\"$oid\": \"56e1fc72e0c917e9c4714161\"}}}}",
"degenerate_extjson": "{\"a\": {\"$dbPointer\": {\"$id\": {\"$oid\": \"56e1fc72e0c917e9c4714161\"}, \"$ref\": \"b\"}}}",
"converted_bson": "2a00000003610022000000022472656600020000006200072469640056e1fc72e0c917e9c47141610000",
"converted_extjson": "{\"a\": {\"$ref\": \"b\", \"$id\": {\"$oid\": \"56e1fc72e0c917e9c4714161\"}}}"
},
{
"description": "With two-byte UTF-8",
"bson": "1B0000000C610003000000C3A90056E1FC72E0C917E9C471416100",
"extjson": "{\"a\": {\"$dbPointer\": {\"$ref\": \"é\", \"$id\": {\"$oid\": \"56e1fc72e0c917e9c4714161\"}}}}"
"canonical_bson": "1B0000000C610003000000C3A90056E1FC72E0C917E9C471416100",
"canonical_extjson": "{\"a\": {\"$dbPointer\": {\"$ref\": \"é\", \"$id\": {\"$oid\": \"56e1fc72e0c917e9c4714161\"}}}}",
"converted_bson": "2B0000000361002300000002247265660003000000C3A900072469640056E1FC72E0C917E9C47141610000",
"converted_extjson": "{\"a\": {\"$ref\": \"é\", \"$id\": {\"$oid\": \"56e1fc72e0c917e9c4714161\"}}}"
}
],
"decodeErrors": [

View File

@ -4,28 +4,28 @@
"valid": [
{
"description": "DBRef",
"bson": "37000000036462726566002b0000000224726566000b000000636f6c6c656374696f6e00072469640058921b3e6e32ab156a22b59e0000",
"extjson": "{\"dbref\": {\"$ref\": \"collection\", \"$id\": {\"$oid\": \"58921b3e6e32ab156a22b59e\"}}}"
"canonical_bson": "37000000036462726566002b0000000224726566000b000000636f6c6c656374696f6e00072469640058921b3e6e32ab156a22b59e0000",
"canonical_extjson": "{\"dbref\": {\"$ref\": \"collection\", \"$id\": {\"$oid\": \"58921b3e6e32ab156a22b59e\"}}}"
},
{
"description": "DBRef with database",
"bson": "4300000003646272656600370000000224726566000b000000636f6c6c656374696f6e00072469640058921b3e6e32ab156a22b59e0224646200030000006462000000",
"extjson": "{\"dbref\": {\"$ref\": \"collection\", \"$id\": {\"$oid\": \"58921b3e6e32ab156a22b59e\"}, \"$db\": \"db\"}}"
"canonical_bson": "4300000003646272656600370000000224726566000b000000636f6c6c656374696f6e00072469640058921b3e6e32ab156a22b59e0224646200030000006462000000",
"canonical_extjson": "{\"dbref\": {\"$ref\": \"collection\", \"$id\": {\"$oid\": \"58921b3e6e32ab156a22b59e\"}, \"$db\": \"db\"}}"
},
{
"description": "DBRef with database and additional fields",
"bson": "48000000036462726566003c0000000224726566000b000000636f6c6c656374696f6e0010246964002a00000002246462000300000064620002666f6f0004000000626172000000",
"extjson": "{\"dbref\": {\"$ref\": \"collection\", \"$id\": {\"$numberInt\": \"42\"}, \"$db\": \"db\", \"foo\": \"bar\"}}"
"canonical_bson": "48000000036462726566003c0000000224726566000b000000636f6c6c656374696f6e0010246964002a00000002246462000300000064620002666f6f0004000000626172000000",
"canonical_extjson": "{\"dbref\": {\"$ref\": \"collection\", \"$id\": {\"$numberInt\": \"42\"}, \"$db\": \"db\", \"foo\": \"bar\"}}"
},
{
"description": "DBRef with additional fields",
"bson": "4400000003646272656600380000000224726566000b000000636f6c6c656374696f6e00072469640058921b3e6e32ab156a22b59e02666f6f0004000000626172000000",
"extjson": "{\"dbref\": {\"$ref\": \"collection\", \"$id\": {\"$oid\": \"58921b3e6e32ab156a22b59e\"}, \"foo\": \"bar\"}}"
"canonical_bson": "4400000003646272656600380000000224726566000b000000636f6c6c656374696f6e00072469640058921b3e6e32ab156a22b59e02666f6f0004000000626172000000",
"canonical_extjson": "{\"dbref\": {\"$ref\": \"collection\", \"$id\": {\"$oid\": \"58921b3e6e32ab156a22b59e\"}, \"foo\": \"bar\"}}"
},
{
"description": "Document with key names similar to those of a DBRef",
"bson": "3e0000000224726566000c0000006e6f742d612d646272656600072469640058921b3e6e32ab156a22b59e022462616e616e6100050000007065656c0000",
"extjson": "{\"$ref\": \"not-a-dbref\", \"$id\": {\"$oid\": \"58921b3e6e32ab156a22b59e\"}, \"$banana\": \"peel\"}"
"canonical_bson": "3e0000000224726566000c0000006e6f742d612d646272656600072469640058921b3e6e32ab156a22b59e022462616e616e6100050000007065656c0000",
"canonical_extjson": "{\"$ref\": \"not-a-dbref\", \"$id\": {\"$oid\": \"58921b3e6e32ab156a22b59e\"}, \"$banana\": \"peel\"}"
}
]
}

View File

@ -0,0 +1,317 @@
{
"description": "Decimal128",
"bson_type": "0x13",
"test_key": "d",
"valid": [
{
"description": "Special - Canonical NaN",
"canonical_bson": "180000001364000000000000000000000000000000007C00",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"NaN\"}}"
},
{
"description": "Special - Negative NaN",
"canonical_bson": "18000000136400000000000000000000000000000000FC00",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"NaN\"}}",
"lossy": true
},
{
"description": "Special - Negative NaN",
"canonical_bson": "18000000136400000000000000000000000000000000FC00",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"NaN\"}}",
"degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"-NaN\"}}",
"lossy": true
},
{
"description": "Special - Canonical SNaN",
"canonical_bson": "180000001364000000000000000000000000000000007E00",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"NaN\"}}",
"lossy": true
},
{
"description": "Special - Negative SNaN",
"canonical_bson": "18000000136400000000000000000000000000000000FE00",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"NaN\"}}",
"lossy": true
},
{
"description": "Special - NaN with a payload",
"canonical_bson": "180000001364001200000000000000000000000000007E00",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"NaN\"}}",
"lossy": true
},
{
"description": "Special - Canonical Positive Infinity",
"canonical_bson": "180000001364000000000000000000000000000000007800",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"Infinity\"}}"
},
{
"description": "Special - Canonical Negative Infinity",
"canonical_bson": "18000000136400000000000000000000000000000000F800",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"-Infinity\"}}"
},
{
"description": "Special - Invalid representation treated as 0",
"canonical_bson": "180000001364000000000000000000000000000000106C00",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"0\"}}",
"lossy": true
},
{
"description": "Special - Invalid representation treated as -0",
"canonical_bson": "18000000136400DCBA9876543210DEADBEEF00000010EC00",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"-0\"}}",
"lossy": true
},
{
"description": "Special - Invalid representation treated as 0E3",
"canonical_bson": "18000000136400FFFFFFFFFFFFFFFFFFFFFFFFFFFF116C00",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"0E+3\"}}",
"lossy": true
},
{
"description": "Regular - Adjusted Exponent Limit",
"canonical_bson": "18000000136400F2AF967ED05C82DE3297FF6FDE3CF22F00",
"canonical_extjson": "{\"d\": { \"$numberDecimal\": \"0.000001234567890123456789012345678901234\" }}"
},
{
"description": "Regular - Smallest",
"canonical_bson": "18000000136400D204000000000000000000000000343000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"0.001234\"}}"
},
{
"description": "Regular - Smallest with Trailing Zeros",
"canonical_bson": "1800000013640040EF5A07000000000000000000002A3000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"0.00123400000\"}}"
},
{
"description": "Regular - 0.1",
"canonical_bson": "1800000013640001000000000000000000000000003E3000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"0.1\"}}"
},
{
"description": "Regular - 0.1234567890123456789012345678901234",
"canonical_bson": "18000000136400F2AF967ED05C82DE3297FF6FDE3CFC2F00",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"0.1234567890123456789012345678901234\"}}"
},
{
"description": "Regular - 0",
"canonical_bson": "180000001364000000000000000000000000000000403000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"0\"}}"
},
{
"description": "Regular - -0",
"canonical_bson": "18000000136400000000000000000000000000000040B000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"-0\"}}"
},
{
"description": "Regular - -0.0",
"canonical_bson": "1800000013640000000000000000000000000000003EB000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"-0.0\"}}"
},
{
"description": "Regular - 2",
"canonical_bson": "180000001364000200000000000000000000000000403000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"2\"}}"
},
{
"description": "Regular - 2.000",
"canonical_bson": "18000000136400D0070000000000000000000000003A3000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"2.000\"}}"
},
{
"description": "Regular - Largest",
"canonical_bson": "18000000136400F2AF967ED05C82DE3297FF6FDE3C403000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1234567890123456789012345678901234\"}}"
},
{
"description": "Scientific - Tiniest",
"canonical_bson": "18000000136400FFFFFFFF638E8D37C087ADBE09ED010000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"9.999999999999999999999999999999999E-6143\"}}"
},
{
"description": "Scientific - Tiny",
"canonical_bson": "180000001364000100000000000000000000000000000000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1E-6176\"}}"
},
{
"description": "Scientific - Negative Tiny",
"canonical_bson": "180000001364000100000000000000000000000000008000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"-1E-6176\"}}"
},
{
"description": "Scientific - Adjusted Exponent Limit",
"canonical_bson": "18000000136400F2AF967ED05C82DE3297FF6FDE3CF02F00",
"canonical_extjson": "{\"d\": { \"$numberDecimal\": \"1.234567890123456789012345678901234E-7\" }}"
},
{
"description": "Scientific - Fractional",
"canonical_bson": "1800000013640064000000000000000000000000002CB000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"-1.00E-8\"}}"
},
{
"description": "Scientific - 0 with Exponent",
"canonical_bson": "180000001364000000000000000000000000000000205F00",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"0E+6000\"}}"
},
{
"description": "Scientific - 0 with Negative Exponent",
"canonical_bson": "1800000013640000000000000000000000000000007A2B00",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"0E-611\"}}"
},
{
"description": "Scientific - No Decimal with Signed Exponent",
"canonical_bson": "180000001364000100000000000000000000000000463000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1E+3\"}}"
},
{
"description": "Scientific - Trailing Zero",
"canonical_bson": "180000001364001A04000000000000000000000000423000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1.050E+4\"}}"
},
{
"description": "Scientific - With Decimal",
"canonical_bson": "180000001364006900000000000000000000000000423000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1.05E+3\"}}"
},
{
"description": "Scientific - Full",
"canonical_bson": "18000000136400FFFFFFFFFFFFFFFFFFFFFFFFFFFF403000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"5192296858534827628530496329220095\"}}"
},
{
"description": "Scientific - Large",
"canonical_bson": "18000000136400000000000A5BC138938D44C64D31FE5F00",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1.000000000000000000000000000000000E+6144\"}}"
},
{
"description": "Scientific - Largest",
"canonical_bson": "18000000136400FFFFFFFF638E8D37C087ADBE09EDFF5F00",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"9.999999999999999999999999999999999E+6144\"}}"
},
{
"description": "Non-Canonical Parsing - Exponent Normalization",
"canonical_bson": "1800000013640064000000000000000000000000002CB000",
"degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"-100E-10\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"-1.00E-8\"}}"
},
{
"description": "Non-Canonical Parsing - Unsigned Positive Exponent",
"canonical_bson": "180000001364000100000000000000000000000000463000",
"degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"1E3\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1E+3\"}}"
},
{
"description": "Non-Canonical Parsing - Lowercase Exponent Identifier",
"canonical_bson": "180000001364000100000000000000000000000000463000",
"degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"1e+3\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1E+3\"}}"
},
{
"description": "Non-Canonical Parsing - Long Significand with Exponent",
"canonical_bson": "1800000013640079D9E0F9763ADA429D0200000000583000",
"degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"12345689012345789012345E+12\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1.2345689012345789012345E+34\"}}"
},
{
"description": "Non-Canonical Parsing - Positive Sign",
"canonical_bson": "18000000136400F2AF967ED05C82DE3297FF6FDE3C403000",
"degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"+1234567890123456789012345678901234\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1234567890123456789012345678901234\"}}"
},
{
"description": "Non-Canonical Parsing - Long Decimal String",
"canonical_bson": "180000001364000100000000000000000000000000722800",
"degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \".000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1E-999\"}}"
},
{
"description": "Non-Canonical Parsing - nan",
"canonical_bson": "180000001364000000000000000000000000000000007C00",
"degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"nan\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"NaN\"}}"
},
{
"description": "Non-Canonical Parsing - nAn",
"canonical_bson": "180000001364000000000000000000000000000000007C00",
"degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"nAn\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"NaN\"}}"
},
{
"description": "Non-Canonical Parsing - +infinity",
"canonical_bson": "180000001364000000000000000000000000000000007800",
"degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"+infinity\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"Infinity\"}}"
},
{
"description": "Non-Canonical Parsing - infinity",
"canonical_bson": "180000001364000000000000000000000000000000007800",
"degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"infinity\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"Infinity\"}}"
},
{
"description": "Non-Canonical Parsing - infiniTY",
"canonical_bson": "180000001364000000000000000000000000000000007800",
"degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"infiniTY\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"Infinity\"}}"
},
{
"description": "Non-Canonical Parsing - inf",
"canonical_bson": "180000001364000000000000000000000000000000007800",
"degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"inf\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"Infinity\"}}"
},
{
"description": "Non-Canonical Parsing - inF",
"canonical_bson": "180000001364000000000000000000000000000000007800",
"degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"inF\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"Infinity\"}}"
},
{
"description": "Non-Canonical Parsing - -infinity",
"canonical_bson": "18000000136400000000000000000000000000000000F800",
"degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"-infinity\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"-Infinity\"}}"
},
{
"description": "Non-Canonical Parsing - -infiniTy",
"canonical_bson": "18000000136400000000000000000000000000000000F800",
"degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"-infiniTy\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"-Infinity\"}}"
},
{
"description": "Non-Canonical Parsing - -Inf",
"canonical_bson": "18000000136400000000000000000000000000000000F800",
"degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"-Infinity\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"-Infinity\"}}"
},
{
"description": "Non-Canonical Parsing - -inf",
"canonical_bson": "18000000136400000000000000000000000000000000F800",
"degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"-inf\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"-Infinity\"}}"
},
{
"description": "Non-Canonical Parsing - -inF",
"canonical_bson": "18000000136400000000000000000000000000000000F800",
"degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"-inF\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"-Infinity\"}}"
},
{
"description": "Rounded Subnormal number",
"canonical_bson": "180000001364000100000000000000000000000000000000",
"degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"10E-6177\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1E-6176\"}}"
},
{
"description": "Clamped",
"canonical_bson": "180000001364000a00000000000000000000000000fe5f00",
"degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"1E6112\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1.0E+6112\"}}"
},
{
"description": "Exact rounding",
"canonical_bson": "18000000136400000000000a5bc138938d44c64d31cc3700",
"degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1.000000000000000000000000000000000E+999\"}}"
}
]
}

View File

@ -0,0 +1,793 @@
{
"description": "Decimal128",
"bson_type": "0x13",
"test_key": "d",
"valid": [
{
"description": "[decq021] Normality",
"canonical_bson": "18000000136400F2AF967ED05C82DE3297FF6FDE3C40B000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"-1234567890123456789012345678901234\"}}"
},
{
"description": "[decq823] values around [u]int32 edges (zeros done earlier)",
"canonical_bson": "18000000136400010000800000000000000000000040B000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"-2147483649\"}}"
},
{
"description": "[decq822] values around [u]int32 edges (zeros done earlier)",
"canonical_bson": "18000000136400000000800000000000000000000040B000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"-2147483648\"}}"
},
{
"description": "[decq821] values around [u]int32 edges (zeros done earlier)",
"canonical_bson": "18000000136400FFFFFF7F0000000000000000000040B000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"-2147483647\"}}"
},
{
"description": "[decq820] values around [u]int32 edges (zeros done earlier)",
"canonical_bson": "18000000136400FEFFFF7F0000000000000000000040B000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"-2147483646\"}}"
},
{
"description": "[decq152] fold-downs (more below)",
"canonical_bson": "18000000136400393000000000000000000000000040B000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"-12345\"}}"
},
{
"description": "[decq154] fold-downs (more below)",
"canonical_bson": "18000000136400D20400000000000000000000000040B000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"-1234\"}}"
},
{
"description": "[decq006] derivative canonical plain strings",
"canonical_bson": "18000000136400EE0200000000000000000000000040B000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"-750\"}}"
},
{
"description": "[decq164] fold-downs (more below)",
"canonical_bson": "1800000013640039300000000000000000000000003CB000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"-123.45\"}}"
},
{
"description": "[decq156] fold-downs (more below)",
"canonical_bson": "180000001364007B0000000000000000000000000040B000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"-123\"}}"
},
{
"description": "[decq008] derivative canonical plain strings",
"canonical_bson": "18000000136400EE020000000000000000000000003EB000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"-75.0\"}}"
},
{
"description": "[decq158] fold-downs (more below)",
"canonical_bson": "180000001364000C0000000000000000000000000040B000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"-12\"}}"
},
{
"description": "[decq122] Nmax and similar",
"canonical_bson": "18000000136400FFFFFFFF638E8D37C087ADBE09EDFFDF00",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"-9.999999999999999999999999999999999E+6144\"}}"
},
{
"description": "[decq002] (mostly derived from the Strawman 4 document and examples)",
"canonical_bson": "18000000136400EE020000000000000000000000003CB000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"-7.50\"}}"
},
{
"description": "[decq004] derivative canonical plain strings",
"canonical_bson": "18000000136400EE0200000000000000000000000042B000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"-7.50E+3\"}}"
},
{
"description": "[decq018] derivative canonical plain strings",
"canonical_bson": "18000000136400EE020000000000000000000000002EB000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"-7.50E-7\"}}"
},
{
"description": "[decq125] Nmax and similar",
"canonical_bson": "18000000136400F2AF967ED05C82DE3297FF6FDE3CFEDF00",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"-1.234567890123456789012345678901234E+6144\"}}"
},
{
"description": "[decq131] fold-downs (more below)",
"canonical_bson": "18000000136400000000807F1BCF85B27059C8A43CFEDF00",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"-1.230000000000000000000000000000000E+6144\"}}"
},
{
"description": "[decq162] fold-downs (more below)",
"canonical_bson": "180000001364007B000000000000000000000000003CB000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"-1.23\"}}"
},
{
"description": "[decq176] Nmin and below",
"canonical_bson": "18000000136400010000000A5BC138938D44C64D31008000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"-1.000000000000000000000000000000001E-6143\"}}"
},
{
"description": "[decq174] Nmin and below",
"canonical_bson": "18000000136400000000000A5BC138938D44C64D31008000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"-1.000000000000000000000000000000000E-6143\"}}"
},
{
"description": "[decq133] fold-downs (more below)",
"canonical_bson": "18000000136400000000000A5BC138938D44C64D31FEDF00",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"-1.000000000000000000000000000000000E+6144\"}}"
},
{
"description": "[decq160] fold-downs (more below)",
"canonical_bson": "18000000136400010000000000000000000000000040B000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"-1\"}}"
},
{
"description": "[decq172] Nmin and below",
"canonical_bson": "180000001364000100000000000000000000000000428000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"-1E-6143\"}}"
},
{
"description": "[decq010] derivative canonical plain strings",
"canonical_bson": "18000000136400EE020000000000000000000000003AB000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"-0.750\"}}"
},
{
"description": "[decq012] derivative canonical plain strings",
"canonical_bson": "18000000136400EE0200000000000000000000000038B000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"-0.0750\"}}"
},
{
"description": "[decq014] derivative canonical plain strings",
"canonical_bson": "18000000136400EE0200000000000000000000000034B000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"-0.000750\"}}"
},
{
"description": "[decq016] derivative canonical plain strings",
"canonical_bson": "18000000136400EE0200000000000000000000000030B000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"-0.00000750\"}}"
},
{
"description": "[decq404] zeros",
"canonical_bson": "180000001364000000000000000000000000000000000000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"0E-6176\"}}"
},
{
"description": "[decq424] negative zeros",
"canonical_bson": "180000001364000000000000000000000000000000008000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"-0E-6176\"}}"
},
{
"description": "[decq407] zeros",
"canonical_bson": "1800000013640000000000000000000000000000003C3000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"0.00\"}}"
},
{
"description": "[decq427] negative zeros",
"canonical_bson": "1800000013640000000000000000000000000000003CB000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"-0.00\"}}"
},
{
"description": "[decq409] zeros",
"canonical_bson": "180000001364000000000000000000000000000000403000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"0\"}}"
},
{
"description": "[decq428] negative zeros",
"canonical_bson": "18000000136400000000000000000000000000000040B000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"-0\"}}"
},
{
"description": "[decq700] Selected DPD codes",
"canonical_bson": "180000001364000000000000000000000000000000403000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"0\"}}"
},
{
"description": "[decq406] zeros",
"canonical_bson": "1800000013640000000000000000000000000000003C3000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"0.00\"}}"
},
{
"description": "[decq426] negative zeros",
"canonical_bson": "1800000013640000000000000000000000000000003CB000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"-0.00\"}}"
},
{
"description": "[decq410] zeros",
"canonical_bson": "180000001364000000000000000000000000000000463000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"0E+3\"}}"
},
{
"description": "[decq431] negative zeros",
"canonical_bson": "18000000136400000000000000000000000000000046B000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"-0E+3\"}}"
},
{
"description": "[decq419] clamped zeros...",
"canonical_bson": "180000001364000000000000000000000000000000FE5F00",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"0E+6111\"}}"
},
{
"description": "[decq432] negative zeros",
"canonical_bson": "180000001364000000000000000000000000000000FEDF00",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"-0E+6111\"}}"
},
{
"description": "[decq405] zeros",
"canonical_bson": "180000001364000000000000000000000000000000000000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"0E-6176\"}}"
},
{
"description": "[decq425] negative zeros",
"canonical_bson": "180000001364000000000000000000000000000000008000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"-0E-6176\"}}"
},
{
"description": "[decq508] Specials",
"canonical_bson": "180000001364000000000000000000000000000000007800",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"Infinity\"}}"
},
{
"description": "[decq528] Specials",
"canonical_bson": "18000000136400000000000000000000000000000000F800",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"-Infinity\"}}"
},
{
"description": "[decq541] Specials",
"canonical_bson": "180000001364000000000000000000000000000000007C00",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"NaN\"}}"
},
{
"description": "[decq074] Nmin and below",
"canonical_bson": "18000000136400000000000A5BC138938D44C64D31000000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1.000000000000000000000000000000000E-6143\"}}"
},
{
"description": "[decq602] fold-down full sequence",
"canonical_bson": "18000000136400000000000A5BC138938D44C64D31FE5F00",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1.000000000000000000000000000000000E+6144\"}}"
},
{
"description": "[decq604] fold-down full sequence",
"canonical_bson": "180000001364000000000081EFAC855B416D2DEE04FE5F00",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1.00000000000000000000000000000000E+6143\"}}"
},
{
"description": "[decq606] fold-down full sequence",
"canonical_bson": "1800000013640000000080264B91C02220BE377E00FE5F00",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1.0000000000000000000000000000000E+6142\"}}"
},
{
"description": "[decq608] fold-down full sequence",
"canonical_bson": "1800000013640000000040EAED7446D09C2C9F0C00FE5F00",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1.000000000000000000000000000000E+6141\"}}"
},
{
"description": "[decq610] fold-down full sequence",
"canonical_bson": "18000000136400000000A0CA17726DAE0F1E430100FE5F00",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1.00000000000000000000000000000E+6140\"}}"
},
{
"description": "[decq612] fold-down full sequence",
"canonical_bson": "18000000136400000000106102253E5ECE4F200000FE5F00",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1.0000000000000000000000000000E+6139\"}}"
},
{
"description": "[decq614] fold-down full sequence",
"canonical_bson": "18000000136400000000E83C80D09F3C2E3B030000FE5F00",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1.000000000000000000000000000E+6138\"}}"
},
{
"description": "[decq616] fold-down full sequence",
"canonical_bson": "18000000136400000000E4D20CC8DCD2B752000000FE5F00",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1.00000000000000000000000000E+6137\"}}"
},
{
"description": "[decq618] fold-down full sequence",
"canonical_bson": "180000001364000000004A48011416954508000000FE5F00",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1.0000000000000000000000000E+6136\"}}"
},
{
"description": "[decq620] fold-down full sequence",
"canonical_bson": "18000000136400000000A1EDCCCE1BC2D300000000FE5F00",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1.000000000000000000000000E+6135\"}}"
},
{
"description": "[decq622] fold-down full sequence",
"canonical_bson": "18000000136400000080F64AE1C7022D1500000000FE5F00",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1.00000000000000000000000E+6134\"}}"
},
{
"description": "[decq624] fold-down full sequence",
"canonical_bson": "18000000136400000040B2BAC9E0191E0200000000FE5F00",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1.0000000000000000000000E+6133\"}}"
},
{
"description": "[decq626] fold-down full sequence",
"canonical_bson": "180000001364000000A0DEC5ADC935360000000000FE5F00",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1.000000000000000000000E+6132\"}}"
},
{
"description": "[decq628] fold-down full sequence",
"canonical_bson": "18000000136400000010632D5EC76B050000000000FE5F00",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1.00000000000000000000E+6131\"}}"
},
{
"description": "[decq630] fold-down full sequence",
"canonical_bson": "180000001364000000E8890423C78A000000000000FE5F00",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1.0000000000000000000E+6130\"}}"
},
{
"description": "[decq632] fold-down full sequence",
"canonical_bson": "18000000136400000064A7B3B6E00D000000000000FE5F00",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1.000000000000000000E+6129\"}}"
},
{
"description": "[decq634] fold-down full sequence",
"canonical_bson": "1800000013640000008A5D78456301000000000000FE5F00",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1.00000000000000000E+6128\"}}"
},
{
"description": "[decq636] fold-down full sequence",
"canonical_bson": "180000001364000000C16FF2862300000000000000FE5F00",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1.0000000000000000E+6127\"}}"
},
{
"description": "[decq638] fold-down full sequence",
"canonical_bson": "180000001364000080C6A47E8D0300000000000000FE5F00",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1.000000000000000E+6126\"}}"
},
{
"description": "[decq640] fold-down full sequence",
"canonical_bson": "1800000013640000407A10F35A0000000000000000FE5F00",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1.00000000000000E+6125\"}}"
},
{
"description": "[decq642] fold-down full sequence",
"canonical_bson": "1800000013640000A0724E18090000000000000000FE5F00",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1.0000000000000E+6124\"}}"
},
{
"description": "[decq644] fold-down full sequence",
"canonical_bson": "180000001364000010A5D4E8000000000000000000FE5F00",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1.000000000000E+6123\"}}"
},
{
"description": "[decq646] fold-down full sequence",
"canonical_bson": "1800000013640000E8764817000000000000000000FE5F00",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1.00000000000E+6122\"}}"
},
{
"description": "[decq648] fold-down full sequence",
"canonical_bson": "1800000013640000E40B5402000000000000000000FE5F00",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1.0000000000E+6121\"}}"
},
{
"description": "[decq650] fold-down full sequence",
"canonical_bson": "1800000013640000CA9A3B00000000000000000000FE5F00",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1.000000000E+6120\"}}"
},
{
"description": "[decq652] fold-down full sequence",
"canonical_bson": "1800000013640000E1F50500000000000000000000FE5F00",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1.00000000E+6119\"}}"
},
{
"description": "[decq654] fold-down full sequence",
"canonical_bson": "180000001364008096980000000000000000000000FE5F00",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1.0000000E+6118\"}}"
},
{
"description": "[decq656] fold-down full sequence",
"canonical_bson": "1800000013640040420F0000000000000000000000FE5F00",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1.000000E+6117\"}}"
},
{
"description": "[decq658] fold-down full sequence",
"canonical_bson": "18000000136400A086010000000000000000000000FE5F00",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1.00000E+6116\"}}"
},
{
"description": "[decq660] fold-down full sequence",
"canonical_bson": "180000001364001027000000000000000000000000FE5F00",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1.0000E+6115\"}}"
},
{
"description": "[decq662] fold-down full sequence",
"canonical_bson": "18000000136400E803000000000000000000000000FE5F00",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1.000E+6114\"}}"
},
{
"description": "[decq664] fold-down full sequence",
"canonical_bson": "180000001364006400000000000000000000000000FE5F00",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1.00E+6113\"}}"
},
{
"description": "[decq666] fold-down full sequence",
"canonical_bson": "180000001364000A00000000000000000000000000FE5F00",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1.0E+6112\"}}"
},
{
"description": "[decq060] fold-downs (more below)",
"canonical_bson": "180000001364000100000000000000000000000000403000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1\"}}"
},
{
"description": "[decq670] fold-down full sequence",
"canonical_bson": "180000001364000100000000000000000000000000FC5F00",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1E+6110\"}}"
},
{
"description": "[decq668] fold-down full sequence",
"canonical_bson": "180000001364000100000000000000000000000000FE5F00",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1E+6111\"}}"
},
{
"description": "[decq072] Nmin and below",
"canonical_bson": "180000001364000100000000000000000000000000420000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1E-6143\"}}"
},
{
"description": "[decq076] Nmin and below",
"canonical_bson": "18000000136400010000000A5BC138938D44C64D31000000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1.000000000000000000000000000000001E-6143\"}}"
},
{
"description": "[decq036] fold-downs (more below)",
"canonical_bson": "18000000136400000000807F1BCF85B27059C8A43CFE5F00",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1.230000000000000000000000000000000E+6144\"}}"
},
{
"description": "[decq062] fold-downs (more below)",
"canonical_bson": "180000001364007B000000000000000000000000003C3000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1.23\"}}"
},
{
"description": "[decq034] Nmax and similar",
"canonical_bson": "18000000136400F2AF967ED05C82DE3297FF6FDE3CFE5F00",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1.234567890123456789012345678901234E+6144\"}}"
},
{
"description": "[decq441] exponent lengths",
"canonical_bson": "180000001364000700000000000000000000000000403000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"7\"}}"
},
{
"description": "[decq449] exponent lengths",
"canonical_bson": "1800000013640007000000000000000000000000001E5F00",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"7E+5999\"}}"
},
{
"description": "[decq447] exponent lengths",
"canonical_bson": "1800000013640007000000000000000000000000000E3800",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"7E+999\"}}"
},
{
"description": "[decq445] exponent lengths",
"canonical_bson": "180000001364000700000000000000000000000000063100",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"7E+99\"}}"
},
{
"description": "[decq443] exponent lengths",
"canonical_bson": "180000001364000700000000000000000000000000523000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"7E+9\"}}"
},
{
"description": "[decq842] VG testcase",
"canonical_bson": "180000001364000000FED83F4E7C9FE4E269E38A5BCD1700",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"7.049000000000010795488000000000000E-3097\"}}"
},
{
"description": "[decq841] VG testcase",
"canonical_bson": "180000001364000000203B9DB5056F000000000000002400",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"8.000000000000000000E-1550\"}}"
},
{
"description": "[decq840] VG testcase",
"canonical_bson": "180000001364003C17258419D710C42F0000000000002400",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"8.81125000000001349436E-1548\"}}"
},
{
"description": "[decq701] Selected DPD codes",
"canonical_bson": "180000001364000900000000000000000000000000403000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"9\"}}"
},
{
"description": "[decq032] Nmax and similar",
"canonical_bson": "18000000136400FFFFFFFF638E8D37C087ADBE09EDFF5F00",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"9.999999999999999999999999999999999E+6144\"}}"
},
{
"description": "[decq702] Selected DPD codes",
"canonical_bson": "180000001364000A00000000000000000000000000403000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"10\"}}"
},
{
"description": "[decq057] fold-downs (more below)",
"canonical_bson": "180000001364000C00000000000000000000000000403000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"12\"}}"
},
{
"description": "[decq703] Selected DPD codes",
"canonical_bson": "180000001364001300000000000000000000000000403000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"19\"}}"
},
{
"description": "[decq704] Selected DPD codes",
"canonical_bson": "180000001364001400000000000000000000000000403000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"20\"}}"
},
{
"description": "[decq705] Selected DPD codes",
"canonical_bson": "180000001364001D00000000000000000000000000403000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"29\"}}"
},
{
"description": "[decq706] Selected DPD codes",
"canonical_bson": "180000001364001E00000000000000000000000000403000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"30\"}}"
},
{
"description": "[decq707] Selected DPD codes",
"canonical_bson": "180000001364002700000000000000000000000000403000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"39\"}}"
},
{
"description": "[decq708] Selected DPD codes",
"canonical_bson": "180000001364002800000000000000000000000000403000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"40\"}}"
},
{
"description": "[decq709] Selected DPD codes",
"canonical_bson": "180000001364003100000000000000000000000000403000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"49\"}}"
},
{
"description": "[decq710] Selected DPD codes",
"canonical_bson": "180000001364003200000000000000000000000000403000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"50\"}}"
},
{
"description": "[decq711] Selected DPD codes",
"canonical_bson": "180000001364003B00000000000000000000000000403000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"59\"}}"
},
{
"description": "[decq712] Selected DPD codes",
"canonical_bson": "180000001364003C00000000000000000000000000403000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"60\"}}"
},
{
"description": "[decq713] Selected DPD codes",
"canonical_bson": "180000001364004500000000000000000000000000403000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"69\"}}"
},
{
"description": "[decq714] Selected DPD codes",
"canonical_bson": "180000001364004600000000000000000000000000403000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"70\"}}"
},
{
"description": "[decq715] Selected DPD codes",
"canonical_bson": "180000001364004700000000000000000000000000403000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"71\"}}"
},
{
"description": "[decq716] Selected DPD codes",
"canonical_bson": "180000001364004800000000000000000000000000403000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"72\"}}"
},
{
"description": "[decq717] Selected DPD codes",
"canonical_bson": "180000001364004900000000000000000000000000403000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"73\"}}"
},
{
"description": "[decq718] Selected DPD codes",
"canonical_bson": "180000001364004A00000000000000000000000000403000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"74\"}}"
},
{
"description": "[decq719] Selected DPD codes",
"canonical_bson": "180000001364004B00000000000000000000000000403000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"75\"}}"
},
{
"description": "[decq720] Selected DPD codes",
"canonical_bson": "180000001364004C00000000000000000000000000403000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"76\"}}"
},
{
"description": "[decq721] Selected DPD codes",
"canonical_bson": "180000001364004D00000000000000000000000000403000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"77\"}}"
},
{
"description": "[decq722] Selected DPD codes",
"canonical_bson": "180000001364004E00000000000000000000000000403000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"78\"}}"
},
{
"description": "[decq723] Selected DPD codes",
"canonical_bson": "180000001364004F00000000000000000000000000403000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"79\"}}"
},
{
"description": "[decq056] fold-downs (more below)",
"canonical_bson": "180000001364007B00000000000000000000000000403000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"123\"}}"
},
{
"description": "[decq064] fold-downs (more below)",
"canonical_bson": "1800000013640039300000000000000000000000003C3000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"123.45\"}}"
},
{
"description": "[decq732] Selected DPD codes",
"canonical_bson": "180000001364000802000000000000000000000000403000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"520\"}}"
},
{
"description": "[decq733] Selected DPD codes",
"canonical_bson": "180000001364000902000000000000000000000000403000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"521\"}}"
},
{
"description": "[decq740] DPD: one of each of the huffman groups",
"canonical_bson": "180000001364000903000000000000000000000000403000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"777\"}}"
},
{
"description": "[decq741] DPD: one of each of the huffman groups",
"canonical_bson": "180000001364000A03000000000000000000000000403000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"778\"}}"
},
{
"description": "[decq742] DPD: one of each of the huffman groups",
"canonical_bson": "180000001364001303000000000000000000000000403000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"787\"}}"
},
{
"description": "[decq746] DPD: one of each of the huffman groups",
"canonical_bson": "180000001364001F03000000000000000000000000403000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"799\"}}"
},
{
"description": "[decq743] DPD: one of each of the huffman groups",
"canonical_bson": "180000001364006D03000000000000000000000000403000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"877\"}}"
},
{
"description": "[decq753] DPD all-highs cases (includes the 24 redundant codes)",
"canonical_bson": "180000001364007803000000000000000000000000403000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"888\"}}"
},
{
"description": "[decq754] DPD all-highs cases (includes the 24 redundant codes)",
"canonical_bson": "180000001364007903000000000000000000000000403000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"889\"}}"
},
{
"description": "[decq760] DPD all-highs cases (includes the 24 redundant codes)",
"canonical_bson": "180000001364008203000000000000000000000000403000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"898\"}}"
},
{
"description": "[decq764] DPD all-highs cases (includes the 24 redundant codes)",
"canonical_bson": "180000001364008303000000000000000000000000403000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"899\"}}"
},
{
"description": "[decq745] DPD: one of each of the huffman groups",
"canonical_bson": "18000000136400D303000000000000000000000000403000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"979\"}}"
},
{
"description": "[decq770] DPD all-highs cases (includes the 24 redundant codes)",
"canonical_bson": "18000000136400DC03000000000000000000000000403000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"988\"}}"
},
{
"description": "[decq774] DPD all-highs cases (includes the 24 redundant codes)",
"canonical_bson": "18000000136400DD03000000000000000000000000403000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"989\"}}"
},
{
"description": "[decq730] Selected DPD codes",
"canonical_bson": "18000000136400E203000000000000000000000000403000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"994\"}}"
},
{
"description": "[decq731] Selected DPD codes",
"canonical_bson": "18000000136400E303000000000000000000000000403000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"995\"}}"
},
{
"description": "[decq744] DPD: one of each of the huffman groups",
"canonical_bson": "18000000136400E503000000000000000000000000403000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"997\"}}"
},
{
"description": "[decq780] DPD all-highs cases (includes the 24 redundant codes)",
"canonical_bson": "18000000136400E603000000000000000000000000403000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"998\"}}"
},
{
"description": "[decq787] DPD all-highs cases (includes the 24 redundant codes)",
"canonical_bson": "18000000136400E703000000000000000000000000403000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"999\"}}"
},
{
"description": "[decq053] fold-downs (more below)",
"canonical_bson": "18000000136400D204000000000000000000000000403000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1234\"}}"
},
{
"description": "[decq052] fold-downs (more below)",
"canonical_bson": "180000001364003930000000000000000000000000403000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"12345\"}}"
},
{
"description": "[decq792] Miscellaneous (testers' queries, etc.)",
"canonical_bson": "180000001364003075000000000000000000000000403000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"30000\"}}"
},
{
"description": "[decq793] Miscellaneous (testers' queries, etc.)",
"canonical_bson": "1800000013640090940D0000000000000000000000403000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"890000\"}}"
},
{
"description": "[decq824] values around [u]int32 edges (zeros done earlier)",
"canonical_bson": "18000000136400FEFFFF7F00000000000000000000403000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"2147483646\"}}"
},
{
"description": "[decq825] values around [u]int32 edges (zeros done earlier)",
"canonical_bson": "18000000136400FFFFFF7F00000000000000000000403000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"2147483647\"}}"
},
{
"description": "[decq826] values around [u]int32 edges (zeros done earlier)",
"canonical_bson": "180000001364000000008000000000000000000000403000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"2147483648\"}}"
},
{
"description": "[decq827] values around [u]int32 edges (zeros done earlier)",
"canonical_bson": "180000001364000100008000000000000000000000403000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"2147483649\"}}"
},
{
"description": "[decq828] values around [u]int32 edges (zeros done earlier)",
"canonical_bson": "18000000136400FEFFFFFF00000000000000000000403000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"4294967294\"}}"
},
{
"description": "[decq829] values around [u]int32 edges (zeros done earlier)",
"canonical_bson": "18000000136400FFFFFFFF00000000000000000000403000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"4294967295\"}}"
},
{
"description": "[decq830] values around [u]int32 edges (zeros done earlier)",
"canonical_bson": "180000001364000000000001000000000000000000403000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"4294967296\"}}"
},
{
"description": "[decq831] values around [u]int32 edges (zeros done earlier)",
"canonical_bson": "180000001364000100000001000000000000000000403000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"4294967297\"}}"
},
{
"description": "[decq022] Normality",
"canonical_bson": "18000000136400C7711CC7B548F377DC80A131C836403000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1111111111111111111111111111111111\"}}"
},
{
"description": "[decq020] Normality",
"canonical_bson": "18000000136400F2AF967ED05C82DE3297FF6FDE3C403000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1234567890123456789012345678901234\"}}"
},
{
"description": "[decq550] Specials",
"canonical_bson": "18000000136400FFFFFFFF638E8D37C087ADBE09ED413000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"9999999999999999999999999999999999\"}}"
}
]
}

File diff suppressed because it is too large Load Diff

View File

@ -5,78 +5,78 @@
"valid": [
{
"description": "[basx023] conform to rules and exponent will be in permitted range).",
"bson": "1800000013640001000000000000000000000000003EB000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"-0.1\"}}"
"canonical_bson": "1800000013640001000000000000000000000000003EB000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"-0.1\"}}"
},
{
"description": "[basx045] strings without E cannot generate E in result",
"bson": "1800000013640003000000000000000000000000003A3000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"+0.003\"}}",
"canonical_bson": "1800000013640003000000000000000000000000003A3000",
"degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"+0.003\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"0.003\"}}"
},
{
"description": "[basx610] Zeros",
"bson": "1800000013640000000000000000000000000000003E3000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \".0\"}}",
"canonical_bson": "1800000013640000000000000000000000000000003E3000",
"degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \".0\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"0.0\"}}"
},
{
"description": "[basx612] Zeros",
"bson": "1800000013640000000000000000000000000000003EB000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"-.0\"}}",
"canonical_bson": "1800000013640000000000000000000000000000003EB000",
"degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"-.0\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"-0.0\"}}"
},
{
"description": "[basx043] strings without E cannot generate E in result",
"bson": "18000000136400FC040000000000000000000000003C3000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"+12.76\"}}",
"canonical_bson": "18000000136400FC040000000000000000000000003C3000",
"degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"+12.76\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"12.76\"}}"
},
{
"description": "[basx055] strings without E cannot generate E in result",
"bson": "180000001364000500000000000000000000000000303000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"0.00000005\"}}",
"canonical_bson": "180000001364000500000000000000000000000000303000",
"degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"0.00000005\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"5E-8\"}}"
},
{
"description": "[basx054] strings without E cannot generate E in result",
"bson": "180000001364000500000000000000000000000000323000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"0.0000005\"}}",
"canonical_bson": "180000001364000500000000000000000000000000323000",
"degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"0.0000005\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"5E-7\"}}"
},
{
"description": "[basx052] strings without E cannot generate E in result",
"bson": "180000001364000500000000000000000000000000343000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"0.000005\"}}"
"canonical_bson": "180000001364000500000000000000000000000000343000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"0.000005\"}}"
},
{
"description": "[basx051] strings without E cannot generate E in result",
"bson": "180000001364000500000000000000000000000000363000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"00.00005\"}}",
"canonical_bson": "180000001364000500000000000000000000000000363000",
"degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"00.00005\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"0.00005\"}}"
},
{
"description": "[basx050] strings without E cannot generate E in result",
"bson": "180000001364000500000000000000000000000000383000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"0.0005\"}}"
"canonical_bson": "180000001364000500000000000000000000000000383000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"0.0005\"}}"
},
{
"description": "[basx047] strings without E cannot generate E in result",
"bson": "1800000013640005000000000000000000000000003E3000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \".5\"}}",
"canonical_bson": "1800000013640005000000000000000000000000003E3000",
"degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \".5\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"0.5\"}}"
},
{
"description": "[dqbsr431] check rounding modes heeded (Rounded)",
"bson": "1800000013640099761CC7B548F377DC80A131C836FE2F00",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"1.1111111111111111111111111111123450\"}}",
"canonical_bson": "1800000013640099761CC7B548F377DC80A131C836FE2F00",
"degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"1.1111111111111111111111111111123450\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1.111111111111111111111111111112345\"}}"
},
{
"description": "OK2",
"bson": "18000000136400000000000A5BC138938D44C64D31FC2F00",
"extjson": "{\"d\" : {\"$numberDecimal\" : \".100000000000000000000000000000000000000000000000000000000000\"}}",
"canonical_bson": "18000000136400000000000A5BC138938D44C64D31FC2F00",
"degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \".100000000000000000000000000000000000000000000000000000000000\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"0.1000000000000000000000000000000000\"}}"
}
],

View File

@ -5,396 +5,396 @@
"valid": [
{
"description": "[decq035] fold-downs (more below) (Clamped)",
"bson": "18000000136400000000807F1BCF85B27059C8A43CFE5F00",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"1.23E+6144\"}}",
"canonical_bson": "18000000136400000000807F1BCF85B27059C8A43CFE5F00",
"degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"1.23E+6144\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1.230000000000000000000000000000000E+6144\"}}"
},
{
"description": "[decq037] fold-downs (more below) (Clamped)",
"bson": "18000000136400000000000A5BC138938D44C64D31FE5F00",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"1E+6144\"}}",
"canonical_bson": "18000000136400000000000A5BC138938D44C64D31FE5F00",
"degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"1E+6144\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1.000000000000000000000000000000000E+6144\"}}"
},
{
"description": "[decq077] Nmin and below (Subnormal)",
"bson": "180000001364000000000081EFAC855B416D2DEE04000000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"0.100000000000000000000000000000000E-6143\"}}",
"canonical_bson": "180000001364000000000081EFAC855B416D2DEE04000000",
"degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"0.100000000000000000000000000000000E-6143\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1.00000000000000000000000000000000E-6144\"}}"
},
{
"description": "[decq078] Nmin and below (Subnormal)",
"bson": "180000001364000000000081EFAC855B416D2DEE04000000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"1.00000000000000000000000000000000E-6144\"}}"
"canonical_bson": "180000001364000000000081EFAC855B416D2DEE04000000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1.00000000000000000000000000000000E-6144\"}}"
},
{
"description": "[decq079] Nmin and below (Subnormal)",
"bson": "180000001364000A00000000000000000000000000000000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"0.000000000000000000000000000000010E-6143\"}}",
"canonical_bson": "180000001364000A00000000000000000000000000000000",
"degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"0.000000000000000000000000000000010E-6143\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1.0E-6175\"}}"
},
{
"description": "[decq080] Nmin and below (Subnormal)",
"bson": "180000001364000A00000000000000000000000000000000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"1.0E-6175\"}}"
"canonical_bson": "180000001364000A00000000000000000000000000000000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1.0E-6175\"}}"
},
{
"description": "[decq081] Nmin and below (Subnormal)",
"bson": "180000001364000100000000000000000000000000020000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"0.00000000000000000000000000000001E-6143\"}}",
"canonical_bson": "180000001364000100000000000000000000000000020000",
"degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"0.00000000000000000000000000000001E-6143\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1E-6175\"}}"
},
{
"description": "[decq082] Nmin and below (Subnormal)",
"bson": "180000001364000100000000000000000000000000020000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"1E-6175\"}}"
"canonical_bson": "180000001364000100000000000000000000000000020000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1E-6175\"}}"
},
{
"description": "[decq083] Nmin and below (Subnormal)",
"bson": "180000001364000100000000000000000000000000000000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"0.000000000000000000000000000000001E-6143\"}}",
"canonical_bson": "180000001364000100000000000000000000000000000000",
"degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"0.000000000000000000000000000000001E-6143\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1E-6176\"}}"
},
{
"description": "[decq084] Nmin and below (Subnormal)",
"bson": "180000001364000100000000000000000000000000000000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"1E-6176\"}}"
"canonical_bson": "180000001364000100000000000000000000000000000000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1E-6176\"}}"
},
{
"description": "[decq090] underflows cannot be tested for simple copies, check edge cases (Subnormal)",
"bson": "180000001364000100000000000000000000000000000000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"1e-6176\"}}",
"canonical_bson": "180000001364000100000000000000000000000000000000",
"degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"1e-6176\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1E-6176\"}}"
},
{
"description": "[decq100] underflows cannot be tested for simple copies, check edge cases (Subnormal)",
"bson": "18000000136400FFFFFFFF095BC138938D44C64D31000000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"999999999999999999999999999999999e-6176\"}}",
"canonical_bson": "18000000136400FFFFFFFF095BC138938D44C64D31000000",
"degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"999999999999999999999999999999999e-6176\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"9.99999999999999999999999999999999E-6144\"}}"
},
{
"description": "[decq130] fold-downs (more below) (Clamped)",
"bson": "18000000136400000000807F1BCF85B27059C8A43CFEDF00",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"-1.23E+6144\"}}",
"canonical_bson": "18000000136400000000807F1BCF85B27059C8A43CFEDF00",
"degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"-1.23E+6144\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"-1.230000000000000000000000000000000E+6144\"}}"
},
{
"description": "[decq132] fold-downs (more below) (Clamped)",
"bson": "18000000136400000000000A5BC138938D44C64D31FEDF00",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"-1E+6144\"}}",
"canonical_bson": "18000000136400000000000A5BC138938D44C64D31FEDF00",
"degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"-1E+6144\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"-1.000000000000000000000000000000000E+6144\"}}"
},
{
"description": "[decq177] Nmin and below (Subnormal)",
"bson": "180000001364000000000081EFAC855B416D2DEE04008000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"-0.100000000000000000000000000000000E-6143\"}}",
"canonical_bson": "180000001364000000000081EFAC855B416D2DEE04008000",
"degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"-0.100000000000000000000000000000000E-6143\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"-1.00000000000000000000000000000000E-6144\"}}"
},
{
"description": "[decq178] Nmin and below (Subnormal)",
"bson": "180000001364000000000081EFAC855B416D2DEE04008000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"-1.00000000000000000000000000000000E-6144\"}}"
"canonical_bson": "180000001364000000000081EFAC855B416D2DEE04008000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"-1.00000000000000000000000000000000E-6144\"}}"
},
{
"description": "[decq179] Nmin and below (Subnormal)",
"bson": "180000001364000A00000000000000000000000000008000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"-0.000000000000000000000000000000010E-6143\"}}",
"canonical_bson": "180000001364000A00000000000000000000000000008000",
"degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"-0.000000000000000000000000000000010E-6143\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"-1.0E-6175\"}}"
},
{
"description": "[decq180] Nmin and below (Subnormal)",
"bson": "180000001364000A00000000000000000000000000008000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"-1.0E-6175\"}}"
"canonical_bson": "180000001364000A00000000000000000000000000008000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"-1.0E-6175\"}}"
},
{
"description": "[decq181] Nmin and below (Subnormal)",
"bson": "180000001364000100000000000000000000000000028000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"-0.00000000000000000000000000000001E-6143\"}}",
"canonical_bson": "180000001364000100000000000000000000000000028000",
"degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"-0.00000000000000000000000000000001E-6143\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"-1E-6175\"}}"
},
{
"description": "[decq182] Nmin and below (Subnormal)",
"bson": "180000001364000100000000000000000000000000028000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"-1E-6175\"}}"
"canonical_bson": "180000001364000100000000000000000000000000028000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"-1E-6175\"}}"
},
{
"description": "[decq183] Nmin and below (Subnormal)",
"bson": "180000001364000100000000000000000000000000008000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"-0.000000000000000000000000000000001E-6143\"}}",
"canonical_bson": "180000001364000100000000000000000000000000008000",
"degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"-0.000000000000000000000000000000001E-6143\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"-1E-6176\"}}"
},
{
"description": "[decq184] Nmin and below (Subnormal)",
"bson": "180000001364000100000000000000000000000000008000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"-1E-6176\"}}"
"canonical_bson": "180000001364000100000000000000000000000000008000",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"-1E-6176\"}}"
},
{
"description": "[decq190] underflow edge cases (Subnormal)",
"bson": "180000001364000100000000000000000000000000008000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"-1e-6176\"}}",
"canonical_bson": "180000001364000100000000000000000000000000008000",
"degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"-1e-6176\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"-1E-6176\"}}"
},
{
"description": "[decq200] underflow edge cases (Subnormal)",
"bson": "18000000136400FFFFFFFF095BC138938D44C64D31008000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"-999999999999999999999999999999999e-6176\"}}",
"canonical_bson": "18000000136400FFFFFFFF095BC138938D44C64D31008000",
"degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"-999999999999999999999999999999999e-6176\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"-9.99999999999999999999999999999999E-6144\"}}"
},
{
"description": "[decq400] zeros (Clamped)",
"bson": "180000001364000000000000000000000000000000000000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"0E-8000\"}}",
"canonical_bson": "180000001364000000000000000000000000000000000000",
"degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"0E-8000\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"0E-6176\"}}"
},
{
"description": "[decq401] zeros (Clamped)",
"bson": "180000001364000000000000000000000000000000000000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"0E-6177\"}}",
"canonical_bson": "180000001364000000000000000000000000000000000000",
"degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"0E-6177\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"0E-6176\"}}"
},
{
"description": "[decq414] clamped zeros... (Clamped)",
"bson": "180000001364000000000000000000000000000000FE5F00",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"0E+6112\"}}",
"canonical_bson": "180000001364000000000000000000000000000000FE5F00",
"degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"0E+6112\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"0E+6111\"}}"
},
{
"description": "[decq416] clamped zeros... (Clamped)",
"bson": "180000001364000000000000000000000000000000FE5F00",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"0E+6144\"}}",
"canonical_bson": "180000001364000000000000000000000000000000FE5F00",
"degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"0E+6144\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"0E+6111\"}}"
},
{
"description": "[decq418] clamped zeros... (Clamped)",
"bson": "180000001364000000000000000000000000000000FE5F00",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"0E+8000\"}}",
"canonical_bson": "180000001364000000000000000000000000000000FE5F00",
"degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"0E+8000\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"0E+6111\"}}"
},
{
"description": "[decq420] negative zeros (Clamped)",
"bson": "180000001364000000000000000000000000000000008000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"-0E-8000\"}}",
"canonical_bson": "180000001364000000000000000000000000000000008000",
"degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"-0E-8000\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"-0E-6176\"}}"
},
{
"description": "[decq421] negative zeros (Clamped)",
"bson": "180000001364000000000000000000000000000000008000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"-0E-6177\"}}",
"canonical_bson": "180000001364000000000000000000000000000000008000",
"degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"-0E-6177\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"-0E-6176\"}}"
},
{
"description": "[decq434] clamped zeros... (Clamped)",
"bson": "180000001364000000000000000000000000000000FEDF00",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"-0E+6112\"}}",
"canonical_bson": "180000001364000000000000000000000000000000FEDF00",
"degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"-0E+6112\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"-0E+6111\"}}"
},
{
"description": "[decq436] clamped zeros... (Clamped)",
"bson": "180000001364000000000000000000000000000000FEDF00",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"-0E+6144\"}}",
"canonical_bson": "180000001364000000000000000000000000000000FEDF00",
"degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"-0E+6144\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"-0E+6111\"}}"
},
{
"description": "[decq438] clamped zeros... (Clamped)",
"bson": "180000001364000000000000000000000000000000FEDF00",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"-0E+8000\"}}",
"canonical_bson": "180000001364000000000000000000000000000000FEDF00",
"degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"-0E+8000\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"-0E+6111\"}}"
},
{
"description": "[decq601] fold-down full sequence (Clamped)",
"bson": "18000000136400000000000A5BC138938D44C64D31FE5F00",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"1E+6144\"}}",
"canonical_bson": "18000000136400000000000A5BC138938D44C64D31FE5F00",
"degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"1E+6144\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1.000000000000000000000000000000000E+6144\"}}"
},
{
"description": "[decq603] fold-down full sequence (Clamped)",
"bson": "180000001364000000000081EFAC855B416D2DEE04FE5F00",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"1E+6143\"}}",
"canonical_bson": "180000001364000000000081EFAC855B416D2DEE04FE5F00",
"degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"1E+6143\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1.00000000000000000000000000000000E+6143\"}}"
},
{
"description": "[decq605] fold-down full sequence (Clamped)",
"bson": "1800000013640000000080264B91C02220BE377E00FE5F00",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"1E+6142\"}}",
"canonical_bson": "1800000013640000000080264B91C02220BE377E00FE5F00",
"degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"1E+6142\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1.0000000000000000000000000000000E+6142\"}}"
},
{
"description": "[decq607] fold-down full sequence (Clamped)",
"bson": "1800000013640000000040EAED7446D09C2C9F0C00FE5F00",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"1E+6141\"}}",
"canonical_bson": "1800000013640000000040EAED7446D09C2C9F0C00FE5F00",
"degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"1E+6141\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1.000000000000000000000000000000E+6141\"}}"
},
{
"description": "[decq609] fold-down full sequence (Clamped)",
"bson": "18000000136400000000A0CA17726DAE0F1E430100FE5F00",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"1E+6140\"}}",
"canonical_bson": "18000000136400000000A0CA17726DAE0F1E430100FE5F00",
"degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"1E+6140\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1.00000000000000000000000000000E+6140\"}}"
},
{
"description": "[decq611] fold-down full sequence (Clamped)",
"bson": "18000000136400000000106102253E5ECE4F200000FE5F00",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"1E+6139\"}}",
"canonical_bson": "18000000136400000000106102253E5ECE4F200000FE5F00",
"degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"1E+6139\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1.0000000000000000000000000000E+6139\"}}"
},
{
"description": "[decq613] fold-down full sequence (Clamped)",
"bson": "18000000136400000000E83C80D09F3C2E3B030000FE5F00",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"1E+6138\"}}",
"canonical_bson": "18000000136400000000E83C80D09F3C2E3B030000FE5F00",
"degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"1E+6138\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1.000000000000000000000000000E+6138\"}}"
},
{
"description": "[decq615] fold-down full sequence (Clamped)",
"bson": "18000000136400000000E4D20CC8DCD2B752000000FE5F00",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"1E+6137\"}}",
"canonical_bson": "18000000136400000000E4D20CC8DCD2B752000000FE5F00",
"degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"1E+6137\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1.00000000000000000000000000E+6137\"}}"
},
{
"description": "[decq617] fold-down full sequence (Clamped)",
"bson": "180000001364000000004A48011416954508000000FE5F00",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"1E+6136\"}}",
"canonical_bson": "180000001364000000004A48011416954508000000FE5F00",
"degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"1E+6136\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1.0000000000000000000000000E+6136\"}}"
},
{
"description": "[decq619] fold-down full sequence (Clamped)",
"bson": "18000000136400000000A1EDCCCE1BC2D300000000FE5F00",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"1E+6135\"}}",
"canonical_bson": "18000000136400000000A1EDCCCE1BC2D300000000FE5F00",
"degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"1E+6135\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1.000000000000000000000000E+6135\"}}"
},
{
"description": "[decq621] fold-down full sequence (Clamped)",
"bson": "18000000136400000080F64AE1C7022D1500000000FE5F00",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"1E+6134\"}}",
"canonical_bson": "18000000136400000080F64AE1C7022D1500000000FE5F00",
"degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"1E+6134\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1.00000000000000000000000E+6134\"}}"
},
{
"description": "[decq623] fold-down full sequence (Clamped)",
"bson": "18000000136400000040B2BAC9E0191E0200000000FE5F00",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"1E+6133\"}}",
"canonical_bson": "18000000136400000040B2BAC9E0191E0200000000FE5F00",
"degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"1E+6133\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1.0000000000000000000000E+6133\"}}"
},
{
"description": "[decq625] fold-down full sequence (Clamped)",
"bson": "180000001364000000A0DEC5ADC935360000000000FE5F00",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"1E+6132\"}}",
"canonical_bson": "180000001364000000A0DEC5ADC935360000000000FE5F00",
"degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"1E+6132\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1.000000000000000000000E+6132\"}}"
},
{
"description": "[decq627] fold-down full sequence (Clamped)",
"bson": "18000000136400000010632D5EC76B050000000000FE5F00",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"1E+6131\"}}",
"canonical_bson": "18000000136400000010632D5EC76B050000000000FE5F00",
"degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"1E+6131\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1.00000000000000000000E+6131\"}}"
},
{
"description": "[decq629] fold-down full sequence (Clamped)",
"bson": "180000001364000000E8890423C78A000000000000FE5F00",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"1E+6130\"}}",
"canonical_bson": "180000001364000000E8890423C78A000000000000FE5F00",
"degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"1E+6130\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1.0000000000000000000E+6130\"}}"
},
{
"description": "[decq631] fold-down full sequence (Clamped)",
"bson": "18000000136400000064A7B3B6E00D000000000000FE5F00",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"1E+6129\"}}",
"canonical_bson": "18000000136400000064A7B3B6E00D000000000000FE5F00",
"degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"1E+6129\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1.000000000000000000E+6129\"}}"
},
{
"description": "[decq633] fold-down full sequence (Clamped)",
"bson": "1800000013640000008A5D78456301000000000000FE5F00",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"1E+6128\"}}",
"canonical_bson": "1800000013640000008A5D78456301000000000000FE5F00",
"degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"1E+6128\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1.00000000000000000E+6128\"}}"
},
{
"description": "[decq635] fold-down full sequence (Clamped)",
"bson": "180000001364000000C16FF2862300000000000000FE5F00",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"1E+6127\"}}",
"canonical_bson": "180000001364000000C16FF2862300000000000000FE5F00",
"degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"1E+6127\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1.0000000000000000E+6127\"}}"
},
{
"description": "[decq637] fold-down full sequence (Clamped)",
"bson": "180000001364000080C6A47E8D0300000000000000FE5F00",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"1E+6126\"}}",
"canonical_bson": "180000001364000080C6A47E8D0300000000000000FE5F00",
"degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"1E+6126\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1.000000000000000E+6126\"}}"
},
{
"description": "[decq639] fold-down full sequence (Clamped)",
"bson": "1800000013640000407A10F35A0000000000000000FE5F00",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"1E+6125\"}}",
"canonical_bson": "1800000013640000407A10F35A0000000000000000FE5F00",
"degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"1E+6125\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1.00000000000000E+6125\"}}"
},
{
"description": "[decq641] fold-down full sequence (Clamped)",
"bson": "1800000013640000A0724E18090000000000000000FE5F00",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"1E+6124\"}}",
"canonical_bson": "1800000013640000A0724E18090000000000000000FE5F00",
"degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"1E+6124\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1.0000000000000E+6124\"}}"
},
{
"description": "[decq643] fold-down full sequence (Clamped)",
"bson": "180000001364000010A5D4E8000000000000000000FE5F00",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"1E+6123\"}}",
"canonical_bson": "180000001364000010A5D4E8000000000000000000FE5F00",
"degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"1E+6123\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1.000000000000E+6123\"}}"
},
{
"description": "[decq645] fold-down full sequence (Clamped)",
"bson": "1800000013640000E8764817000000000000000000FE5F00",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"1E+6122\"}}",
"canonical_bson": "1800000013640000E8764817000000000000000000FE5F00",
"degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"1E+6122\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1.00000000000E+6122\"}}"
},
{
"description": "[decq647] fold-down full sequence (Clamped)",
"bson": "1800000013640000E40B5402000000000000000000FE5F00",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"1E+6121\"}}",
"canonical_bson": "1800000013640000E40B5402000000000000000000FE5F00",
"degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"1E+6121\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1.0000000000E+6121\"}}"
},
{
"description": "[decq649] fold-down full sequence (Clamped)",
"bson": "1800000013640000CA9A3B00000000000000000000FE5F00",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"1E+6120\"}}",
"canonical_bson": "1800000013640000CA9A3B00000000000000000000FE5F00",
"degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"1E+6120\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1.000000000E+6120\"}}"
},
{
"description": "[decq651] fold-down full sequence (Clamped)",
"bson": "1800000013640000E1F50500000000000000000000FE5F00",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"1E+6119\"}}",
"canonical_bson": "1800000013640000E1F50500000000000000000000FE5F00",
"degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"1E+6119\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1.00000000E+6119\"}}"
},
{
"description": "[decq653] fold-down full sequence (Clamped)",
"bson": "180000001364008096980000000000000000000000FE5F00",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"1E+6118\"}}",
"canonical_bson": "180000001364008096980000000000000000000000FE5F00",
"degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"1E+6118\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1.0000000E+6118\"}}"
},
{
"description": "[decq655] fold-down full sequence (Clamped)",
"bson": "1800000013640040420F0000000000000000000000FE5F00",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"1E+6117\"}}",
"canonical_bson": "1800000013640040420F0000000000000000000000FE5F00",
"degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"1E+6117\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1.000000E+6117\"}}"
},
{
"description": "[decq657] fold-down full sequence (Clamped)",
"bson": "18000000136400A086010000000000000000000000FE5F00",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"1E+6116\"}}",
"canonical_bson": "18000000136400A086010000000000000000000000FE5F00",
"degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"1E+6116\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1.00000E+6116\"}}"
},
{
"description": "[decq659] fold-down full sequence (Clamped)",
"bson": "180000001364001027000000000000000000000000FE5F00",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"1E+6115\"}}",
"canonical_bson": "180000001364001027000000000000000000000000FE5F00",
"degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"1E+6115\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1.0000E+6115\"}}"
},
{
"description": "[decq661] fold-down full sequence (Clamped)",
"bson": "18000000136400E803000000000000000000000000FE5F00",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"1E+6114\"}}",
"canonical_bson": "18000000136400E803000000000000000000000000FE5F00",
"degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"1E+6114\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1.000E+6114\"}}"
},
{
"description": "[decq663] fold-down full sequence (Clamped)",
"bson": "180000001364006400000000000000000000000000FE5F00",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"1E+6113\"}}",
"canonical_bson": "180000001364006400000000000000000000000000FE5F00",
"degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"1E+6113\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1.00E+6113\"}}"
},
{
"description": "[decq665] fold-down full sequence (Clamped)",
"bson": "180000001364000A00000000000000000000000000FE5F00",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"1E+6112\"}}",
"canonical_bson": "180000001364000A00000000000000000000000000FE5F00",
"degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"1E+6112\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1.0E+6112\"}}"
}
]

View File

@ -5,38 +5,18 @@
"valid": [
{
"description": "Empty subdoc",
"bson": "0D000000037800050000000000",
"extjson": "{\"x\" : {}}"
"canonical_bson": "0D000000037800050000000000",
"canonical_extjson": "{\"x\" : {}}"
},
{
"description": "Empty-string key subdoc",
"bson": "150000000378000D00000002000200000062000000",
"extjson": "{\"x\" : {\"\" : \"b\"}}"
"canonical_bson": "150000000378000D00000002000200000062000000",
"canonical_extjson": "{\"x\" : {\"\" : \"b\"}}"
},
{
"description": "Single-character key subdoc",
"bson": "160000000378000E0000000261000200000062000000",
"extjson": "{\"x\" : {\"a\" : \"b\"}}"
},
{
"description": "DBRef",
"bson": "37000000036462726566002b0000000224726566000b000000636f6c6c656374696f6e00072469640058921b3e6e32ab156a22b59e0000",
"extjson": "{\"dbref\": {\"$ref\": \"collection\", \"$id\": {\"$oid\": \"58921b3e6e32ab156a22b59e\"}}}"
},
{
"description": "DBRef with database",
"bson": "4300000003646272656600370000000224726566000b000000636f6c6c656374696f6e00072469640058921b3e6e32ab156a22b59e0224646200030000006462000000",
"extjson": "{\"dbref\": {\"$ref\": \"collection\", \"$id\": {\"$oid\": \"58921b3e6e32ab156a22b59e\"}, \"$db\": \"db\"}}"
},
{
"description": "DBRef with additional fields",
"bson": "4400000003646272656600380000000224726566000b000000636f6c6c656374696f6e00072469640058921b3e6e32ab156a22b59e02666f6f0004000000626172000000",
"extjson": "{\"dbref\": {\"$ref\": \"collection\", \"$id\": {\"$oid\": \"58921b3e6e32ab156a22b59e\"}, \"foo\": \"bar\"}}"
},
{
"description": "Document with key names similar to those of a DBRef",
"bson": "3e0000000224726566000c0000006e6f742d612d646272656600072469640058921b3e6e32ab156a22b59e022462616e616e6100050000007065656c0000",
"extjson": "{\"$ref\": \"not-a-dbref\", \"$id\": {\"$oid\": \"58921b3e6e32ab156a22b59e\"}, \"$banana\": \"peel\"}"
"canonical_bson": "160000000378000E0000000261000200000062000000",
"canonical_extjson": "{\"x\" : {\"a\" : \"b\"}}"
}
],
"decodeErrors": [

View File

@ -5,65 +5,77 @@
"valid": [
{
"description": "+1.0",
"bson": "10000000016400000000000000F03F00",
"extjson": "{\"d\" : {\"$numberDouble\": \"1.0\"}}"
"canonical_bson": "10000000016400000000000000F03F00",
"canonical_extjson": "{\"d\" : {\"$numberDouble\": \"1.0\"}}",
"relaxed_extjson": "{\"d\" : 1.0}"
},
{
"description": "-1.0",
"bson": "10000000016400000000000000F0BF00",
"extjson": "{\"d\" : {\"$numberDouble\": \"-1.0\"}}"
"canonical_bson": "10000000016400000000000000F0BF00",
"canonical_extjson": "{\"d\" : {\"$numberDouble\": \"-1.0\"}}",
"relaxed_extjson": "{\"d\" : -1.0}"
},
{
"description": "+1.0001220703125",
"bson": "10000000016400000000008000F03F00",
"extjson": "{\"d\" : {\"$numberDouble\": \"1.0001220703125\"}}"
"canonical_bson": "10000000016400000000008000F03F00",
"canonical_extjson": "{\"d\" : {\"$numberDouble\": \"1.0001220703125\"}}",
"relaxed_extjson": "{\"d\" : 1.0001220703125}"
},
{
"description": "-1.0001220703125",
"bson": "10000000016400000000008000F0BF00",
"extjson": "{\"d\" : {\"$numberDouble\": \"-1.0001220703125\"}}"
"canonical_bson": "10000000016400000000008000F0BF00",
"canonical_extjson": "{\"d\" : {\"$numberDouble\": \"-1.0001220703125\"}}",
"relaxed_extjson": "{\"d\" : -1.0001220703125}"
},
{
"description": "+2.0001220703125e10",
"bson": "1000000001640000807ca1a9a0124200",
"extjson": "{\"d\" : {\"$numberDouble\": \"20001220703.125\"}}"
"description": "1.2345678901234568e+18",
"canonical_bson": "1000000001640081E97DF41022B14300",
"canonical_extjson": "{\"d\" : {\"$numberDouble\": \"1.2345678901234568e+18\"}}",
"relaxed_extjson": "{\"d\" : 1.2345678901234568E+18}"
},
{
"description": "-2.0001220703125e10",
"bson": "1000000001640000807ca1a9a012c200",
"extjson": "{\"d\" : {\"$numberDouble\": \"-20001220703.125\"}}"
"description": "-1.2345678901234568e+18",
"canonical_bson": "1000000001640081E97DF41022B1C300",
"canonical_extjson": "{\"d\" : {\"$numberDouble\": \"-1.2345678901234568e+18\"}}",
"relaxed_extjson": "{\"d\" : -1.2345678901234568e+18}"
},
{
"description": "0.0",
"bson": "10000000016400000000000000000000",
"extjson": "{\"d\" : {\"$numberDouble\": \"0.0\"}}"
"canonical_bson": "10000000016400000000000000000000",
"canonical_extjson": "{\"d\" : {\"$numberDouble\": \"0.0\"}}",
"relaxed_extjson": "{\"d\" : 0.0}"
},
{
"description": "-0.0",
"bson": "10000000016400000000000000008000",
"extjson": "{\"d\" : {\"$numberDouble\": \"-0.0\"}}"
"canonical_bson": "10000000016400000000000000008000",
"canonical_extjson": "{\"d\" : {\"$numberDouble\": \"-0.0\"}}",
"relaxed_extjson": "{\"d\" : -0.0}"
},
{
"description": "NaN",
"bson": "10000000016400000000000000F87F00",
"extjson": "{\"d\": {\"$numberDouble\": \"NaN\"}}",
"canonical_bson": "10000000016400000000000000F87F00",
"canonical_extjson": "{\"d\": {\"$numberDouble\": \"NaN\"}}",
"relaxed_extjson": "{\"d\": {\"$numberDouble\": \"NaN\"}}",
"lossy": true
},
{
"description": "NaN with payload",
"bson": "10000000016400120000000000F87F00",
"extjson": "{\"d\": {\"$numberDouble\": \"NaN\"}}",
"canonical_bson": "10000000016400120000000000F87F00",
"canonical_extjson": "{\"d\": {\"$numberDouble\": \"NaN\"}}",
"relaxed_extjson": "{\"d\": {\"$numberDouble\": \"NaN\"}}",
"lossy": true
},
{
"description": "Inf",
"bson": "10000000016400000000000000F07F00",
"extjson": "{\"d\": {\"$numberDouble\": \"Infinity\"}}"
"canonical_bson": "10000000016400000000000000F07F00",
"canonical_extjson": "{\"d\": {\"$numberDouble\": \"Infinity\"}}",
"relaxed_extjson": "{\"d\": {\"$numberDouble\": \"Infinity\"}}"
},
{
"description": "-Inf",
"bson": "10000000016400000000000000F0FF00",
"extjson": "{\"d\": {\"$numberDouble\": \"-Infinity\"}}"
"canonical_bson": "10000000016400000000000000F0FF00",
"canonical_extjson": "{\"d\": {\"$numberDouble\": \"-Infinity\"}}",
"relaxed_extjson": "{\"d\": {\"$numberDouble\": \"-Infinity\"}}"
}
],
"decodeErrors": [

View File

@ -5,28 +5,33 @@
"valid": [
{
"description": "MinValue",
"bson": "0C0000001069000000008000",
"extjson": "{\"i\" : {\"$numberInt\": \"-2147483648\"}}"
"canonical_bson": "0C0000001069000000008000",
"canonical_extjson": "{\"i\" : {\"$numberInt\": \"-2147483648\"}}",
"relaxed_extjson": "{\"i\" : -2147483648}"
},
{
"description": "MaxValue",
"bson": "0C000000106900FFFFFF7F00",
"extjson": "{\"i\" : {\"$numberInt\": \"2147483647\"}}"
"canonical_bson": "0C000000106900FFFFFF7F00",
"canonical_extjson": "{\"i\" : {\"$numberInt\": \"2147483647\"}}",
"relaxed_extjson": "{\"i\" : 2147483647}"
},
{
"description": "-1",
"bson": "0C000000106900FFFFFFFF00",
"extjson": "{\"i\" : {\"$numberInt\": \"-1\"}}"
"canonical_bson": "0C000000106900FFFFFFFF00",
"canonical_extjson": "{\"i\" : {\"$numberInt\": \"-1\"}}",
"relaxed_extjson": "{\"i\" : -1}"
},
{
"description": "0",
"bson": "0C0000001069000000000000",
"extjson": "{\"i\" : {\"$numberInt\": \"0\"}}"
"canonical_bson": "0C0000001069000000000000",
"canonical_extjson": "{\"i\" : {\"$numberInt\": \"0\"}}",
"relaxed_extjson": "{\"i\" : 0}"
},
{
"description": "1",
"bson": "0C0000001069000100000000",
"extjson": "{\"i\" : {\"$numberInt\": \"1\"}}"
"canonical_bson": "0C0000001069000100000000",
"canonical_extjson": "{\"i\" : {\"$numberInt\": \"1\"}}",
"relaxed_extjson": "{\"i\" : 1}"
}
],
"decodeErrors": [

View File

@ -5,28 +5,33 @@
"valid": [
{
"description": "MinValue",
"bson": "10000000126100000000000000008000",
"extjson": "{\"a\" : {\"$numberLong\" : \"-9223372036854775808\"}}"
"canonical_bson": "10000000126100000000000000008000",
"canonical_extjson": "{\"a\" : {\"$numberLong\" : \"-9223372036854775808\"}}",
"relaxed_extjson": "{\"a\" : -9223372036854775808}"
},
{
"description": "MaxValue",
"bson": "10000000126100FFFFFFFFFFFFFF7F00",
"extjson": "{\"a\" : {\"$numberLong\" : \"9223372036854775807\"}}"
"canonical_bson": "10000000126100FFFFFFFFFFFFFF7F00",
"canonical_extjson": "{\"a\" : {\"$numberLong\" : \"9223372036854775807\"}}",
"relaxed_extjson": "{\"a\" : 9223372036854775807}"
},
{
"description": "-1",
"bson": "10000000126100FFFFFFFFFFFFFFFF00",
"extjson": "{\"a\" : {\"$numberLong\" : \"-1\"}}"
"canonical_bson": "10000000126100FFFFFFFFFFFFFFFF00",
"canonical_extjson": "{\"a\" : {\"$numberLong\" : \"-1\"}}",
"relaxed_extjson": "{\"a\" : -1}"
},
{
"description": "0",
"bson": "10000000126100000000000000000000",
"extjson": "{\"a\" : {\"$numberLong\" : \"0\"}}"
"canonical_bson": "10000000126100000000000000000000",
"canonical_extjson": "{\"a\" : {\"$numberLong\" : \"0\"}}",
"relaxed_extjson": "{\"a\" : 0}"
},
{
"description": "1",
"bson": "10000000126100010000000000000000",
"extjson": "{\"a\" : {\"$numberLong\" : \"1\"}}"
"canonical_bson": "10000000126100010000000000000000",
"canonical_extjson": "{\"a\" : {\"$numberLong\" : \"1\"}}",
"relaxed_extjson": "{\"a\" : 1}"
}
],
"decodeErrors": [

View File

@ -1,12 +1,12 @@
{
"description": "Maxkey type",
"bson_type": "0xFF",
"bson_type": "0x7F",
"test_key": "a",
"valid": [
{
"description": "Maxkey",
"bson": "080000007F610000",
"extjson": "{\"a\" : {\"$maxKey\" : 1}}"
"canonical_bson": "080000007F610000",
"canonical_extjson": "{\"a\" : {\"$maxKey\" : 1}}"
}
]
}

View File

@ -5,8 +5,8 @@
"valid": [
{
"description": "Minkey",
"bson": "08000000FF610000",
"extjson": "{\"a\" : {\"$minKey\" : 1}}"
"canonical_bson": "08000000FF610000",
"canonical_extjson": "{\"a\" : {\"$minKey\" : 1}}"
}
]
}

View File

@ -0,0 +1,15 @@
{
"description": "Multiple types within the same document",
"bson_type": "0x00",
"deprecated": true,
"valid": [
{
"description": "All BSON types",
"canonical_bson": "3B020000075F69640057E193D7A9CC81B4027498B50E53796D626F6C000700000073796D626F6C0002537472696E670007000000737472696E670010496E743332002A00000012496E743634002A0000000000000001446F75626C6500000000000000F0BF0542696E617279001000000003A34C38F7C3ABEDC8A37814A992AB8DB60542696E61727955736572446566696E656400050000008001020304050D436F6465000E00000066756E6374696F6E2829207B7D000F436F64655769746853636F7065001B0000000E00000066756E6374696F6E2829207B7D00050000000003537562646F63756D656E74001200000002666F6F0004000000626172000004417272617900280000001030000100000010310002000000103200030000001033000400000010340005000000001154696D657374616D7000010000002A0000000B5265676578007061747465726E0000094461746574696D6545706F6368000000000000000000094461746574696D65506F73697469766500FFFFFF7F00000000094461746574696D654E656761746976650000000080FFFFFFFF085472756500010846616C736500000C4442506F696E746572000E00000064622E636F6C6C656374696F6E0057E193D7A9CC81B4027498B1034442526566003D0000000224726566000B000000636F6C6C656374696F6E00072469640057FD71E96E32AB4225B723FB02246462000900000064617461626173650000FF4D696E6B6579007F4D61786B6579000A4E756C6C0006556E646566696E65640000",
"converted_bson": "4b020000075f69640057e193d7a9cc81b4027498b50253796d626f6c000700000073796d626f6c0002537472696e670007000000737472696e670010496e743332002a00000012496e743634002a0000000000000001446f75626c6500000000000000f0bf0542696e617279001000000003a34c38f7c3abedc8a37814a992ab8db60542696e61727955736572446566696e656400050000008001020304050d436f6465000e00000066756e6374696f6e2829207b7d000f436f64655769746853636f7065001b0000000e00000066756e6374696f6e2829207b7d00050000000003537562646f63756d656e74001200000002666f6f0004000000626172000004417272617900280000001030000100000010310002000000103200030000001033000400000010340005000000001154696d657374616d7000010000002a0000000b5265676578007061747465726e0000094461746574696d6545706f6368000000000000000000094461746574696d65506f73697469766500ffffff7f00000000094461746574696d654e656761746976650000000080ffffffff085472756500010846616c73650000034442506f696e746572002e0000000224726566000e00000064622e636f6c6c656374696f6e00072469640057e193d7a9cc81b4027498b100034442526566003d0000000224726566000b000000636f6c6c656374696f6e00072469640057fd71e96e32ab4225b723fb02246462000900000064617461626173650000ff4d696e6b6579007f4d61786b6579000a4e756c6c000a556e646566696e65640000",
"canonical_extjson": "{\"_id\": {\"$oid\": \"57e193d7a9cc81b4027498b5\"}, \"Symbol\": {\"$symbol\": \"symbol\"}, \"String\": \"string\", \"Int32\": {\"$numberInt\": \"42\"}, \"Int64\": {\"$numberLong\": \"42\"}, \"Double\": {\"$numberDouble\": \"-1.0\"}, \"Binary\": { \"$binary\" : {\"base64\": \"o0w498Or7cijeBSpkquNtg==\", \"subType\": \"03\"}}, \"BinaryUserDefined\": { \"$binary\" : {\"base64\": \"AQIDBAU=\", \"subType\": \"80\"}}, \"Code\": {\"$code\": \"function() {}\"}, \"CodeWithScope\": {\"$code\": \"function() {}\", \"$scope\": {}}, \"Subdocument\": {\"foo\": \"bar\"}, \"Array\": [{\"$numberInt\": \"1\"}, {\"$numberInt\": \"2\"}, {\"$numberInt\": \"3\"}, {\"$numberInt\": \"4\"}, {\"$numberInt\": \"5\"}], \"Timestamp\": {\"$timestamp\": {\"t\": 42, \"i\": 1}}, \"Regex\": {\"$regularExpression\": {\"pattern\": \"pattern\", \"options\": \"\"}}, \"DatetimeEpoch\": {\"$date\": {\"$numberLong\": \"0\"}}, \"DatetimePositive\": {\"$date\": {\"$numberLong\": \"2147483647\"}}, \"DatetimeNegative\": {\"$date\": {\"$numberLong\": \"-2147483648\"}}, \"True\": true, \"False\": false, \"DBPointer\": {\"$dbPointer\": {\"$ref\": \"db.collection\", \"$id\": {\"$oid\": \"57e193d7a9cc81b4027498b1\"}}}, \"DBRef\": {\"$ref\": \"collection\", \"$id\": {\"$oid\": \"57fd71e96e32ab4225b723fb\"}, \"$db\": \"database\"}, \"Minkey\": {\"$minKey\": 1}, \"Maxkey\": {\"$maxKey\": 1}, \"Null\": null, \"Undefined\": {\"$undefined\": true}}",
"converted_extjson": "{\"_id\": {\"$oid\": \"57e193d7a9cc81b4027498b5\"}, \"Symbol\": \"symbol\", \"String\": \"string\", \"Int32\": {\"$numberInt\": \"42\"}, \"Int64\": {\"$numberLong\": \"42\"}, \"Double\": {\"$numberDouble\": \"-1.0\"}, \"Binary\": { \"$binary\" : {\"base64\": \"o0w498Or7cijeBSpkquNtg==\", \"subType\": \"03\"}}, \"BinaryUserDefined\": { \"$binary\" : {\"base64\": \"AQIDBAU=\", \"subType\": \"80\"}}, \"Code\": {\"$code\": \"function() {}\"}, \"CodeWithScope\": {\"$code\": \"function() {}\", \"$scope\": {}}, \"Subdocument\": {\"foo\": \"bar\"}, \"Array\": [{\"$numberInt\": \"1\"}, {\"$numberInt\": \"2\"}, {\"$numberInt\": \"3\"}, {\"$numberInt\": \"4\"}, {\"$numberInt\": \"5\"}], \"Timestamp\": {\"$timestamp\": {\"t\": 42, \"i\": 1}}, \"Regex\": {\"$regularExpression\": {\"pattern\": \"pattern\", \"options\": \"\"}}, \"DatetimeEpoch\": {\"$date\": {\"$numberLong\": \"0\"}}, \"DatetimePositive\": {\"$date\": {\"$numberLong\": \"2147483647\"}}, \"DatetimeNegative\": {\"$date\": {\"$numberLong\": \"-2147483648\"}}, \"True\": true, \"False\": false, \"DBPointer\": {\"$ref\": \"db.collection\", \"$id\": {\"$oid\": \"57e193d7a9cc81b4027498b1\"}}, \"DBRef\": {\"$ref\": \"collection\", \"$id\": {\"$oid\": \"57fd71e96e32ab4225b723fb\"}, \"$db\": \"database\"}, \"Minkey\": {\"$minKey\": 1}, \"Maxkey\": {\"$maxKey\": 1}, \"Null\": null, \"Undefined\": null}"
}
]
}

View File

@ -4,8 +4,8 @@
"valid": [
{
"description": "All BSON types",
"bson": "3b020000075f69640057e193d7a9cc81b4027498b50e53796d626f6c000700000073796d626f6c0002537472696e670007000000737472696e670010496e743332002a00000012496e743634002a0000000000000001446f75626c6500f6285c8fc23545400542696e617279001000000003a34c38f7c3abedc8a37814a992ab8db60542696e61727955736572446566696e656400050000008001020304050d436f6465000e00000066756e6374696f6e2829207b7d000f436f64655769746853636f7065001b0000000e00000066756e6374696f6e2829207b7d00050000000003537562646f63756d656e74001200000002666f6f0004000000626172000004417272617900280000001030000100000010310002000000103200030000001033000400000010340005000000001154696d657374616d7000010000002a0000000b5265676578007061747465726e0000094461746574696d6545706f6368000000000000000000094461746574696d65506f73697469766500ffffff7f00000000094461746574696d654e656761746976650000000080ffffffff085472756500010846616c736500000c4442506f696e746572000e00000064622e636f6c6c656374696f6e0057e193d7a9cc81b4027498b1034442526566003d0000000224726566000b000000636f6c6c656374696f6e00072469640057fd71e96e32ab4225b723fb02246462000900000064617461626173650000ff4d696e6b6579007f4d61786b6579000a4e756c6c0006556e646566696e65640000",
"extjson": "{\"_id\": {\"$oid\": \"57e193d7a9cc81b4027498b5\"}, \"Symbol\": {\"$symbol\": \"symbol\"}, \"String\": \"string\", \"Int32\": {\"$numberInt\": \"42\"}, \"Int64\": {\"$numberLong\": \"42\"}, \"Double\": {\"$numberDouble\": \"42.42\"}, \"Binary\": {\"$binary\": \"o0w498Or7cijeBSpkquNtg==\", \"$type\": \"03\"}, \"BinaryUserDefined\": {\"$binary\": \"AQIDBAU=\", \"$type\": \"80\"}, \"Code\": {\"$code\": \"function() {}\"}, \"CodeWithScope\": {\"$code\": \"function() {}\", \"$scope\": {}}, \"Subdocument\": {\"foo\": \"bar\"}, \"Array\": [{\"$numberInt\": \"1\"}, {\"$numberInt\": \"2\"}, {\"$numberInt\": \"3\"}, {\"$numberInt\": \"4\"}, {\"$numberInt\": \"5\"}], \"Timestamp\": {\"$timestamp\": \"180388626433\"}, \"Regex\": {\"$regex\": \"pattern\", \"$options\": \"\"}, \"DatetimeEpoch\": {\"$date\": {\"$numberLong\": \"0\"}}, \"DatetimePositive\": {\"$date\": {\"$numberLong\": \"2147483647\"}}, \"DatetimeNegative\": {\"$date\": {\"$numberLong\": \"-2147483648\"}}, \"True\": true, \"False\": false, \"DBPointer\": {\"$dbPointer\": {\"$ref\": \"db.collection\", \"$id\": {\"$oid\": \"57e193d7a9cc81b4027498b1\"}}}, \"DBRef\": {\"$ref\": \"collection\", \"$id\": {\"$oid\": \"57fd71e96e32ab4225b723fb\"}, \"$db\": \"database\"}, \"Minkey\": {\"$minKey\": 1}, \"Maxkey\": {\"$maxKey\": 1}, \"Null\": null, \"Undefined\": {\"$undefined\": true}}"
"canonical_bson": "F4010000075F69640057E193D7A9CC81B4027498B502537472696E670007000000737472696E670010496E743332002A00000012496E743634002A0000000000000001446F75626C6500000000000000F0BF0542696E617279001000000003A34C38F7C3ABEDC8A37814A992AB8DB60542696E61727955736572446566696E656400050000008001020304050D436F6465000E00000066756E6374696F6E2829207B7D000F436F64655769746853636F7065001B0000000E00000066756E6374696F6E2829207B7D00050000000003537562646F63756D656E74001200000002666F6F0004000000626172000004417272617900280000001030000100000010310002000000103200030000001033000400000010340005000000001154696D657374616D7000010000002A0000000B5265676578007061747465726E0000094461746574696D6545706F6368000000000000000000094461746574696D65506F73697469766500FFFFFF7F00000000094461746574696D654E656761746976650000000080FFFFFFFF085472756500010846616C73650000034442526566003D0000000224726566000B000000636F6C6C656374696F6E00072469640057FD71E96E32AB4225B723FB02246462000900000064617461626173650000FF4D696E6B6579007F4D61786B6579000A4E756C6C0000",
"canonical_extjson": "{\"_id\": {\"$oid\": \"57e193d7a9cc81b4027498b5\"}, \"String\": \"string\", \"Int32\": {\"$numberInt\": \"42\"}, \"Int64\": {\"$numberLong\": \"42\"}, \"Double\": {\"$numberDouble\": \"-1.0\"}, \"Binary\": { \"$binary\" : {\"base64\": \"o0w498Or7cijeBSpkquNtg==\", \"subType\": \"03\"}}, \"BinaryUserDefined\": { \"$binary\" : {\"base64\": \"AQIDBAU=\", \"subType\": \"80\"}}, \"Code\": {\"$code\": \"function() {}\"}, \"CodeWithScope\": {\"$code\": \"function() {}\", \"$scope\": {}}, \"Subdocument\": {\"foo\": \"bar\"}, \"Array\": [{\"$numberInt\": \"1\"}, {\"$numberInt\": \"2\"}, {\"$numberInt\": \"3\"}, {\"$numberInt\": \"4\"}, {\"$numberInt\": \"5\"}], \"Timestamp\": {\"$timestamp\": {\"t\": 42, \"i\": 1}}, \"Regex\": {\"$regularExpression\": {\"pattern\": \"pattern\", \"options\": \"\"}}, \"DatetimeEpoch\": {\"$date\": {\"$numberLong\": \"0\"}}, \"DatetimePositive\": {\"$date\": {\"$numberLong\": \"2147483647\"}}, \"DatetimeNegative\": {\"$date\": {\"$numberLong\": \"-2147483648\"}}, \"True\": true, \"False\": false, \"DBRef\": {\"$ref\": \"collection\", \"$id\": {\"$oid\": \"57fd71e96e32ab4225b723fb\"}, \"$db\": \"database\"}, \"Minkey\": {\"$minKey\": 1}, \"Maxkey\": {\"$maxKey\": 1}, \"Null\": null}"
}
]
}

View File

@ -5,8 +5,8 @@
"valid": [
{
"description": "Null",
"bson": "080000000A610000",
"extjson": "{\"a\" : null}"
"canonical_bson": "080000000A610000",
"canonical_extjson": "{\"a\" : null}"
}
]
}

View File

@ -5,18 +5,18 @@
"valid": [
{
"description": "All zeroes",
"bson": "1400000007610000000000000000000000000000",
"extjson": "{\"a\" : {\"$oid\" : \"000000000000000000000000\"}}"
"canonical_bson": "1400000007610000000000000000000000000000",
"canonical_extjson": "{\"a\" : {\"$oid\" : \"000000000000000000000000\"}}"
},
{
"description": "All ones",
"bson": "14000000076100FFFFFFFFFFFFFFFFFFFFFFFF00",
"extjson": "{\"a\" : {\"$oid\" : \"ffffffffffffffffffffffff\"}}"
"canonical_bson": "14000000076100FFFFFFFFFFFFFFFFFFFFFFFF00",
"canonical_extjson": "{\"a\" : {\"$oid\" : \"ffffffffffffffffffffffff\"}}"
},
{
"description": "Random",
"bson": "1400000007610056E1FC72E0C917E9C471416100",
"extjson": "{\"a\" : {\"$oid\" : \"56e1fc72e0c917e9c4714161\"}}"
"canonical_bson": "1400000007610056E1FC72E0C917E9C471416100",
"canonical_extjson": "{\"a\" : {\"$oid\" : \"56e1fc72e0c917e9c4714161\"}}"
}
],
"decodeErrors": [

View File

@ -5,29 +5,51 @@
"valid": [
{
"description": "empty regex with no options",
"bson": "0A0000000B6100000000",
"extjson": "{\"a\" : {\"$regex\" : \"\", \"$options\" : \"\"}}"
"canonical_bson": "0A0000000B6100000000",
"canonical_extjson": "{\"a\" : {\"$regularExpression\" : { \"pattern\": \"\", \"options\" : \"\"}}}"
},
{
"description": "regex without options",
"bson": "0D0000000B6100616263000000",
"extjson": "{\"a\" : {\"$regex\" : \"abc\", \"$options\" : \"\"}}"
"canonical_bson": "0D0000000B6100616263000000",
"canonical_extjson": "{\"a\" : {\"$regularExpression\" : { \"pattern\": \"abc\", \"options\" : \"\"}}}"
},
{
"description": "regex with options",
"bson": "0F0000000B610061626300696D0000",
"extjson": "{\"a\" : {\"$regex\" : \"abc\", \"$options\" : \"im\"}}"
"canonical_bson": "0F0000000B610061626300696D0000",
"canonical_extjson": "{\"a\" : {\"$regularExpression\" : { \"pattern\": \"abc\", \"options\" : \"im\"}}}"
},
{
"description": "regex with options (keys reversed)",
"canonical_bson": "0F0000000B610061626300696D0000",
"canonical_extjson": "{\"a\" : {\"$regularExpression\" : { \"pattern\": \"abc\", \"options\" : \"im\"}}}",
"degenerate_extjson": "{\"a\" : {\"$regularExpression\" : {\"options\" : \"im\", \"pattern\": \"abc\"}}}"
},
{
"description": "regex with slash",
"bson": "110000000B610061622F636400696D0000",
"extjson": "{\"a\" : {\"$regex\" : \"ab/cd\", \"$options\" : \"im\"}}"
"canonical_bson": "110000000B610061622F636400696D0000",
"canonical_extjson": "{\"a\" : {\"$regularExpression\" : { \"pattern\": \"ab/cd\", \"options\" : \"im\"}}}"
},
{
"description": "flags not alphabetized",
"bson": "100000000B6100616263006D69780000",
"degenerate_bson": "100000000B6100616263006D69780000",
"canonical_bson": "100000000B610061626300696D780000",
"extjson": "{\"a\" : {\"$regex\" : \"abc\", \"$options\" : \"imx\"}}"
"canonical_extjson": "{\"a\" : {\"$regularExpression\" : { \"pattern\": \"abc\", \"options\" : \"imx\"}}}",
"degenerate_extjson": "{\"a\" : {\"$regularExpression\" : { \"pattern\": \"abc\", \"options\" : \"mix\"}}}"
},
{
"description" : "Required escapes",
"canonical_bson" : "100000000B610061625C226162000000",
"canonical_extjson": "{\"a\" : {\"$regularExpression\" : { \"pattern\": \"ab\\\\\\\"ab\", \"options\" : \"\"}}}"
},
{
"description" : "Regular expression as value of $regex query operator",
"canonical_bson" : "180000000B247265676578007061747465726E0069780000",
"canonical_extjson": "{\"$regex\" : {\"$regularExpression\" : { \"pattern\": \"pattern\", \"options\" : \"ix\"}}}"
},
{
"description" : "Regular expression as value of $regex query operator with $options",
"canonical_bson" : "270000000B247265676578007061747465726E000002246F7074696F6E73000300000069780000",
"canonical_extjson": "{\"$regex\" : {\"$regularExpression\" : { \"pattern\": \"pattern\", \"options\" : \"\"}}, \"$options\" : \"ix\"}"
}
],
"decodeErrors": [

View File

@ -5,33 +5,38 @@
"valid": [
{
"description": "Empty string",
"bson": "0D000000026100010000000000",
"extjson": "{\"a\" : \"\"}"
"canonical_bson": "0D000000026100010000000000",
"canonical_extjson": "{\"a\" : \"\"}"
},
{
"description": "Single character",
"bson": "0E00000002610002000000620000",
"extjson": "{\"a\" : \"b\"}"
"canonical_bson": "0E00000002610002000000620000",
"canonical_extjson": "{\"a\" : \"b\"}"
},
{
"description": "Multi-character",
"bson": "190000000261000D0000006162616261626162616261620000",
"extjson": "{\"a\" : \"abababababab\"}"
"canonical_bson": "190000000261000D0000006162616261626162616261620000",
"canonical_extjson": "{\"a\" : \"abababababab\"}"
},
{
"description": "two-byte UTF-8 (\u00e9)",
"bson": "190000000261000D000000C3A9C3A9C3A9C3A9C3A9C3A90000",
"extjson": "{\"a\" : \"\\u00e9\\u00e9\\u00e9\\u00e9\\u00e9\\u00e9\"}"
"canonical_bson": "190000000261000D000000C3A9C3A9C3A9C3A9C3A9C3A90000",
"canonical_extjson": "{\"a\" : \"\\u00e9\\u00e9\\u00e9\\u00e9\\u00e9\\u00e9\"}"
},
{
"description": "three-byte UTF-8 (\u2606)",
"bson": "190000000261000D000000E29886E29886E29886E298860000",
"extjson": "{\"a\" : \"\\u2606\\u2606\\u2606\\u2606\"}"
"canonical_bson": "190000000261000D000000E29886E29886E29886E298860000",
"canonical_extjson": "{\"a\" : \"\\u2606\\u2606\\u2606\\u2606\"}"
},
{
"description": "Embedded nulls",
"bson": "190000000261000D0000006162006261620062616261620000",
"extjson": "{\"a\" : \"ab\\u0000bab\\u0000babab\"}"
"canonical_bson": "190000000261000D0000006162006261620062616261620000",
"canonical_extjson": "{\"a\" : \"ab\\u0000bab\\u0000babab\"}"
},
{
"description": "Required escapes",
"canonical_bson" : "320000000261002600000061625C220102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F61620000",
"canonical_extjson" : "{\"a\":\"ab\\\\\\\"\\u0001\\u0002\\u0003\\u0004\\u0005\\u0006\\u0007\\b\\t\\n\\u000b\\f\\r\\u000e\\u000f\\u0010\\u0011\\u0012\\u0013\\u0014\\u0015\\u0016\\u0017\\u0018\\u0019\\u001a\\u001b\\u001c\\u001d\\u001e\\u001fab\"}"
}
],
"decodeErrors": [

View File

@ -6,33 +6,45 @@
"valid": [
{
"description": "Empty string",
"bson": "0D0000000E6100010000000000",
"extjson": "{\"a\": {\"$symbol\": \"\"}}"
"canonical_bson": "0D0000000E6100010000000000",
"canonical_extjson": "{\"a\": {\"$symbol\": \"\"}}",
"converted_bson": "0D000000026100010000000000",
"converted_extjson": "{\"a\": \"\"}"
},
{
"description": "Single character",
"bson": "0E0000000E610002000000620000",
"extjson": "{\"a\": {\"$symbol\": \"b\"}}"
"canonical_bson": "0E0000000E610002000000620000",
"canonical_extjson": "{\"a\": {\"$symbol\": \"b\"}}",
"converted_bson": "0E00000002610002000000620000",
"converted_extjson": "{\"a\": \"b\"}"
},
{
"description": "Multi-character",
"bson": "190000000E61000D0000006162616261626162616261620000",
"extjson": "{\"a\": {\"$symbol\": \"abababababab\"}}"
"canonical_bson": "190000000E61000D0000006162616261626162616261620000",
"canonical_extjson": "{\"a\": {\"$symbol\": \"abababababab\"}}",
"converted_bson": "190000000261000D0000006162616261626162616261620000",
"converted_extjson": "{\"a\": \"abababababab\"}"
},
{
"description": "two-byte UTF-8 (\u00e9)",
"bson": "190000000E61000D000000C3A9C3A9C3A9C3A9C3A9C3A90000",
"extjson": "{\"a\": {\"$symbol\": \"éééééé\"}}"
"canonical_bson": "190000000E61000D000000C3A9C3A9C3A9C3A9C3A9C3A90000",
"canonical_extjson": "{\"a\": {\"$symbol\": \"éééééé\"}}",
"converted_bson": "190000000261000D000000C3A9C3A9C3A9C3A9C3A9C3A90000",
"converted_extjson": "{\"a\": \"éééééé\"}"
},
{
"description": "three-byte UTF-8 (\u2606)",
"bson": "190000000E61000D000000E29886E29886E29886E298860000",
"extjson": "{\"a\": {\"$symbol\": \"☆☆☆☆\"}}"
"canonical_bson": "190000000E61000D000000E29886E29886E29886E298860000",
"canonical_extjson": "{\"a\": {\"$symbol\": \"☆☆☆☆\"}}",
"converted_bson": "190000000261000D000000E29886E29886E29886E298860000",
"converted_extjson": "{\"a\": \"☆☆☆☆\"}"
},
{
"description": "Embedded nulls",
"bson": "190000000E61000D0000006162006261620062616261620000",
"extjson": "{\"a\": {\"$symbol\": \"ab\\u0000bab\\u0000babab\"}}"
"canonical_bson": "190000000E61000D0000006162006261620062616261620000",
"canonical_extjson": "{\"a\": {\"$symbol\": \"ab\\u0000bab\\u0000babab\"}}",
"converted_bson": "190000000261000D0000006162006261620062616261620000",
"converted_extjson": "{\"a\": \"ab\\u0000bab\\u0000babab\"}"
}
],
"decodeErrors": [

View File

@ -5,8 +5,19 @@
"valid": [
{
"description": "Timestamp: (123456789, 42)",
"bson": "100000001161002A00000015CD5B0700",
"extjson": "{\"a\" : {\"$timestamp\" : \"530242871224172586\"}}"
"canonical_bson": "100000001161002A00000015CD5B0700",
"canonical_extjson": "{\"a\" : {\"$timestamp\" : {\"t\" : 123456789, \"i\" : 42} } }"
},
{
"description": "Timestamp: (123456789, 42) (keys reversed)",
"canonical_bson": "100000001161002A00000015CD5B0700",
"canonical_extjson": "{\"a\" : {\"$timestamp\" : {\"t\" : 123456789, \"i\" : 42} } }",
"degenerate_extjson": "{\"a\" : {\"$timestamp\" : {\"i\" : 42, \"t\" : 123456789} } }"
},
{
"description": "Timestamp with high-order bit set on both seconds and increment",
"canonical_bson": "10000000116100FFFFFFFFFFFFFFFF00",
"canonical_extjson": "{\"a\" : {\"$timestamp\" : {\"t\" : 4294967295, \"i\" : 4294967295} } }"
}
],
"decodeErrors": [

View File

@ -4,18 +4,8 @@
"valid": [
{
"description": "Document with keys that start with $",
"bson": "0f00000010246b6579002a00000000",
"extjson": "{\"$key\": {\"$numberInt\": \"42\"}}"
},
{
"description": "Document that resembles extended JSON, but with extra keys",
"bson": "3f00000002247265676578000c0000006e6f742d612d72656765780002246f7074696f6e7300020000006900022462616e616e6100050000007065656c0000",
"extjson": "{\"$regex\": \"not-a-regex\", \"$options\": \"i\", \"$banana\": \"peel\"}"
},
{
"description": "Document that resembles extended JSON, but with missing keys",
"bson": "1a000000022462696e6172790008000000616263646566670000",
"extjson": "{\"$binary\": \"abcdefg\"}"
"canonical_bson": "0F00000010246B6579002A00000000",
"canonical_extjson": "{\"$key\": {\"$numberInt\": \"42\"}}"
}
],
"decodeErrors": [
@ -75,5 +65,172 @@
"description": "Document truncated mid-key",
"bson": "1200000002666F"
}
],
"parseErrors": [
{
"description" : "Bad $regularExpression (extra field)",
"string" : "{\"a\" : \"$regularExpression\": {\"pattern\": \"abc\", \"options\": \"\", \"unrelated\": true}}}"
},
{
"description" : "Bad $regularExpression (missing options field)",
"string" : "{\"a\" : \"$regularExpression\": {\"pattern\": \"abc\"}}}"
},
{
"description": "Bad $regularExpression (pattern is number, not string)",
"string": "{\"x\" : {\"$regularExpression\" : { \"pattern\": 42, \"$options\" : \"\"}}}"
},
{
"description": "Bad $regularExpression (options are number, not string)",
"string": "{\"x\" : {\"$regularExpression\" : { \"pattern\": \"a\", \"$options\" : 0}}}"
},
{
"description" : "Bad $regularExpression (missing pattern field)",
"string" : "{\"a\" : \"$regularExpression\": {\"options\":\"ix\"}}}"
},
{
"description": "Bad $oid (number, not string)",
"string": "{\"a\" : {\"$oid\" : 42}}"
},
{
"description": "Bad $oid (extra field)",
"string": "{\"a\" : {\"$oid\" : \"56e1fc72e0c917e9c4714161\", \"unrelated\": true}}"
},
{
"description": "Bad $numberInt (number, not string)",
"string": "{\"a\" : {\"$numberInt\" : 42}}"
},
{
"description": "Bad $numberInt (extra field)",
"string": "{\"a\" : {\"$numberInt\" : \"42\", \"unrelated\": true}}"
},
{
"description": "Bad $numberLong (number, not string)",
"string": "{\"a\" : {\"$numberLong\" : 42}}"
},
{
"description": "Bad $numberLong (extra field)",
"string": "{\"a\" : {\"$numberLong\" : \"42\", \"unrelated\": true}}"
},
{
"description": "Bad $numberDouble (number, not string)",
"string": "{\"a\" : {\"$numberDouble\" : 42}}"
},
{
"description": "Bad $numberDouble (extra field)",
"string": "{\"a\" : {\"$numberDouble\" : \".1\", \"unrelated\": true}}"
},
{
"description": "Bad $numberDecimal (number, not string)",
"string": "{\"a\" : {\"$numberDecimal\" : 42}}"
},
{
"description": "Bad $numberDecimal (extra field)",
"string": "{\"a\" : {\"$numberDecimal\" : \".1\", \"unrelated\": true}}"
},
{
"description": "Bad $binary (binary is number, not string)",
"string": "{\"x\" : {\"$binary\" : {\"base64\" : 0, \"subType\" : \"00\"}}}"
},
{
"description": "Bad $binary (type is number, not string)",
"string": "{\"x\" : {\"$binary\" : {\"base64\" : \"\", \"subType\" : 0}}}"
},
{
"description": "Bad $binary (missing $type)",
"string": "{\"x\" : {\"$binary\" : {\"base64\" : \"//8=\"}}}"
},
{
"description": "Bad $binary (missing $binary)",
"string": "{\"x\" : {\"$binary\" : {\"subType\" : \"00\"}}}"
},
{
"description": "Bad $binary (extra field)",
"string": "{\"x\" : {\"$binary\" : {\"base64\" : \"//8=\", \"subType\" : 0, \"unrelated\": true}}}"
},
{
"description": "Bad $code (type is number, not string)",
"string": "{\"a\" : {\"$code\" : 42}}"
},
{
"description": "Bad $code (extra field)",
"string": "{\"a\" : {\"$code\" : \"\", \"unrelated\": true}}"
},
{
"description": "Bad $code with $scope (scope is number, not doc)",
"string": "{\"x\" : {\"$code\" : \"\", \"$scope\" : 42}}"
},
{
"description": "Bad $timestamp (type is number, not doc)",
"string": "{\"a\" : {\"$timestamp\" : 42} }"
},
{
"description": "Bad $timestamp ('t' type is string, not number)",
"string": "{\"a\" : {\"$timestamp\" : {\"t\" : \"123456789\", \"i\" : 42} } }"
},
{
"description": "Bad $timestamp ('i' type is string, not number)",
"string": "{\"a\" : {\"$timestamp\" : {\"t\" : 123456789, \"i\" : \"42\"} } }"
},
{
"description": "Bad $timestamp (extra field at same level as $timestamp)",
"string": "{\"a\" : {\"$timestamp\" : {\"t\" : \"123456789\", \"i\" : \"42\"}, \"unrelated\": true } }"
},
{
"description": "Bad $timestamp (extra field at same level as t and i)",
"string": "{\"a\" : {\"$timestamp\" : {\"t\" : \"123456789\", \"i\" : \"42\", \"unrelated\": true} } }"
},
{
"description": "Bad $timestamp (missing t)",
"string": "{\"a\" : {\"$timestamp\" : {\"i\" : \"42\"} } }"
},
{
"description": "Bad $timestamp (missing i)",
"string": "{\"a\" : {\"$timestamp\" : {\"t\" : \"123456789\"} } }"
},
{
"description": "Bad $date (number, not string or hash)",
"string": "{\"a\" : {\"$date\" : 42}}"
},
{
"description": "Bad $date (extra field)",
"string": "{\"a\" : {\"$date\" : {\"$numberLong\" : \"1356351330501\"}, \"unrelated\": true}}"
},
{
"description": "Bad DBRef (ref is number, not string)",
"string": "{\"x\" : {\"$ref\" : 42, \"$id\" : \"abc\"}}"
},
{
"description": "Bad DBRef (db is number, not string)",
"string": "{\"x\" : {\"$ref\" : \"a\", \"$id\" : \"abc\", \"$db\" : 42}}"
},
{
"description": "Bad $minKey (boolean, not integer)",
"string": "{\"a\" : {\"$minKey\" : true}}"
},
{
"description": "Bad $minKey (wrong integer)",
"string": "{\"a\" : {\"$minKey\" : 0}}"
},
{
"description": "Bad $minKey (extra field)",
"string": "{\"a\" : {\"$minKey\" : 1, \"unrelated\": true}}"
},
{
"description": "Bad $maxKey (boolean, not integer)",
"string": "{\"a\" : {\"$maxKey\" : true}}"
},
{
"description": "Bad $maxKey (wrong integer)",
"string": "{\"a\" : {\"$maxKey\" : 0}}"
},
{
"description": "Bad $maxKey (extra field)",
"string": "{\"a\" : {\"$maxKey\" : 1, \"unrelated\": true}}"
},
{
"description": "Bad DBpointer (extra field)",
"string": "{\"a\": {\"$dbPointer\": {\"a\": {\"$numberInt\": \"1\"}, \"$id\": {\"$oid\": \"56e1fc72e0c917e9c4714161\"}, \"c\": {\"$numberInt\": \"2\"}, \"$ref\": \"b\"}}}"
}
]
}

View File

@ -6,8 +6,10 @@
"valid": [
{
"description": "Undefined",
"bson": "0800000006610000",
"extjson": "{\"a\" : {\"$undefined\" : true}}"
"canonical_bson": "0800000006610000",
"canonical_extjson": "{\"a\" : {\"$undefined\" : true}}",
"converted_bson": "080000000A610000",
"converted_extjson": "{\"a\" : null}"
}
]
}

View File

@ -1,317 +0,0 @@
{
"description": "Decimal128",
"bson_type": "0x13",
"test_key": "d",
"valid": [
{
"description": "Special - Canonical NaN",
"bson": "180000001364000000000000000000000000000000007C00",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"NaN\"}}"
},
{
"description": "Special - Negative NaN",
"bson": "18000000136400000000000000000000000000000000FC00",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"NaN\"}}",
"lossy": true
},
{
"description": "Special - Negative NaN",
"bson": "18000000136400000000000000000000000000000000FC00",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"NaN\"}}",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"-NaN\"}}",
"lossy": true
},
{
"description": "Special - Canonical SNaN",
"bson": "180000001364000000000000000000000000000000007E00",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"NaN\"}}",
"lossy": true
},
{
"description": "Special - Negative SNaN",
"bson": "18000000136400000000000000000000000000000000FE00",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"NaN\"}}",
"lossy": true
},
{
"description": "Special - NaN with a payload",
"bson": "180000001364001200000000000000000000000000007E00",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"NaN\"}}",
"lossy": true
},
{
"description": "Special - Canonical Positive Infinity",
"bson": "180000001364000000000000000000000000000000007800",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"Infinity\"}}"
},
{
"description": "Special - Canonical Negative Infinity",
"bson": "18000000136400000000000000000000000000000000F800",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"-Infinity\"}}"
},
{
"description": "Special - Invalid representation treated as 0",
"bson": "180000001364000000000000000000000000000000106C00",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"0\"}}",
"lossy": true
},
{
"description": "Special - Invalid representation treated as -0",
"bson": "18000000136400DCBA9876543210DEADBEEF00000010EC00",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"-0\"}}",
"lossy": true
},
{
"description": "Special - Invalid representation treated as 0E3",
"bson": "18000000136400FFFFFFFFFFFFFFFFFFFFFFFFFFFF116C00",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"0E+3\"}}",
"lossy": true
},
{
"description": "Regular - Adjusted Exponent Limit",
"bson": "18000000136400F2AF967ED05C82DE3297FF6FDE3CF22F00",
"extjson": "{\"d\": { \"$numberDecimal\": \"0.000001234567890123456789012345678901234\" }}"
},
{
"description": "Regular - Smallest",
"bson": "18000000136400D204000000000000000000000000343000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"0.001234\"}}"
},
{
"description": "Regular - Smallest with Trailing Zeros",
"bson": "1800000013640040EF5A07000000000000000000002A3000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"0.00123400000\"}}"
},
{
"description": "Regular - 0.1",
"bson": "1800000013640001000000000000000000000000003E3000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"0.1\"}}"
},
{
"description": "Regular - 0.1234567890123456789012345678901234",
"bson": "18000000136400F2AF967ED05C82DE3297FF6FDE3CFC2F00",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"0.1234567890123456789012345678901234\"}}"
},
{
"description": "Regular - 0",
"bson": "180000001364000000000000000000000000000000403000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"0\"}}"
},
{
"description": "Regular - -0",
"bson": "18000000136400000000000000000000000000000040B000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"-0\"}}"
},
{
"description": "Regular - -0.0",
"bson": "1800000013640000000000000000000000000000003EB000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"-0.0\"}}"
},
{
"description": "Regular - 2",
"bson": "180000001364000200000000000000000000000000403000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"2\"}}"
},
{
"description": "Regular - 2.000",
"bson": "18000000136400D0070000000000000000000000003A3000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"2.000\"}}"
},
{
"description": "Regular - Largest",
"bson": "18000000136400F2AF967ED05C82DE3297FF6FDE3C403000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"1234567890123456789012345678901234\"}}"
},
{
"description": "Scientific - Tiniest",
"bson": "18000000136400FFFFFFFF638E8D37C087ADBE09ED010000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"9.999999999999999999999999999999999E-6143\"}}"
},
{
"description": "Scientific - Tiny",
"bson": "180000001364000100000000000000000000000000000000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"1E-6176\"}}"
},
{
"description": "Scientific - Negative Tiny",
"bson": "180000001364000100000000000000000000000000008000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"-1E-6176\"}}"
},
{
"description": "Scientific - Adjusted Exponent Limit",
"bson": "18000000136400F2AF967ED05C82DE3297FF6FDE3CF02F00",
"extjson": "{\"d\": { \"$numberDecimal\": \"1.234567890123456789012345678901234E-7\" }}"
},
{
"description": "Scientific - Fractional",
"bson": "1800000013640064000000000000000000000000002CB000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"-1.00E-8\"}}"
},
{
"description": "Scientific - 0 with Exponent",
"bson": "180000001364000000000000000000000000000000205F00",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"0E+6000\"}}"
},
{
"description": "Scientific - 0 with Negative Exponent",
"bson": "1800000013640000000000000000000000000000007A2B00",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"0E-611\"}}"
},
{
"description": "Scientific - No Decimal with Signed Exponent",
"bson": "180000001364000100000000000000000000000000463000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"1E+3\"}}"
},
{
"description": "Scientific - Trailing Zero",
"bson": "180000001364001A04000000000000000000000000423000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"1.050E+4\"}}"
},
{
"description": "Scientific - With Decimal",
"bson": "180000001364006900000000000000000000000000423000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"1.05E+3\"}}"
},
{
"description": "Scientific - Full",
"bson": "18000000136400FFFFFFFFFFFFFFFFFFFFFFFFFFFF403000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"5192296858534827628530496329220095\"}}"
},
{
"description": "Scientific - Large",
"bson": "18000000136400000000000A5BC138938D44C64D31FE5F00",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"1.000000000000000000000000000000000E+6144\"}}"
},
{
"description": "Scientific - Largest",
"bson": "18000000136400FFFFFFFF638E8D37C087ADBE09EDFF5F00",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"9.999999999999999999999999999999999E+6144\"}}"
},
{
"description": "Non-Canonical Parsing - Exponent Normalization",
"bson": "1800000013640064000000000000000000000000002CB000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"-100E-10\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"-1.00E-8\"}}"
},
{
"description": "Non-Canonical Parsing - Unsigned Positive Exponent",
"bson": "180000001364000100000000000000000000000000463000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"1E3\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1E+3\"}}"
},
{
"description": "Non-Canonical Parsing - Lowercase Exponent Identifier",
"bson": "180000001364000100000000000000000000000000463000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"1e+3\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1E+3\"}}"
},
{
"description": "Non-Canonical Parsing - Long Significand with Exponent",
"bson": "1800000013640079D9E0F9763ADA429D0200000000583000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"12345689012345789012345E+12\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1.2345689012345789012345E+34\"}}"
},
{
"description": "Non-Canonical Parsing - Positive Sign",
"bson": "18000000136400F2AF967ED05C82DE3297FF6FDE3C403000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"+1234567890123456789012345678901234\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1234567890123456789012345678901234\"}}"
},
{
"description": "Non-Canonical Parsing - Long Decimal String",
"bson": "180000001364000100000000000000000000000000722800",
"extjson": "{\"d\" : {\"$numberDecimal\" : \".000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1E-999\"}}"
},
{
"description": "Non-Canonical Parsing - nan",
"bson": "180000001364000000000000000000000000000000007C00",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"nan\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"NaN\"}}"
},
{
"description": "Non-Canonical Parsing - nAn",
"bson": "180000001364000000000000000000000000000000007C00",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"nAn\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"NaN\"}}"
},
{
"description": "Non-Canonical Parsing - +infinity",
"bson": "180000001364000000000000000000000000000000007800",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"+infinity\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"Infinity\"}}"
},
{
"description": "Non-Canonical Parsing - infinity",
"bson": "180000001364000000000000000000000000000000007800",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"infinity\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"Infinity\"}}"
},
{
"description": "Non-Canonical Parsing - infiniTY",
"bson": "180000001364000000000000000000000000000000007800",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"infiniTY\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"Infinity\"}}"
},
{
"description": "Non-Canonical Parsing - inf",
"bson": "180000001364000000000000000000000000000000007800",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"inf\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"Infinity\"}}"
},
{
"description": "Non-Canonical Parsing - inF",
"bson": "180000001364000000000000000000000000000000007800",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"inF\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"Infinity\"}}"
},
{
"description": "Non-Canonical Parsing - -infinity",
"bson": "18000000136400000000000000000000000000000000F800",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"-infinity\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"-Infinity\"}}"
},
{
"description": "Non-Canonical Parsing - -infiniTy",
"bson": "18000000136400000000000000000000000000000000F800",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"-infiniTy\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"-Infinity\"}}"
},
{
"description": "Non-Canonical Parsing - -Inf",
"bson": "18000000136400000000000000000000000000000000F800",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"-Infinity\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"-Infinity\"}}"
},
{
"description": "Non-Canonical Parsing - -inf",
"bson": "18000000136400000000000000000000000000000000F800",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"-inf\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"-Infinity\"}}"
},
{
"description": "Non-Canonical Parsing - -inF",
"bson": "18000000136400000000000000000000000000000000F800",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"-inF\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"-Infinity\"}}"
},
{
"description": "Rounded Subnormal number",
"bson": "180000001364000100000000000000000000000000000000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"10E-6177\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1E-6176\"}}"
},
{
"description": "Clamped",
"bson": "180000001364000a00000000000000000000000000fe5f00",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"1E6112\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1.0E+6112\"}}"
},
{
"description": "Exact rounding",
"bson": "18000000136400000000000a5bc138938d44c64d31cc3700",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\"}}",
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1.000000000000000000000000000000000E+999\"}}"
}
]
}

View File

@ -1,793 +0,0 @@
{
"description": "Decimal128",
"bson_type": "0x13",
"test_key": "d",
"valid": [
{
"description": "[decq021] Normality",
"bson": "18000000136400F2AF967ED05C82DE3297FF6FDE3C40B000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"-1234567890123456789012345678901234\"}}"
},
{
"description": "[decq823] values around [u]int32 edges (zeros done earlier)",
"bson": "18000000136400010000800000000000000000000040B000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"-2147483649\"}}"
},
{
"description": "[decq822] values around [u]int32 edges (zeros done earlier)",
"bson": "18000000136400000000800000000000000000000040B000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"-2147483648\"}}"
},
{
"description": "[decq821] values around [u]int32 edges (zeros done earlier)",
"bson": "18000000136400FFFFFF7F0000000000000000000040B000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"-2147483647\"}}"
},
{
"description": "[decq820] values around [u]int32 edges (zeros done earlier)",
"bson": "18000000136400FEFFFF7F0000000000000000000040B000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"-2147483646\"}}"
},
{
"description": "[decq152] fold-downs (more below)",
"bson": "18000000136400393000000000000000000000000040B000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"-12345\"}}"
},
{
"description": "[decq154] fold-downs (more below)",
"bson": "18000000136400D20400000000000000000000000040B000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"-1234\"}}"
},
{
"description": "[decq006] derivative canonical plain strings",
"bson": "18000000136400EE0200000000000000000000000040B000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"-750\"}}"
},
{
"description": "[decq164] fold-downs (more below)",
"bson": "1800000013640039300000000000000000000000003CB000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"-123.45\"}}"
},
{
"description": "[decq156] fold-downs (more below)",
"bson": "180000001364007B0000000000000000000000000040B000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"-123\"}}"
},
{
"description": "[decq008] derivative canonical plain strings",
"bson": "18000000136400EE020000000000000000000000003EB000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"-75.0\"}}"
},
{
"description": "[decq158] fold-downs (more below)",
"bson": "180000001364000C0000000000000000000000000040B000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"-12\"}}"
},
{
"description": "[decq122] Nmax and similar",
"bson": "18000000136400FFFFFFFF638E8D37C087ADBE09EDFFDF00",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"-9.999999999999999999999999999999999E+6144\"}}"
},
{
"description": "[decq002] (mostly derived from the Strawman 4 document and examples)",
"bson": "18000000136400EE020000000000000000000000003CB000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"-7.50\"}}"
},
{
"description": "[decq004] derivative canonical plain strings",
"bson": "18000000136400EE0200000000000000000000000042B000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"-7.50E+3\"}}"
},
{
"description": "[decq018] derivative canonical plain strings",
"bson": "18000000136400EE020000000000000000000000002EB000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"-7.50E-7\"}}"
},
{
"description": "[decq125] Nmax and similar",
"bson": "18000000136400F2AF967ED05C82DE3297FF6FDE3CFEDF00",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"-1.234567890123456789012345678901234E+6144\"}}"
},
{
"description": "[decq131] fold-downs (more below)",
"bson": "18000000136400000000807F1BCF85B27059C8A43CFEDF00",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"-1.230000000000000000000000000000000E+6144\"}}"
},
{
"description": "[decq162] fold-downs (more below)",
"bson": "180000001364007B000000000000000000000000003CB000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"-1.23\"}}"
},
{
"description": "[decq176] Nmin and below",
"bson": "18000000136400010000000A5BC138938D44C64D31008000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"-1.000000000000000000000000000000001E-6143\"}}"
},
{
"description": "[decq174] Nmin and below",
"bson": "18000000136400000000000A5BC138938D44C64D31008000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"-1.000000000000000000000000000000000E-6143\"}}"
},
{
"description": "[decq133] fold-downs (more below)",
"bson": "18000000136400000000000A5BC138938D44C64D31FEDF00",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"-1.000000000000000000000000000000000E+6144\"}}"
},
{
"description": "[decq160] fold-downs (more below)",
"bson": "18000000136400010000000000000000000000000040B000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"-1\"}}"
},
{
"description": "[decq172] Nmin and below",
"bson": "180000001364000100000000000000000000000000428000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"-1E-6143\"}}"
},
{
"description": "[decq010] derivative canonical plain strings",
"bson": "18000000136400EE020000000000000000000000003AB000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"-0.750\"}}"
},
{
"description": "[decq012] derivative canonical plain strings",
"bson": "18000000136400EE0200000000000000000000000038B000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"-0.0750\"}}"
},
{
"description": "[decq014] derivative canonical plain strings",
"bson": "18000000136400EE0200000000000000000000000034B000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"-0.000750\"}}"
},
{
"description": "[decq016] derivative canonical plain strings",
"bson": "18000000136400EE0200000000000000000000000030B000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"-0.00000750\"}}"
},
{
"description": "[decq404] zeros",
"bson": "180000001364000000000000000000000000000000000000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"0E-6176\"}}"
},
{
"description": "[decq424] negative zeros",
"bson": "180000001364000000000000000000000000000000008000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"-0E-6176\"}}"
},
{
"description": "[decq407] zeros",
"bson": "1800000013640000000000000000000000000000003C3000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"0.00\"}}"
},
{
"description": "[decq427] negative zeros",
"bson": "1800000013640000000000000000000000000000003CB000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"-0.00\"}}"
},
{
"description": "[decq409] zeros",
"bson": "180000001364000000000000000000000000000000403000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"0\"}}"
},
{
"description": "[decq428] negative zeros",
"bson": "18000000136400000000000000000000000000000040B000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"-0\"}}"
},
{
"description": "[decq700] Selected DPD codes",
"bson": "180000001364000000000000000000000000000000403000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"0\"}}"
},
{
"description": "[decq406] zeros",
"bson": "1800000013640000000000000000000000000000003C3000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"0.00\"}}"
},
{
"description": "[decq426] negative zeros",
"bson": "1800000013640000000000000000000000000000003CB000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"-0.00\"}}"
},
{
"description": "[decq410] zeros",
"bson": "180000001364000000000000000000000000000000463000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"0E+3\"}}"
},
{
"description": "[decq431] negative zeros",
"bson": "18000000136400000000000000000000000000000046B000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"-0E+3\"}}"
},
{
"description": "[decq419] clamped zeros...",
"bson": "180000001364000000000000000000000000000000FE5F00",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"0E+6111\"}}"
},
{
"description": "[decq432] negative zeros",
"bson": "180000001364000000000000000000000000000000FEDF00",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"-0E+6111\"}}"
},
{
"description": "[decq405] zeros",
"bson": "180000001364000000000000000000000000000000000000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"0E-6176\"}}"
},
{
"description": "[decq425] negative zeros",
"bson": "180000001364000000000000000000000000000000008000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"-0E-6176\"}}"
},
{
"description": "[decq508] Specials",
"bson": "180000001364000000000000000000000000000000007800",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"Infinity\"}}"
},
{
"description": "[decq528] Specials",
"bson": "18000000136400000000000000000000000000000000F800",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"-Infinity\"}}"
},
{
"description": "[decq541] Specials",
"bson": "180000001364000000000000000000000000000000007C00",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"NaN\"}}"
},
{
"description": "[decq074] Nmin and below",
"bson": "18000000136400000000000A5BC138938D44C64D31000000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"1.000000000000000000000000000000000E-6143\"}}"
},
{
"description": "[decq602] fold-down full sequence",
"bson": "18000000136400000000000A5BC138938D44C64D31FE5F00",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"1.000000000000000000000000000000000E+6144\"}}"
},
{
"description": "[decq604] fold-down full sequence",
"bson": "180000001364000000000081EFAC855B416D2DEE04FE5F00",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"1.00000000000000000000000000000000E+6143\"}}"
},
{
"description": "[decq606] fold-down full sequence",
"bson": "1800000013640000000080264B91C02220BE377E00FE5F00",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"1.0000000000000000000000000000000E+6142\"}}"
},
{
"description": "[decq608] fold-down full sequence",
"bson": "1800000013640000000040EAED7446D09C2C9F0C00FE5F00",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"1.000000000000000000000000000000E+6141\"}}"
},
{
"description": "[decq610] fold-down full sequence",
"bson": "18000000136400000000A0CA17726DAE0F1E430100FE5F00",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"1.00000000000000000000000000000E+6140\"}}"
},
{
"description": "[decq612] fold-down full sequence",
"bson": "18000000136400000000106102253E5ECE4F200000FE5F00",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"1.0000000000000000000000000000E+6139\"}}"
},
{
"description": "[decq614] fold-down full sequence",
"bson": "18000000136400000000E83C80D09F3C2E3B030000FE5F00",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"1.000000000000000000000000000E+6138\"}}"
},
{
"description": "[decq616] fold-down full sequence",
"bson": "18000000136400000000E4D20CC8DCD2B752000000FE5F00",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"1.00000000000000000000000000E+6137\"}}"
},
{
"description": "[decq618] fold-down full sequence",
"bson": "180000001364000000004A48011416954508000000FE5F00",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"1.0000000000000000000000000E+6136\"}}"
},
{
"description": "[decq620] fold-down full sequence",
"bson": "18000000136400000000A1EDCCCE1BC2D300000000FE5F00",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"1.000000000000000000000000E+6135\"}}"
},
{
"description": "[decq622] fold-down full sequence",
"bson": "18000000136400000080F64AE1C7022D1500000000FE5F00",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"1.00000000000000000000000E+6134\"}}"
},
{
"description": "[decq624] fold-down full sequence",
"bson": "18000000136400000040B2BAC9E0191E0200000000FE5F00",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"1.0000000000000000000000E+6133\"}}"
},
{
"description": "[decq626] fold-down full sequence",
"bson": "180000001364000000A0DEC5ADC935360000000000FE5F00",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"1.000000000000000000000E+6132\"}}"
},
{
"description": "[decq628] fold-down full sequence",
"bson": "18000000136400000010632D5EC76B050000000000FE5F00",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"1.00000000000000000000E+6131\"}}"
},
{
"description": "[decq630] fold-down full sequence",
"bson": "180000001364000000E8890423C78A000000000000FE5F00",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"1.0000000000000000000E+6130\"}}"
},
{
"description": "[decq632] fold-down full sequence",
"bson": "18000000136400000064A7B3B6E00D000000000000FE5F00",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"1.000000000000000000E+6129\"}}"
},
{
"description": "[decq634] fold-down full sequence",
"bson": "1800000013640000008A5D78456301000000000000FE5F00",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"1.00000000000000000E+6128\"}}"
},
{
"description": "[decq636] fold-down full sequence",
"bson": "180000001364000000C16FF2862300000000000000FE5F00",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"1.0000000000000000E+6127\"}}"
},
{
"description": "[decq638] fold-down full sequence",
"bson": "180000001364000080C6A47E8D0300000000000000FE5F00",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"1.000000000000000E+6126\"}}"
},
{
"description": "[decq640] fold-down full sequence",
"bson": "1800000013640000407A10F35A0000000000000000FE5F00",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"1.00000000000000E+6125\"}}"
},
{
"description": "[decq642] fold-down full sequence",
"bson": "1800000013640000A0724E18090000000000000000FE5F00",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"1.0000000000000E+6124\"}}"
},
{
"description": "[decq644] fold-down full sequence",
"bson": "180000001364000010A5D4E8000000000000000000FE5F00",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"1.000000000000E+6123\"}}"
},
{
"description": "[decq646] fold-down full sequence",
"bson": "1800000013640000E8764817000000000000000000FE5F00",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"1.00000000000E+6122\"}}"
},
{
"description": "[decq648] fold-down full sequence",
"bson": "1800000013640000E40B5402000000000000000000FE5F00",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"1.0000000000E+6121\"}}"
},
{
"description": "[decq650] fold-down full sequence",
"bson": "1800000013640000CA9A3B00000000000000000000FE5F00",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"1.000000000E+6120\"}}"
},
{
"description": "[decq652] fold-down full sequence",
"bson": "1800000013640000E1F50500000000000000000000FE5F00",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"1.00000000E+6119\"}}"
},
{
"description": "[decq654] fold-down full sequence",
"bson": "180000001364008096980000000000000000000000FE5F00",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"1.0000000E+6118\"}}"
},
{
"description": "[decq656] fold-down full sequence",
"bson": "1800000013640040420F0000000000000000000000FE5F00",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"1.000000E+6117\"}}"
},
{
"description": "[decq658] fold-down full sequence",
"bson": "18000000136400A086010000000000000000000000FE5F00",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"1.00000E+6116\"}}"
},
{
"description": "[decq660] fold-down full sequence",
"bson": "180000001364001027000000000000000000000000FE5F00",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"1.0000E+6115\"}}"
},
{
"description": "[decq662] fold-down full sequence",
"bson": "18000000136400E803000000000000000000000000FE5F00",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"1.000E+6114\"}}"
},
{
"description": "[decq664] fold-down full sequence",
"bson": "180000001364006400000000000000000000000000FE5F00",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"1.00E+6113\"}}"
},
{
"description": "[decq666] fold-down full sequence",
"bson": "180000001364000A00000000000000000000000000FE5F00",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"1.0E+6112\"}}"
},
{
"description": "[decq060] fold-downs (more below)",
"bson": "180000001364000100000000000000000000000000403000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"1\"}}"
},
{
"description": "[decq670] fold-down full sequence",
"bson": "180000001364000100000000000000000000000000FC5F00",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"1E+6110\"}}"
},
{
"description": "[decq668] fold-down full sequence",
"bson": "180000001364000100000000000000000000000000FE5F00",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"1E+6111\"}}"
},
{
"description": "[decq072] Nmin and below",
"bson": "180000001364000100000000000000000000000000420000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"1E-6143\"}}"
},
{
"description": "[decq076] Nmin and below",
"bson": "18000000136400010000000A5BC138938D44C64D31000000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"1.000000000000000000000000000000001E-6143\"}}"
},
{
"description": "[decq036] fold-downs (more below)",
"bson": "18000000136400000000807F1BCF85B27059C8A43CFE5F00",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"1.230000000000000000000000000000000E+6144\"}}"
},
{
"description": "[decq062] fold-downs (more below)",
"bson": "180000001364007B000000000000000000000000003C3000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"1.23\"}}"
},
{
"description": "[decq034] Nmax and similar",
"bson": "18000000136400F2AF967ED05C82DE3297FF6FDE3CFE5F00",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"1.234567890123456789012345678901234E+6144\"}}"
},
{
"description": "[decq441] exponent lengths",
"bson": "180000001364000700000000000000000000000000403000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"7\"}}"
},
{
"description": "[decq449] exponent lengths",
"bson": "1800000013640007000000000000000000000000001E5F00",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"7E+5999\"}}"
},
{
"description": "[decq447] exponent lengths",
"bson": "1800000013640007000000000000000000000000000E3800",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"7E+999\"}}"
},
{
"description": "[decq445] exponent lengths",
"bson": "180000001364000700000000000000000000000000063100",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"7E+99\"}}"
},
{
"description": "[decq443] exponent lengths",
"bson": "180000001364000700000000000000000000000000523000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"7E+9\"}}"
},
{
"description": "[decq842] VG testcase",
"bson": "180000001364000000FED83F4E7C9FE4E269E38A5BCD1700",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"7.049000000000010795488000000000000E-3097\"}}"
},
{
"description": "[decq841] VG testcase",
"bson": "180000001364000000203B9DB5056F000000000000002400",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"8.000000000000000000E-1550\"}}"
},
{
"description": "[decq840] VG testcase",
"bson": "180000001364003C17258419D710C42F0000000000002400",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"8.81125000000001349436E-1548\"}}"
},
{
"description": "[decq701] Selected DPD codes",
"bson": "180000001364000900000000000000000000000000403000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"9\"}}"
},
{
"description": "[decq032] Nmax and similar",
"bson": "18000000136400FFFFFFFF638E8D37C087ADBE09EDFF5F00",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"9.999999999999999999999999999999999E+6144\"}}"
},
{
"description": "[decq702] Selected DPD codes",
"bson": "180000001364000A00000000000000000000000000403000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"10\"}}"
},
{
"description": "[decq057] fold-downs (more below)",
"bson": "180000001364000C00000000000000000000000000403000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"12\"}}"
},
{
"description": "[decq703] Selected DPD codes",
"bson": "180000001364001300000000000000000000000000403000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"19\"}}"
},
{
"description": "[decq704] Selected DPD codes",
"bson": "180000001364001400000000000000000000000000403000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"20\"}}"
},
{
"description": "[decq705] Selected DPD codes",
"bson": "180000001364001D00000000000000000000000000403000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"29\"}}"
},
{
"description": "[decq706] Selected DPD codes",
"bson": "180000001364001E00000000000000000000000000403000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"30\"}}"
},
{
"description": "[decq707] Selected DPD codes",
"bson": "180000001364002700000000000000000000000000403000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"39\"}}"
},
{
"description": "[decq708] Selected DPD codes",
"bson": "180000001364002800000000000000000000000000403000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"40\"}}"
},
{
"description": "[decq709] Selected DPD codes",
"bson": "180000001364003100000000000000000000000000403000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"49\"}}"
},
{
"description": "[decq710] Selected DPD codes",
"bson": "180000001364003200000000000000000000000000403000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"50\"}}"
},
{
"description": "[decq711] Selected DPD codes",
"bson": "180000001364003B00000000000000000000000000403000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"59\"}}"
},
{
"description": "[decq712] Selected DPD codes",
"bson": "180000001364003C00000000000000000000000000403000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"60\"}}"
},
{
"description": "[decq713] Selected DPD codes",
"bson": "180000001364004500000000000000000000000000403000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"69\"}}"
},
{
"description": "[decq714] Selected DPD codes",
"bson": "180000001364004600000000000000000000000000403000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"70\"}}"
},
{
"description": "[decq715] Selected DPD codes",
"bson": "180000001364004700000000000000000000000000403000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"71\"}}"
},
{
"description": "[decq716] Selected DPD codes",
"bson": "180000001364004800000000000000000000000000403000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"72\"}}"
},
{
"description": "[decq717] Selected DPD codes",
"bson": "180000001364004900000000000000000000000000403000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"73\"}}"
},
{
"description": "[decq718] Selected DPD codes",
"bson": "180000001364004A00000000000000000000000000403000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"74\"}}"
},
{
"description": "[decq719] Selected DPD codes",
"bson": "180000001364004B00000000000000000000000000403000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"75\"}}"
},
{
"description": "[decq720] Selected DPD codes",
"bson": "180000001364004C00000000000000000000000000403000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"76\"}}"
},
{
"description": "[decq721] Selected DPD codes",
"bson": "180000001364004D00000000000000000000000000403000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"77\"}}"
},
{
"description": "[decq722] Selected DPD codes",
"bson": "180000001364004E00000000000000000000000000403000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"78\"}}"
},
{
"description": "[decq723] Selected DPD codes",
"bson": "180000001364004F00000000000000000000000000403000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"79\"}}"
},
{
"description": "[decq056] fold-downs (more below)",
"bson": "180000001364007B00000000000000000000000000403000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"123\"}}"
},
{
"description": "[decq064] fold-downs (more below)",
"bson": "1800000013640039300000000000000000000000003C3000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"123.45\"}}"
},
{
"description": "[decq732] Selected DPD codes",
"bson": "180000001364000802000000000000000000000000403000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"520\"}}"
},
{
"description": "[decq733] Selected DPD codes",
"bson": "180000001364000902000000000000000000000000403000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"521\"}}"
},
{
"description": "[decq740] DPD: one of each of the huffman groups",
"bson": "180000001364000903000000000000000000000000403000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"777\"}}"
},
{
"description": "[decq741] DPD: one of each of the huffman groups",
"bson": "180000001364000A03000000000000000000000000403000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"778\"}}"
},
{
"description": "[decq742] DPD: one of each of the huffman groups",
"bson": "180000001364001303000000000000000000000000403000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"787\"}}"
},
{
"description": "[decq746] DPD: one of each of the huffman groups",
"bson": "180000001364001F03000000000000000000000000403000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"799\"}}"
},
{
"description": "[decq743] DPD: one of each of the huffman groups",
"bson": "180000001364006D03000000000000000000000000403000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"877\"}}"
},
{
"description": "[decq753] DPD all-highs cases (includes the 24 redundant codes)",
"bson": "180000001364007803000000000000000000000000403000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"888\"}}"
},
{
"description": "[decq754] DPD all-highs cases (includes the 24 redundant codes)",
"bson": "180000001364007903000000000000000000000000403000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"889\"}}"
},
{
"description": "[decq760] DPD all-highs cases (includes the 24 redundant codes)",
"bson": "180000001364008203000000000000000000000000403000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"898\"}}"
},
{
"description": "[decq764] DPD all-highs cases (includes the 24 redundant codes)",
"bson": "180000001364008303000000000000000000000000403000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"899\"}}"
},
{
"description": "[decq745] DPD: one of each of the huffman groups",
"bson": "18000000136400D303000000000000000000000000403000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"979\"}}"
},
{
"description": "[decq770] DPD all-highs cases (includes the 24 redundant codes)",
"bson": "18000000136400DC03000000000000000000000000403000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"988\"}}"
},
{
"description": "[decq774] DPD all-highs cases (includes the 24 redundant codes)",
"bson": "18000000136400DD03000000000000000000000000403000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"989\"}}"
},
{
"description": "[decq730] Selected DPD codes",
"bson": "18000000136400E203000000000000000000000000403000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"994\"}}"
},
{
"description": "[decq731] Selected DPD codes",
"bson": "18000000136400E303000000000000000000000000403000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"995\"}}"
},
{
"description": "[decq744] DPD: one of each of the huffman groups",
"bson": "18000000136400E503000000000000000000000000403000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"997\"}}"
},
{
"description": "[decq780] DPD all-highs cases (includes the 24 redundant codes)",
"bson": "18000000136400E603000000000000000000000000403000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"998\"}}"
},
{
"description": "[decq787] DPD all-highs cases (includes the 24 redundant codes)",
"bson": "18000000136400E703000000000000000000000000403000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"999\"}}"
},
{
"description": "[decq053] fold-downs (more below)",
"bson": "18000000136400D204000000000000000000000000403000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"1234\"}}"
},
{
"description": "[decq052] fold-downs (more below)",
"bson": "180000001364003930000000000000000000000000403000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"12345\"}}"
},
{
"description": "[decq792] Miscellaneous (testers' queries, etc.)",
"bson": "180000001364003075000000000000000000000000403000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"30000\"}}"
},
{
"description": "[decq793] Miscellaneous (testers' queries, etc.)",
"bson": "1800000013640090940D0000000000000000000000403000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"890000\"}}"
},
{
"description": "[decq824] values around [u]int32 edges (zeros done earlier)",
"bson": "18000000136400FEFFFF7F00000000000000000000403000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"2147483646\"}}"
},
{
"description": "[decq825] values around [u]int32 edges (zeros done earlier)",
"bson": "18000000136400FFFFFF7F00000000000000000000403000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"2147483647\"}}"
},
{
"description": "[decq826] values around [u]int32 edges (zeros done earlier)",
"bson": "180000001364000000008000000000000000000000403000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"2147483648\"}}"
},
{
"description": "[decq827] values around [u]int32 edges (zeros done earlier)",
"bson": "180000001364000100008000000000000000000000403000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"2147483649\"}}"
},
{
"description": "[decq828] values around [u]int32 edges (zeros done earlier)",
"bson": "18000000136400FEFFFFFF00000000000000000000403000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"4294967294\"}}"
},
{
"description": "[decq829] values around [u]int32 edges (zeros done earlier)",
"bson": "18000000136400FFFFFFFF00000000000000000000403000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"4294967295\"}}"
},
{
"description": "[decq830] values around [u]int32 edges (zeros done earlier)",
"bson": "180000001364000000000001000000000000000000403000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"4294967296\"}}"
},
{
"description": "[decq831] values around [u]int32 edges (zeros done earlier)",
"bson": "180000001364000100000001000000000000000000403000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"4294967297\"}}"
},
{
"description": "[decq022] Normality",
"bson": "18000000136400C7711CC7B548F377DC80A131C836403000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"1111111111111111111111111111111111\"}}"
},
{
"description": "[decq020] Normality",
"bson": "18000000136400F2AF967ED05C82DE3297FF6FDE3C403000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"1234567890123456789012345678901234\"}}"
},
{
"description": "[decq550] Specials",
"bson": "18000000136400FFFFFFFF638E8D37C087ADBE09ED413000",
"extjson": "{\"d\" : {\"$numberDecimal\" : \"9999999999999999999999999999999999\"}}"
}
]
}

File diff suppressed because it is too large Load Diff

View File

@ -21,6 +21,8 @@ import glob
import os
import sys
from decimal import DecimalException
if sys.version_info[:2] == (2, 6):
try:
import simplejson as json
@ -31,11 +33,13 @@ else:
sys.path[0:0] = [""]
from bson import BSON, EPOCH_AWARE, json_util
from bson import BSON, json_util
from bson.binary import STANDARD
from bson.codec_options import CodecOptions
from bson.decimal128 import Decimal128
from bson.dbref import DBRef
from bson.errors import InvalidBSON
from bson.errors import InvalidBSON, InvalidId
from bson.json_util import JSONMode
from bson.py3compat import text_type, b
from bson.son import SON
@ -44,6 +48,18 @@ from test import unittest
_TEST_PATH = os.path.join(
os.path.dirname(os.path.realpath(__file__)), 'bson_corpus')
_TESTS_TO_SKIP = set([
# Python cannot decode dates after year 9999.
'Y10K',
])
_NON_PARSE_ERRORS = set([
# {"$date": <number>} is our legacy format which we still need to parse.
'Bad $date (number, not string or hash)',
# This variant of $numberLong may have been generated by an old version
# of mongoexport.
'Bad $numberLong (number, not string)',
])
_DEPRECATED_BSON_TYPES = {
# Symbol
@ -60,19 +76,18 @@ codec_options = CodecOptions(tz_aware=True, document_class=SON)
# We normally encode UUID as binary subtype 0x03,
# but we'll need to encode to subtype 0x04 for one of the tests.
codec_options_uuid_04 = codec_options._replace(uuid_representation=STANDARD)
json_options_uuid_04 = json_util.JSONOptions(
strict_number_long=True,
strict_uuid=True,
datetime_representation=json_util.DatetimeRepresentation.NUMBERLONG,
uuid_representation=STANDARD)
json_options_uuid_04 = json_util.JSONOptions(json_mode=JSONMode.CANONICAL,
uuid_representation=STANDARD)
json_options_iso8601 = json_util.JSONOptions(
datetime_representation=json_util.DatetimeRepresentation.ISO8601)
to_extjson = functools.partial(
json_util.dumps, json_options=json_util.CANONICAL_JSON_OPTIONS)
to_extjson = functools.partial(json_util.dumps,
json_options=json_util.CANONICAL_JSON_OPTIONS)
to_extjson_uuid_04 = functools.partial(json_util.dumps,
json_options=json_options_uuid_04)
to_extjson_iso8601 = functools.partial(json_util.dumps,
json_options=json_options_iso8601)
to_relaxed_extjson = functools.partial(
json_util.dumps, json_options=json_util.RELAXED_JSON_OPTIONS)
to_bson_uuid_04 = functools.partial(BSON.encode,
codec_options=codec_options_uuid_04)
to_bson = functools.partial(BSON.encode, codec_options=codec_options)
@ -80,7 +95,7 @@ decode_bson = lambda bbytes: BSON(bbytes).decode(codec_options=codec_options)
if json_util._HAS_OBJECT_PAIRS_HOOK:
decode_extjson = functools.partial(
json_util.loads,
json_options=json_util.JSONOptions(canonical_extended_json=True,
json_options=json_util.JSONOptions(json_mode=JSONMode.CANONICAL,
document_class=SON))
loads = functools.partial(json.loads, object_pairs_hook=SON)
else:
@ -91,147 +106,130 @@ else:
class TestBSONCorpus(unittest.TestCase):
def test_all_bson_types(self):
# Because we can't round-trip all BSON types (see _DEPRECATED_BSON_TYPES
# above for how these are handled), make this test a special case,
# instead of mangling our create_test function below.
with open(os.path.join(_TEST_PATH, 'multi-type.json')) as spec_file:
case_spec = json.load(spec_file)
for valid_case in case_spec.get('valid', []):
B = binascii.unhexlify(b(valid_case['bson']))
E = valid_case['extjson']
def assertJsonEqual(self, first, second, msg=None):
"""Fail if the two json strings are unequal.
# Make sure that the BSON and JSON decode to the same document.
self.assertEqual(
json_util.loads(
E, json_options=json_util.CANONICAL_JSON_OPTIONS),
BSON(B).decode(
codec_options=CodecOptions(
document_class=SON, tz_aware=True)))
Normalize json by parsing it with the built-in json library. This
accounts for discrepancies in spacing.
"""
self.assertEqual(loads(first), loads(second), msg=msg)
def create_test(case_spec):
bson_type = case_spec['bson_type']
# Test key is absent when testing top-level documents.
test_key = case_spec.get('test_key')
deprecated = case_spec.get('deprecated')
def run_test(self):
for valid_case in case_spec.get('valid', []):
description = valid_case['description']
if description in _TESTS_TO_SKIP:
continue
# Special case for testing encoding UUID as binary subtype 0x04.
if valid_case['description'] == 'subtype 0x04':
if description == 'subtype 0x04':
encode_extjson = to_extjson_uuid_04
encode_bson = to_bson_uuid_04
else:
encode_extjson = to_extjson
encode_bson = to_bson
B = binascii.unhexlify(b(valid_case['bson']))
cB = binascii.unhexlify(b(valid_case['canonical_bson']))
cEJ = valid_case['canonical_extjson']
rEJ = valid_case.get('relaxed_extjson')
dEJ = valid_case.get('degenerate_extjson')
lossy = valid_case.get('lossy')
if 'canonical_bson' in valid_case:
cB = binascii.unhexlify(b(valid_case['canonical_bson']))
else:
cB = B
decoded_bson = decode_bson(cB)
if not lossy:
# Make sure we can parse the legacy (default) JSON format.
legacy_json = json_util.dumps(
decoded_bson, json_options=json_util.LEGACY_JSON_OPTIONS)
self.assertEqual(decode_extjson(legacy_json), decoded_bson)
if deprecated:
if 'converted_bson' in valid_case:
converted_bson = binascii.unhexlify(
b(valid_case['converted_bson']))
self.assertEqual(encode_bson(decoded_bson), converted_bson)
self.assertJsonEqual(
encode_extjson(decode_bson(converted_bson)),
valid_case['converted_extjson'])
# Make sure we can decode the type.
self.assertEqual(decoded_bson, decode_extjson(cEJ))
if test_key is not None:
self.assertIsInstance(decoded_bson[test_key],
_DEPRECATED_BSON_TYPES[bson_type])
continue
if bson_type in _DEPRECATED_BSON_TYPES:
# Just make sure we can decode the type.
self.assertIsInstance(
decode_bson(B)[test_key], _DEPRECATED_BSON_TYPES[bson_type])
if B != cB:
self.assertIsInstance(
decode_bson(cB)[test_key],
_DEPRECATED_BSON_TYPES[bson_type])
# PyPy3 and Jython can't handle NaN with a payload from
# struct.(un)pack if endianness is specified in the format string.
elif not ((('PyPy' in sys.version and
sys.version_info[:2] < (3, 3)) or
sys.platform.startswith("java")) and
valid_case['description'] == 'NaN with payload'):
# Test round-tripping encoding/decoding the type.
self.assertEqual(encode_bson(decode_bson(B)), cB)
if not ((('PyPy' in sys.version and
sys.version_info[:2] < (3, 3)) or
sys.platform.startswith("java")) and
description == 'NaN with payload'):
# Test round-tripping canonical bson.
self.assertEqual(encode_bson(decoded_bson), cB)
self.assertJsonEqual(encode_extjson(decoded_bson), cEJ)
if B != cB:
self.assertEqual(
encode_bson(decode_bson(cB)), cB)
# Test round-tripping canonical extended json.
decoded_json = decode_extjson(cEJ)
self.assertJsonEqual(encode_extjson(decoded_json), cEJ)
if not lossy and json_util._HAS_OBJECT_PAIRS_HOOK:
self.assertEqual(encode_bson(decoded_json), cB)
if 'extjson' in valid_case:
E = valid_case['extjson']
cE = valid_case.get('canonical_extjson', E)
# Test round-tripping degenerate bson.
if 'degenerate_bson' in valid_case:
dB = binascii.unhexlify(b(valid_case['degenerate_bson']))
self.assertEqual(encode_bson(decode_bson(dB)), cB)
if bson_type in _DEPRECATED_BSON_TYPES:
# Just make sure that we can parse the extended JSON.
self.assertIsInstance(
decode_extjson(E)[test_key],
_DEPRECATED_BSON_TYPES[bson_type])
if E != cE:
self.assertIsInstance(
decode_extjson(cE)[test_key],
_DEPRECATED_BSON_TYPES[bson_type])
continue
# Test round-tripping degenerate extended json.
if dEJ is not None:
decoded_json = decode_extjson(dEJ)
self.assertJsonEqual(encode_extjson(decoded_json), cEJ)
if not lossy:
# We don't need to check json_util._HAS_OBJECT_PAIRS_HOOK
# because degenerate_extjson is always a single key so
# the order cannot be changed.
self.assertEqual(encode_bson(decoded_json), cB)
# Normalize extended json by parsing it with the built-in
# json library. This accounts for discrepancies in spacing.
# Key ordering is preserved when possible.
normalized_cE = loads(cE)
self.assertEqual(
loads(encode_extjson(decode_bson(B))),
normalized_cE)
self.assertEqual(
loads(encode_extjson(decode_extjson(E))),
normalized_cE)
if bson_type == '0x09':
# Test datetime can output ISO8601 to match extjson or
# $numberLong to match canonical_extjson if the datetime
# is pre-epoch.
if decode_extjson(E)[test_key] >= EPOCH_AWARE:
normalized_date = loads(E)
else:
normalized_date = normalized_cE
self.assertEqual(
loads(to_extjson_iso8601(decode_extjson(cE))),
normalized_date)
if B != cB:
self.assertEqual(
loads(encode_extjson(decode_bson(cB))),
normalized_cE)
if E != cE:
self.assertEqual(
loads(encode_extjson(decode_extjson(cE))),
normalized_cE)
if 'lossy' not in valid_case:
# Skip tests for document type in Python 2.6 that have
# multiple keys, since we can't control key ordering when
# parsing JSON.
if json_util._HAS_OBJECT_PAIRS_HOOK or not (
sys.version_info[:2] == (2, 6) and
bson_type in ('0x03', '0x00') and
len(decode_extjson(E)) > 1):
self.assertEqual(encode_bson(decode_extjson(E)), cB)
if E != cE:
self.assertEqual(
encode_bson(decode_extjson(cE)),
cB)
# Test round-tripping relaxed extended json.
if rEJ is not None:
self.assertJsonEqual(to_relaxed_extjson(decoded_bson), rEJ)
decoded_json = decode_extjson(rEJ)
self.assertJsonEqual(to_relaxed_extjson(decoded_json), rEJ)
for decode_error_case in case_spec.get('decodeErrors', []):
with self.assertRaises(InvalidBSON):
decode_bson(
binascii.unhexlify(b(decode_error_case['bson'])))
for parse_error_case in case_spec.get('parseErrors', []):
if bson_type == '0x13':
self.assertRaises(
DecimalException, Decimal128, parse_error_case['string'])
elif bson_type == '0x00':
description = parse_error_case['description']
if description in _NON_PARSE_ERRORS:
decode_extjson(parse_error_case['string'])
else:
try:
decode_extjson(parse_error_case['string'])
raise AssertionError('exception not raised for test '
'case: ' + description)
except (ValueError, KeyError, TypeError, InvalidId):
pass
else:
raise AssertionError('cannot test parseErrors for type ' +
bson_type)
return run_test
def create_tests():
for filename in glob.glob(os.path.join(_TEST_PATH, '*.json')):
test_suffix, _ = os.path.splitext(os.path.basename(filename))
if test_suffix == 'multi-type':
# Special case in TestBSONCorpus.
continue
with codecs.open(filename, encoding='utf-8') as bson_test_file:
test_method = create_test(json.load(bson_test_file))
setattr(TestBSONCorpus, 'test_' + test_suffix, test_method)

View File

@ -79,53 +79,6 @@ class TestDecimal128(unittest.TestCase):
self.assertEqual("Infinity", str(ctx.copy().create_decimal("1E6145")))
self.assertEqual("0E-6176", str(ctx.copy().create_decimal("1E-6177")))
def test_spec(self):
for path in glob.glob(os.path.join(
os.path.dirname(os.path.realpath(__file__)),
"decimal",
"decimal128*")):
with codecs.open(path, "r", "utf-8-sig") as fp:
suite = json.load(fp)
for case in suite.get("valid", []):
B = unhexlify(b(case["bson"]))
E = case["extjson"].replace(" ", "")
if "canonical_bson" in case:
cB = unhexlify(b(case["canonical_bson"]))
else:
cB = B
if "canonical_extjson" in case:
cE = case["canonical_extjson"].replace(" ", "")
else:
cE = E
self.assertEqual(BSON().encode(BSON(B).decode()), cB)
if B != cB:
self.assertEqual(BSON().encode(BSON(cB).decode()), cB)
self.assertEqual(
dumps(BSON(B).decode()).replace(" ", ""), cE)
self.assertEqual(
dumps(loads(E)).replace(" ", ""), cE)
if B != cB:
self.assertEqual(
dumps(BSON(cB).decode()).replace(" ", ""), cE)
if E != cE:
self.assertEqual(
dumps(loads(cE)).replace(" ", ""), cE)
if "lossy" not in case:
self.assertEqual(BSON().encode(loads(E)), cB)
if E != cE:
self.assertEqual(BSON().encode(loads(cE)), cB)
for test in suite.get("parseErrors", []):
self.assertRaises(
DecimalException, Decimal128, test["string"])
if __name__ == '__main__':
unittest.main()