bson 4.7.0 → 4.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -2
- data/ext/bson/bson-endian.h +1 -1
- data/ext/bson/bson-native.h +16 -5
- data/ext/bson/bytebuf.c +1 -1
- data/ext/bson/endian.c +2 -1
- data/ext/bson/init.c +26 -3
- data/ext/bson/read.c +127 -33
- data/ext/bson/util.c +41 -1
- data/ext/bson/write.c +18 -14
- data/lib/bson.rb +4 -1
- data/lib/bson/active_support.rb +1 -1
- data/lib/bson/array.rb +34 -5
- data/lib/bson/binary.rb +42 -4
- data/lib/bson/boolean.rb +12 -3
- data/lib/bson/code.rb +16 -2
- data/lib/bson/code_with_scope.rb +32 -5
- data/lib/bson/config.rb +1 -1
- data/lib/bson/date.rb +1 -1
- data/lib/bson/date_time.rb +1 -1
- data/lib/bson/db_pointer.rb +110 -0
- data/lib/bson/decimal128.rb +16 -2
- data/lib/bson/decimal128/builder.rb +1 -1
- data/lib/bson/document.rb +1 -1
- data/lib/bson/environment.rb +2 -1
- data/lib/bson/error.rb +21 -0
- data/lib/bson/ext_json.rb +375 -0
- data/lib/bson/false_class.rb +1 -1
- data/lib/bson/float.rb +48 -2
- data/lib/bson/hash.rb +36 -5
- data/lib/bson/int32.rb +22 -2
- data/lib/bson/int64.rb +29 -4
- data/lib/bson/integer.rb +35 -1
- data/lib/bson/json.rb +1 -1
- data/lib/bson/max_key.rb +13 -1
- data/lib/bson/min_key.rb +13 -1
- data/lib/bson/nil_class.rb +4 -2
- data/lib/bson/object.rb +28 -1
- data/lib/bson/object_id.rb +16 -2
- data/lib/bson/open_struct.rb +1 -1
- data/lib/bson/regexp.rb +20 -3
- data/lib/bson/registry.rb +1 -1
- data/lib/bson/specialized.rb +4 -2
- data/lib/bson/string.rb +4 -2
- data/lib/bson/symbol.rb +93 -4
- data/lib/bson/time.rb +63 -4
- data/lib/bson/time_with_zone.rb +1 -1
- data/lib/bson/timestamp.rb +16 -2
- data/lib/bson/true_class.rb +1 -1
- data/lib/bson/undefined.rb +12 -1
- data/lib/bson/version.rb +2 -2
- data/spec/bson/array_spec.rb +1 -1
- data/spec/bson/binary_spec.rb +34 -4
- data/spec/bson/binary_uuid_spec.rb +1 -1
- data/spec/bson/boolean_spec.rb +1 -1
- data/spec/bson/code_spec.rb +1 -1
- data/spec/bson/code_with_scope_spec.rb +1 -1
- data/spec/bson/date_spec.rb +1 -1
- data/spec/bson/date_time_spec.rb +1 -1
- data/spec/bson/decimal128_spec.rb +1 -1
- data/spec/bson/document_spec.rb +1 -1
- data/spec/bson/ext_json_parse_spec.rb +308 -0
- data/spec/bson/false_class_spec.rb +1 -1
- data/spec/bson/float_spec.rb +37 -1
- data/spec/bson/hash_spec.rb +71 -1
- data/spec/bson/int32_spec.rb +21 -1
- data/spec/bson/int64_spec.rb +39 -1
- data/spec/bson/integer_spec.rb +27 -1
- data/spec/bson/json_spec.rb +1 -1
- data/spec/bson/max_key_spec.rb +1 -1
- data/spec/bson/min_key_spec.rb +1 -1
- data/spec/bson/nil_class_spec.rb +1 -1
- data/spec/bson/object_id_spec.rb +1 -1
- data/spec/bson/object_spec.rb +1 -1
- data/spec/bson/open_struct_spec.rb +1 -1
- data/spec/bson/raw_spec.rb +22 -1
- data/spec/bson/regexp_spec.rb +1 -1
- data/spec/bson/registry_spec.rb +1 -1
- data/spec/bson/string_spec.rb +1 -1
- data/spec/bson/symbol_raw_spec.rb +45 -0
- data/spec/bson/symbol_spec.rb +61 -1
- data/spec/bson/time_spec.rb +205 -2
- data/spec/bson/time_with_zone_spec.rb +1 -1
- data/spec/bson/timestamp_spec.rb +1 -1
- data/spec/bson/true_class_spec.rb +1 -1
- data/spec/bson/undefined_spec.rb +1 -1
- data/spec/bson_spec.rb +1 -1
- data/spec/{support → runners}/common_driver.rb +1 -1
- data/spec/runners/corpus.rb +185 -0
- data/spec/{support/corpus.rb → runners/corpus_legacy.rb} +41 -59
- data/spec/spec_helper.rb +10 -3
- data/spec/{bson/driver_bson_spec.rb → spec_tests/common_driver_spec.rb} +1 -0
- data/spec/{bson/corpus_spec.rb → spec_tests/corpus_legacy_spec.rb} +4 -4
- data/spec/spec_tests/corpus_spec.rb +124 -0
- data/spec/spec_tests/data/corpus/README.md +15 -0
- data/spec/spec_tests/data/corpus/array.json +49 -0
- data/spec/spec_tests/data/corpus/binary.json +85 -0
- data/spec/spec_tests/data/corpus/boolean.json +27 -0
- data/spec/spec_tests/data/corpus/code.json +67 -0
- data/spec/spec_tests/data/corpus/code_w_scope.json +78 -0
- data/spec/spec_tests/data/corpus/datetime.json +42 -0
- data/spec/spec_tests/data/corpus/dbpointer.json +56 -0
- data/spec/spec_tests/data/corpus/dbref.json +31 -0
- data/spec/spec_tests/data/corpus/decimal128-1.json +317 -0
- data/spec/spec_tests/data/corpus/decimal128-2.json +793 -0
- data/spec/spec_tests/data/corpus/decimal128-3.json +1771 -0
- data/spec/spec_tests/data/corpus/decimal128-4.json +117 -0
- data/spec/spec_tests/data/corpus/decimal128-5.json +402 -0
- data/spec/spec_tests/data/corpus/decimal128-6.json +119 -0
- data/spec/spec_tests/data/corpus/decimal128-7.json +323 -0
- data/spec/spec_tests/data/corpus/document.json +36 -0
- data/spec/spec_tests/data/corpus/double.json +87 -0
- data/spec/spec_tests/data/corpus/int32.json +43 -0
- data/spec/spec_tests/data/corpus/int64.json +43 -0
- data/spec/spec_tests/data/corpus/maxkey.json +12 -0
- data/spec/spec_tests/data/corpus/minkey.json +12 -0
- data/spec/spec_tests/data/corpus/multi-type-deprecated.json +15 -0
- data/spec/spec_tests/data/corpus/multi-type.json +11 -0
- data/spec/spec_tests/data/corpus/null.json +12 -0
- data/spec/spec_tests/data/corpus/oid.json +28 -0
- data/spec/spec_tests/data/corpus/regex.json +65 -0
- data/spec/spec_tests/data/corpus/string.json +72 -0
- data/spec/spec_tests/data/corpus/symbol.json +80 -0
- data/spec/spec_tests/data/corpus/timestamp.json +24 -0
- data/spec/spec_tests/data/corpus/top.json +236 -0
- data/spec/spec_tests/data/corpus/undefined.json +15 -0
- data/spec/{support/corpus-tests → spec_tests/data/corpus_legacy}/array.json +0 -0
- data/spec/{support/corpus-tests/failures → spec_tests/data/corpus_legacy}/binary.json +0 -0
- data/spec/{support/corpus-tests → spec_tests/data/corpus_legacy}/boolean.json +0 -0
- data/spec/{support/corpus-tests → spec_tests/data/corpus_legacy}/code.json +1 -1
- data/spec/{support/corpus-tests → spec_tests/data/corpus_legacy}/code_w_scope.json +1 -1
- data/spec/{support/corpus-tests → spec_tests/data/corpus_legacy}/document.json +1 -1
- data/spec/{support/corpus-tests → spec_tests/data/corpus_legacy}/double.json +1 -1
- data/spec/{support/corpus-tests → spec_tests/data/corpus_legacy}/failures/datetime.json +0 -0
- data/spec/{support/corpus-tests → spec_tests/data/corpus_legacy}/failures/dbpointer.json +0 -0
- data/spec/{support/corpus-tests → spec_tests/data/corpus_legacy}/failures/int64.json +0 -0
- data/spec/{support/corpus-tests → spec_tests/data/corpus_legacy}/failures/symbol.json +0 -0
- data/spec/{support/corpus-tests → spec_tests/data/corpus_legacy}/int32.json +1 -1
- data/spec/{support/corpus-tests → spec_tests/data/corpus_legacy}/maxkey.json +1 -1
- data/spec/{support/corpus-tests → spec_tests/data/corpus_legacy}/minkey.json +1 -1
- data/spec/{support/corpus-tests → spec_tests/data/corpus_legacy}/null.json +1 -1
- data/spec/{support/corpus-tests → spec_tests/data/corpus_legacy}/oid.json +0 -0
- data/spec/{support/corpus-tests → spec_tests/data/corpus_legacy}/regex.json +1 -1
- data/spec/{support/corpus-tests → spec_tests/data/corpus_legacy}/string.json +0 -0
- data/spec/{support/corpus-tests → spec_tests/data/corpus_legacy}/timestamp.json +1 -1
- data/spec/{support/corpus-tests → spec_tests/data/corpus_legacy}/top.json +0 -0
- data/spec/{support/corpus-tests/failures → spec_tests/data/corpus_legacy}/undefined.json +0 -0
- data/spec/{support/driver-spec-tests → spec_tests/data}/decimal128/decimal128-1.json +0 -0
- data/spec/{support/driver-spec-tests → spec_tests/data}/decimal128/decimal128-2.json +0 -0
- data/spec/{support/driver-spec-tests → spec_tests/data}/decimal128/decimal128-3.json +0 -0
- data/spec/{support/driver-spec-tests → spec_tests/data}/decimal128/decimal128-4.json +0 -0
- data/spec/{support/driver-spec-tests → spec_tests/data}/decimal128/decimal128-5.json +0 -0
- data/spec/{support/driver-spec-tests → spec_tests/data}/decimal128/decimal128-6.json +0 -0
- data/spec/{support/driver-spec-tests → spec_tests/data}/decimal128/decimal128-7.json +0 -0
- data/spec/support/shared_examples.rb +1 -1
- metadata +172 -120
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -1
- metadata.gz.sig +0 -1
data/spec/spec_helper.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2009-
|
1
|
+
# Copyright (C) 2009-2020 MongoDB Inc.
|
2
2
|
#
|
3
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
4
|
# you may not use this file except in compliance with the License.
|
@@ -13,8 +13,9 @@
|
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
15
|
CURRENT_PATH = File.expand_path(File.dirname(__FILE__))
|
16
|
-
DRIVER_COMMON_BSON_TESTS = Dir.glob("#{CURRENT_PATH}/
|
17
|
-
BSON_CORPUS_TESTS = Dir.glob("#{CURRENT_PATH}/
|
16
|
+
DRIVER_COMMON_BSON_TESTS = Dir.glob("#{CURRENT_PATH}/spec_tests/data/decimal128/*.json").sort
|
17
|
+
BSON_CORPUS_TESTS = Dir.glob("#{CURRENT_PATH}/spec_tests/data/corpus/*.json").sort
|
18
|
+
BSON_CORPUS_LEGACY_TESTS = Dir.glob("#{CURRENT_PATH}/spec_tests/data/corpus_legacy/*.json").sort
|
18
19
|
|
19
20
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
20
21
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
|
@@ -54,3 +55,9 @@ class AlternateIO < StringIO
|
|
54
55
|
super.chr
|
55
56
|
end
|
56
57
|
end
|
58
|
+
|
59
|
+
RSpec.configure do |config|
|
60
|
+
config.expect_with :rspec do |c|
|
61
|
+
c.syntax = [:should, :expect]
|
62
|
+
end
|
63
|
+
end
|
@@ -1,13 +1,14 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
+
require 'runners/corpus_legacy'
|
2
3
|
|
3
|
-
describe 'Driver BSON Corpus spec tests' do
|
4
|
+
describe 'Driver BSON Corpus Legacy spec tests' do
|
4
5
|
|
5
|
-
|
6
|
+
BSON_CORPUS_LEGACY_TESTS.each do |path|
|
6
7
|
basename = File.basename(path)
|
7
8
|
# All of the tests in the failures subdir are failing apparently
|
8
9
|
#basename = path.sub(/.*corpus-tests\//, '')
|
9
10
|
|
10
|
-
spec = BSON::
|
11
|
+
spec = BSON::CorpusLegacy::Spec.new(path)
|
11
12
|
|
12
13
|
context("(#{basename}): #{spec.description}") do
|
13
14
|
|
@@ -29,7 +30,6 @@ describe 'Driver BSON Corpus spec tests' do
|
|
29
30
|
context 'when the document can be represented as extended json', if: test.test_extjson? do
|
30
31
|
|
31
32
|
it 'decodes from the given bson, then encodes the document as extended json correctly' do
|
32
|
-
skip 'The extended json in this test case does not match' unless (test.extjson_from_bson == test.correct_extjson)
|
33
33
|
expect(test.extjson_from_bson).to eq(test.correct_extjson)
|
34
34
|
expect(test.extjson_from_bson[test.test_key]).to eq(test.correct_extjson[test.test_key])
|
35
35
|
end
|
@@ -0,0 +1,124 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'runners/corpus'
|
3
|
+
|
4
|
+
describe 'BSON Corpus spec tests' do
|
5
|
+
|
6
|
+
BSON_CORPUS_TESTS.each do |path|
|
7
|
+
basename = File.basename(path)
|
8
|
+
# All of the tests in the failures subdir are failing apparently
|
9
|
+
#basename = path.sub(/.*corpus-tests\//, '')
|
10
|
+
|
11
|
+
spec = BSON::Corpus::Spec.new(path)
|
12
|
+
|
13
|
+
context("(#{basename}): #{spec.description}") do
|
14
|
+
|
15
|
+
spec.valid_tests&.each do |test|
|
16
|
+
|
17
|
+
context("valid: #{test.description}") do
|
18
|
+
|
19
|
+
let(:decoded_canonical_bson) do
|
20
|
+
BSON::Document.from_bson(BSON::ByteBuffer.new(test.canonical_bson), mode: :bson)
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'round-trips canonical bson' do
|
24
|
+
decoded_canonical_bson.to_bson.to_s.should == test.canonical_bson
|
25
|
+
end
|
26
|
+
|
27
|
+
=begin
|
28
|
+
it 'converts bson to canonical extended json' do
|
29
|
+
pending
|
30
|
+
raise NotImplementedError
|
31
|
+
end
|
32
|
+
=end
|
33
|
+
|
34
|
+
it 'converts bson to canonical extended json' do
|
35
|
+
decoded_canonical_bson.as_extended_json.should == test.canonical_extjson_doc
|
36
|
+
end
|
37
|
+
|
38
|
+
if test.relaxed_extjson
|
39
|
+
it 'converts bson to relaxed extended json' do
|
40
|
+
decoded_canonical_bson.as_extended_json(mode: :relaxed).should == test.relaxed_extjson_doc
|
41
|
+
end
|
42
|
+
|
43
|
+
let(:parsed_relaxed_extjson) do
|
44
|
+
BSON::ExtJSON.parse_obj(test.relaxed_extjson_doc, mode: :bson)
|
45
|
+
end
|
46
|
+
|
47
|
+
let(:round_tripped_relaxed_extjson) do
|
48
|
+
parsed_relaxed_extjson.as_extended_json(mode: :relaxed)
|
49
|
+
end
|
50
|
+
|
51
|
+
# Relaxed extended json may parse into something other than the
|
52
|
+
# canonical bson. For example, relaxed extjson representation for
|
53
|
+
# a small int64 is a number that would serialize to an int32.
|
54
|
+
# But round-tripping extended json back to extjson should produce
|
55
|
+
# the same representation we started with.
|
56
|
+
it 'round-trips relaxed extended json' do
|
57
|
+
round_tripped_relaxed_extjson.should == test.relaxed_extjson_doc
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
if test.degenerate_bson
|
62
|
+
|
63
|
+
let(:decoded_degenerate_bson) do
|
64
|
+
BSON::Document.from_bson(BSON::ByteBuffer.new(test.degenerate_bson), mode: :relaxed)
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'round-trips degenerate bson to canonical bson' do
|
68
|
+
decoded_degenerate_bson.to_bson.to_s.should == test.canonical_bson
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
let(:parsed_canonical_extjson) do
|
73
|
+
BSON::ExtJSON.parse_obj(test.canonical_extjson_doc, mode: :bson)
|
74
|
+
end
|
75
|
+
|
76
|
+
unless test.lossy?
|
77
|
+
it 'converts canonical extended json to bson' do
|
78
|
+
parsed_canonical_extjson.to_bson.to_s.should == test.canonical_bson
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
spec.decode_error_tests&.each do |test|
|
86
|
+
|
87
|
+
context("decode error: #{test.description}") do
|
88
|
+
|
89
|
+
let(:decoded_bson) do
|
90
|
+
BSON::Document.from_bson(BSON::ByteBuffer.new(test.bson), mode: :bson)
|
91
|
+
end
|
92
|
+
|
93
|
+
# Until bson-ruby gets an exception hierarchy, we can only rescue
|
94
|
+
# the basic Exception here.
|
95
|
+
# https://jira.mongodb.org/browse/RUBY-1806
|
96
|
+
it 'raises an exception' do
|
97
|
+
expect do
|
98
|
+
decoded_bson
|
99
|
+
end.to raise_error(Exception)
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
spec.parse_error_tests&.each do |test|
|
105
|
+
|
106
|
+
context("parse error: #{test.description}") do
|
107
|
+
|
108
|
+
let(:parsed_extjson) do
|
109
|
+
BSON::ExtJSON.parse(test.string, mode: :bson)
|
110
|
+
end
|
111
|
+
|
112
|
+
# Until bson-ruby gets an exception hierarchy, we can only rescue
|
113
|
+
# the basic Exception here.
|
114
|
+
# https://jira.mongodb.org/browse/RUBY-1806
|
115
|
+
it 'raises an exception' do
|
116
|
+
expect do
|
117
|
+
parsed_extjson
|
118
|
+
end.to raise_error(Exception)
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
There are the following deliberate changes made to the corpus tests in Ruby:
|
2
|
+
|
3
|
+
1. In double.js, Ruby appears to offer less precision than the spec tests
|
4
|
+
demand:
|
5
|
+
|
6
|
+
irb(main):001:0> -1.23456789012345677E+18
|
7
|
+
=> -1.2345678901234568e+18
|
8
|
+
|
9
|
+
Because of this, -1.23456789012345677E+18 was changed to -1.2345678901234568e+18.
|
10
|
+
The "e" was lowercased as well. Both the precision reduction and the lowercasing
|
11
|
+
of "e" changes are also present in the Python driver, which appears to be
|
12
|
+
affected by the same precision limitation.
|
13
|
+
|
14
|
+
2. In datetime.js, the millisecond component of iso8601 serialization of
|
15
|
+
timestamps is always present, even if it is zero.
|
@@ -0,0 +1,49 @@
|
|
1
|
+
{
|
2
|
+
"description": "Array",
|
3
|
+
"bson_type": "0x04",
|
4
|
+
"test_key": "a",
|
5
|
+
"valid": [
|
6
|
+
{
|
7
|
+
"description": "Empty",
|
8
|
+
"canonical_bson": "0D000000046100050000000000",
|
9
|
+
"canonical_extjson": "{\"a\" : []}"
|
10
|
+
},
|
11
|
+
{
|
12
|
+
"description": "Single Element Array",
|
13
|
+
"canonical_bson": "140000000461000C0000001030000A0000000000",
|
14
|
+
"canonical_extjson": "{\"a\" : [{\"$numberInt\": \"10\"}]}"
|
15
|
+
},
|
16
|
+
{
|
17
|
+
"description": "Single Element Array with index set incorrectly to empty string",
|
18
|
+
"degenerate_bson": "130000000461000B00000010000A0000000000",
|
19
|
+
"canonical_bson": "140000000461000C0000001030000A0000000000",
|
20
|
+
"canonical_extjson": "{\"a\" : [{\"$numberInt\": \"10\"}]}"
|
21
|
+
},
|
22
|
+
{
|
23
|
+
"description": "Single Element Array with index set incorrectly to ab",
|
24
|
+
"degenerate_bson": "150000000461000D000000106162000A0000000000",
|
25
|
+
"canonical_bson": "140000000461000C0000001030000A0000000000",
|
26
|
+
"canonical_extjson": "{\"a\" : [{\"$numberInt\": \"10\"}]}"
|
27
|
+
},
|
28
|
+
{
|
29
|
+
"description": "Multi Element Array with duplicate indexes",
|
30
|
+
"degenerate_bson": "1b000000046100130000001030000a000000103000140000000000",
|
31
|
+
"canonical_bson": "1b000000046100130000001030000a000000103100140000000000",
|
32
|
+
"canonical_extjson": "{\"a\" : [{\"$numberInt\": \"10\"}, {\"$numberInt\": \"20\"}]}"
|
33
|
+
}
|
34
|
+
],
|
35
|
+
"decodeErrors": [
|
36
|
+
{
|
37
|
+
"description": "Array length too long: eats outer terminator",
|
38
|
+
"bson": "140000000461000D0000001030000A0000000000"
|
39
|
+
},
|
40
|
+
{
|
41
|
+
"description": "Array length too short: leaks terminator",
|
42
|
+
"bson": "140000000461000B0000001030000A0000000000"
|
43
|
+
},
|
44
|
+
{
|
45
|
+
"description": "Invalid Array: bad string length in field",
|
46
|
+
"bson": "1A00000004666F6F00100000000230000500000062617A000000"
|
47
|
+
}
|
48
|
+
]
|
49
|
+
}
|
@@ -0,0 +1,85 @@
|
|
1
|
+
{
|
2
|
+
"description": "Binary type",
|
3
|
+
"bson_type": "0x05",
|
4
|
+
"test_key": "x",
|
5
|
+
"valid": [
|
6
|
+
{
|
7
|
+
"description": "subtype 0x00 (Zero-length)",
|
8
|
+
"canonical_bson": "0D000000057800000000000000",
|
9
|
+
"canonical_extjson": "{\"x\" : { \"$binary\" : {\"base64\" : \"\", \"subType\" : \"00\"}}}"
|
10
|
+
},
|
11
|
+
{
|
12
|
+
"description": "subtype 0x00 (Zero-length, keys reversed)",
|
13
|
+
"canonical_bson": "0D000000057800000000000000",
|
14
|
+
"canonical_extjson": "{\"x\" : { \"$binary\" : {\"base64\" : \"\", \"subType\" : \"00\"}}}",
|
15
|
+
"degenerate_extjson": "{\"x\" : { \"$binary\" : {\"subType\" : \"00\", \"base64\" : \"\"}}}"
|
16
|
+
},
|
17
|
+
{
|
18
|
+
"description": "subtype 0x00",
|
19
|
+
"canonical_bson": "0F0000000578000200000000FFFF00",
|
20
|
+
"canonical_extjson": "{\"x\" : { \"$binary\" : {\"base64\" : \"//8=\", \"subType\" : \"00\"}}}"
|
21
|
+
},
|
22
|
+
{
|
23
|
+
"description": "subtype 0x01",
|
24
|
+
"canonical_bson": "0F0000000578000200000001FFFF00",
|
25
|
+
"canonical_extjson": "{\"x\" : { \"$binary\" : {\"base64\" : \"//8=\", \"subType\" : \"01\"}}}"
|
26
|
+
},
|
27
|
+
{
|
28
|
+
"description": "subtype 0x02",
|
29
|
+
"canonical_bson": "13000000057800060000000202000000FFFF00",
|
30
|
+
"canonical_extjson": "{\"x\" : { \"$binary\" : {\"base64\" : \"//8=\", \"subType\" : \"02\"}}}"
|
31
|
+
},
|
32
|
+
{
|
33
|
+
"description": "subtype 0x03",
|
34
|
+
"canonical_bson": "1D000000057800100000000373FFD26444B34C6990E8E7D1DFC035D400",
|
35
|
+
"canonical_extjson": "{\"x\" : { \"$binary\" : {\"base64\" : \"c//SZESzTGmQ6OfR38A11A==\", \"subType\" : \"03\"}}}"
|
36
|
+
},
|
37
|
+
{
|
38
|
+
"description": "subtype 0x04",
|
39
|
+
"canonical_bson": "1D000000057800100000000473FFD26444B34C6990E8E7D1DFC035D400",
|
40
|
+
"canonical_extjson": "{\"x\" : { \"$binary\" : {\"base64\" : \"c//SZESzTGmQ6OfR38A11A==\", \"subType\" : \"04\"}}}"
|
41
|
+
},
|
42
|
+
{
|
43
|
+
"description": "subtype 0x05",
|
44
|
+
"canonical_bson": "1D000000057800100000000573FFD26444B34C6990E8E7D1DFC035D400",
|
45
|
+
"canonical_extjson": "{\"x\" : { \"$binary\" : {\"base64\" : \"c//SZESzTGmQ6OfR38A11A==\", \"subType\" : \"05\"}}}"
|
46
|
+
},
|
47
|
+
{
|
48
|
+
"description": "subtype 0x80",
|
49
|
+
"canonical_bson": "0F0000000578000200000080FFFF00",
|
50
|
+
"canonical_extjson": "{\"x\" : { \"$binary\" : {\"base64\" : \"//8=\", \"subType\" : \"80\"}}}"
|
51
|
+
},
|
52
|
+
{
|
53
|
+
"description": "$type query operator (conflicts with legacy $binary form with $type field)",
|
54
|
+
"canonical_bson": "1F000000037800170000000224747970650007000000737472696E67000000",
|
55
|
+
"canonical_extjson": "{\"x\" : { \"$type\" : \"string\"}}"
|
56
|
+
},
|
57
|
+
{
|
58
|
+
"description": "$type query operator (conflicts with legacy $binary form with $type field)",
|
59
|
+
"canonical_bson": "180000000378001000000010247479706500020000000000",
|
60
|
+
"canonical_extjson": "{\"x\" : { \"$type\" : {\"$numberInt\": \"2\"}}}"
|
61
|
+
}
|
62
|
+
],
|
63
|
+
"decodeErrors": [
|
64
|
+
{
|
65
|
+
"description": "Length longer than document",
|
66
|
+
"bson": "1D000000057800FF0000000573FFD26444B34C6990E8E7D1DFC035D400"
|
67
|
+
},
|
68
|
+
{
|
69
|
+
"description": "Negative length",
|
70
|
+
"bson": "0D000000057800FFFFFFFF0000"
|
71
|
+
},
|
72
|
+
{
|
73
|
+
"description": "subtype 0x02 length too long ",
|
74
|
+
"bson": "13000000057800060000000203000000FFFF00"
|
75
|
+
},
|
76
|
+
{
|
77
|
+
"description": "subtype 0x02 length too short",
|
78
|
+
"bson": "13000000057800060000000201000000FFFF00"
|
79
|
+
},
|
80
|
+
{
|
81
|
+
"description": "subtype 0x02 length negative one",
|
82
|
+
"bson": "130000000578000600000002FFFFFFFFFFFF00"
|
83
|
+
}
|
84
|
+
]
|
85
|
+
}
|
@@ -0,0 +1,27 @@
|
|
1
|
+
{
|
2
|
+
"description": "Boolean",
|
3
|
+
"bson_type": "0x08",
|
4
|
+
"test_key": "b",
|
5
|
+
"valid": [
|
6
|
+
{
|
7
|
+
"description": "True",
|
8
|
+
"canonical_bson": "090000000862000100",
|
9
|
+
"canonical_extjson": "{\"b\" : true}"
|
10
|
+
},
|
11
|
+
{
|
12
|
+
"description": "False",
|
13
|
+
"canonical_bson": "090000000862000000",
|
14
|
+
"canonical_extjson": "{\"b\" : false}"
|
15
|
+
}
|
16
|
+
],
|
17
|
+
"decodeErrors": [
|
18
|
+
{
|
19
|
+
"description": "Invalid boolean value of 2",
|
20
|
+
"bson": "090000000862000200"
|
21
|
+
},
|
22
|
+
{
|
23
|
+
"description": "Invalid boolean value of -1",
|
24
|
+
"bson": "09000000086200FF00"
|
25
|
+
}
|
26
|
+
]
|
27
|
+
}
|
@@ -0,0 +1,67 @@
|
|
1
|
+
{
|
2
|
+
"description": "Javascript Code",
|
3
|
+
"bson_type": "0x0D",
|
4
|
+
"test_key": "a",
|
5
|
+
"valid": [
|
6
|
+
{
|
7
|
+
"description": "Empty string",
|
8
|
+
"canonical_bson": "0D0000000D6100010000000000",
|
9
|
+
"canonical_extjson": "{\"a\" : {\"$code\" : \"\"}}"
|
10
|
+
},
|
11
|
+
{
|
12
|
+
"description": "Single character",
|
13
|
+
"canonical_bson": "0E0000000D610002000000620000",
|
14
|
+
"canonical_extjson": "{\"a\" : {\"$code\" : \"b\"}}"
|
15
|
+
},
|
16
|
+
{
|
17
|
+
"description": "Multi-character",
|
18
|
+
"canonical_bson": "190000000D61000D0000006162616261626162616261620000",
|
19
|
+
"canonical_extjson": "{\"a\" : {\"$code\" : \"abababababab\"}}"
|
20
|
+
},
|
21
|
+
{
|
22
|
+
"description": "two-byte UTF-8 (\u00e9)",
|
23
|
+
"canonical_bson": "190000000261000D000000C3A9C3A9C3A9C3A9C3A9C3A90000",
|
24
|
+
"canonical_extjson": "{\"a\" : \"\\u00e9\\u00e9\\u00e9\\u00e9\\u00e9\\u00e9\"}"
|
25
|
+
},
|
26
|
+
{
|
27
|
+
"description": "three-byte UTF-8 (\u2606)",
|
28
|
+
"canonical_bson": "190000000261000D000000E29886E29886E29886E298860000",
|
29
|
+
"canonical_extjson": "{\"a\" : \"\\u2606\\u2606\\u2606\\u2606\"}"
|
30
|
+
},
|
31
|
+
{
|
32
|
+
"description": "Embedded nulls",
|
33
|
+
"canonical_bson": "190000000261000D0000006162006261620062616261620000",
|
34
|
+
"canonical_extjson": "{\"a\" : \"ab\\u0000bab\\u0000babab\"}"
|
35
|
+
}
|
36
|
+
],
|
37
|
+
"decodeErrors": [
|
38
|
+
{
|
39
|
+
"description": "bad code string length: 0 (but no 0x00 either)",
|
40
|
+
"bson": "0C0000000261000000000000"
|
41
|
+
},
|
42
|
+
{
|
43
|
+
"description": "bad code string length: -1",
|
44
|
+
"bson": "0C000000026100FFFFFFFF00"
|
45
|
+
},
|
46
|
+
{
|
47
|
+
"description": "bad code string length: eats terminator",
|
48
|
+
"bson": "10000000026100050000006200620000"
|
49
|
+
},
|
50
|
+
{
|
51
|
+
"description": "bad code string length: longer than rest of document",
|
52
|
+
"bson": "120000000200FFFFFF00666F6F6261720000"
|
53
|
+
},
|
54
|
+
{
|
55
|
+
"description": "code string is not null-terminated",
|
56
|
+
"bson": "1000000002610004000000616263FF00"
|
57
|
+
},
|
58
|
+
{
|
59
|
+
"description": "empty code string, but extra null",
|
60
|
+
"bson": "0E00000002610001000000000000"
|
61
|
+
},
|
62
|
+
{
|
63
|
+
"description": "invalid UTF-8",
|
64
|
+
"bson": "0E00000002610002000000E90000"
|
65
|
+
}
|
66
|
+
]
|
67
|
+
}
|
@@ -0,0 +1,78 @@
|
|
1
|
+
{
|
2
|
+
"description": "Javascript Code with Scope",
|
3
|
+
"bson_type": "0x0F",
|
4
|
+
"test_key": "a",
|
5
|
+
"valid": [
|
6
|
+
{
|
7
|
+
"description": "Empty code string, empty scope",
|
8
|
+
"canonical_bson": "160000000F61000E0000000100000000050000000000",
|
9
|
+
"canonical_extjson": "{\"a\" : {\"$code\" : \"\", \"$scope\" : {}}}"
|
10
|
+
},
|
11
|
+
{
|
12
|
+
"description": "Non-empty code string, empty scope",
|
13
|
+
"canonical_bson": "1A0000000F610012000000050000006162636400050000000000",
|
14
|
+
"canonical_extjson": "{\"a\" : {\"$code\" : \"abcd\", \"$scope\" : {}}}"
|
15
|
+
},
|
16
|
+
{
|
17
|
+
"description": "Empty code string, non-empty scope",
|
18
|
+
"canonical_bson": "1D0000000F61001500000001000000000C000000107800010000000000",
|
19
|
+
"canonical_extjson": "{\"a\" : {\"$code\" : \"\", \"$scope\" : {\"x\" : {\"$numberInt\": \"1\"}}}}"
|
20
|
+
},
|
21
|
+
{
|
22
|
+
"description": "Non-empty code string and non-empty scope",
|
23
|
+
"canonical_bson": "210000000F6100190000000500000061626364000C000000107800010000000000",
|
24
|
+
"canonical_extjson": "{\"a\" : {\"$code\" : \"abcd\", \"$scope\" : {\"x\" : {\"$numberInt\": \"1\"}}}}"
|
25
|
+
},
|
26
|
+
{
|
27
|
+
"description": "Unicode and embedded null in code string, empty scope",
|
28
|
+
"canonical_bson": "1A0000000F61001200000005000000C3A9006400050000000000",
|
29
|
+
"canonical_extjson": "{\"a\" : {\"$code\" : \"\\u00e9\\u0000d\", \"$scope\" : {}}}"
|
30
|
+
}
|
31
|
+
],
|
32
|
+
"decodeErrors": [
|
33
|
+
{
|
34
|
+
"description": "field length zero",
|
35
|
+
"bson": "280000000F6100000000000500000061626364001300000010780001000000107900010000000000"
|
36
|
+
},
|
37
|
+
{
|
38
|
+
"description": "field length negative",
|
39
|
+
"bson": "280000000F6100FFFFFFFF0500000061626364001300000010780001000000107900010000000000"
|
40
|
+
},
|
41
|
+
{
|
42
|
+
"description": "field length too short (less than minimum size)",
|
43
|
+
"bson": "160000000F61000D0000000100000000050000000000"
|
44
|
+
},
|
45
|
+
{
|
46
|
+
"description": "field length too short (truncates scope)",
|
47
|
+
"bson": "280000000F61001F0000000500000061626364001300000010780001000000107900010000000000"
|
48
|
+
},
|
49
|
+
{
|
50
|
+
"description": "field length too long (clips outer doc)",
|
51
|
+
"bson": "280000000F6100210000000500000061626364001300000010780001000000107900010000000000"
|
52
|
+
},
|
53
|
+
{
|
54
|
+
"description": "field length too long (longer than outer doc)",
|
55
|
+
"bson": "280000000F6100FF0000000500000061626364001300000010780001000000107900010000000000"
|
56
|
+
},
|
57
|
+
{
|
58
|
+
"description": "bad code string: length too short",
|
59
|
+
"bson": "280000000F6100200000000400000061626364001300000010780001000000107900010000000000"
|
60
|
+
},
|
61
|
+
{
|
62
|
+
"description": "bad code string: length too long (clips scope)",
|
63
|
+
"bson": "280000000F6100200000000600000061626364001300000010780001000000107900010000000000"
|
64
|
+
},
|
65
|
+
{
|
66
|
+
"description": "bad code string: negative length",
|
67
|
+
"bson": "280000000F610020000000FFFFFFFF61626364001300000010780001000000107900010000000000"
|
68
|
+
},
|
69
|
+
{
|
70
|
+
"description": "bad code string: length longer than field",
|
71
|
+
"bson": "280000000F610020000000FF00000061626364001300000010780001000000107900010000000000"
|
72
|
+
},
|
73
|
+
{
|
74
|
+
"description": "bad scope doc (field has bad string length)",
|
75
|
+
"bson": "1C0000000F001500000001000000000C000000020000000000000000"
|
76
|
+
}
|
77
|
+
]
|
78
|
+
}
|