File tree Expand file tree Collapse file tree 3 files changed +55
-24
lines changed Expand file tree Collapse file tree 3 files changed +55
-24
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1+ --TEST--
2+ Binary vector: Encoding PackedBit vector with non-zero, padded bits fails
3+ --DESCRIPTION--
4+ Binary vector prose test #1
5+ https://github.com/mongodb/specifications/blob/master/source/bson-binary-vector/tests/README.md#prose-tests
6+ --FILE--
7+ <?php
8+
9+ require_once __DIR__ . '/../utils/basic.inc ' ;
10+
11+ // PackedBit vector with padding:7 and non-zero bits is invalid
12+
13+
14+ /* PHPC does not allow constructing a PackedBit vector with non-zero, padded
15+ * bits. As a result, the corresponding decoding test (i.e. prose test #2)
16+ * cannot be implemented. */
17+ echo throws (function () {
18+ var_dump (new MongoDB \BSON \Binary ("\x10\x07\xff" , MongoDB \BSON \Binary::TYPE_VECTOR ));
19+ }, 'MongoDB\Driver\Exception\InvalidArgumentException ' ), "\n" ;
20+
21+ ?>
22+ ===DONE===
23+ <?php exit (0 ); ?>
24+ --EXPECT--
25+ OK: Got MongoDB\Driver\Exception\InvalidArgumentException
26+ Binary vector data is invalid
27+ ===DONE===
Original file line number Diff line number Diff line change 1+ --TEST--
2+ Binary vector: PackedBit vector comparisons
3+ --DESCRIPTION--
4+ Binary vector prose test #3
5+ https://github.com/mongodb/specifications/blob/master/source/bson-binary-vector/tests/README.md#prose-tests
6+ --FILE--
7+ <?php
8+
9+ require_once __DIR__ . '/../utils/basic.inc ' ;
10+
11+ /* Although PHPC does not allow constructing a vector with non-zero, padded
12+ * bits, we can still test comparisons between two valid vector objects
13+ * constructed from raw data and a PHP array, respectively. */
14+ $ b1 = new MongoDB \BSON \Binary ("\x10\x07\x80" , MongoDB \BSON \Binary::TYPE_VECTOR );
15+
16+ // PackedBit vector with padding:7 and all-zero bits (constructed from PHP array)
17+ $ b2 = MongoDB \BSON \Binary::fromVector ([1 ], MongoDB \BSON \VectorType::PackedBit);
18+
19+ var_dump ($ b1 == $ b2 );
20+ var_dump ($ b1 ->toArray () === $ b2 ->toArray ());
21+
22+ ?>
23+ ===DONE===
24+ <?php exit (0 ); ?>
25+ --EXPECT--
26+ bool(true)
27+ bool(true)
28+ ===DONE===
You can’t perform that action at this time.
0 commit comments