Skip to content

Commit c13d23b

Browse files
authored
DRIVERS-3123 add test skip and clarification (#1819)
* Allow drivers to skip the comparison test if the `Vector` type does not support comparison * Do not use `Binary.from_vector` in test example with non-zero ignored bits.
1 parent 28ffbc4 commit c13d23b

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

source/bson-binary-vector/tests/README.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,19 +101,22 @@ means that two single bit vectors in which 7 bits are ignored do not match unles
101101
server does.
102102

103103
```python
104-
b1 = Binary.from_vector([0b10000000], BinaryVectorDtype.PACKED_BIT, padding=7)
105-
assert b1 == Binary(b'\x10\x07\x80', subtype=9) # This is effectively a roundtrip.
106-
v1 = Binary.as_vector(b1)
104+
b1 = Binary(b'\x10\x07\x80', subtype=9) # 1-bit vector with all 0 ignored bits.
105+
b2 = Binary(b'\x10\x07\xff', subtype=9) # 1-bit vector with all 1 ignored bits.
106+
b3 = Binary.from_vector([0b10000000], BinaryVectorDtype.PACKED_BIT, padding=7) # Same data as b1.
107107

108-
b2 = Binary.from_vector([0b11111111], BinaryVectorDtype.PACKED_BIT, padding=7)
109-
assert b2 == Binary(b'\x10\x07\xff', subtype=9)
108+
v1 = Binary.as_vector(b1)
110109
v2 = Binary.as_vector(b2)
110+
v3 = Binary.as_vector(b3)
111111

112112
assert b1 != b2 # Unequal at naive Binary level
113113
assert v2 != v1 # Also chosen to be unequal at BinaryVector level as [255] != [128]
114+
assert b1 == b3 # Equal at naive Binary level
115+
assert v1 == v3 # Equal at the BinaryVector level
114116
```
115117

116-
Drivers MAY skip this test if they choose not to implement a `Vector` type.
118+
Drivers MAY skip this test if they choose not to implement a `Vector` type, or the type does not support comparison, or
119+
the type cannot be constructed with non-zero ignored bits.
117120

118121
## FAQ
119122

0 commit comments

Comments
 (0)