Skip to content

Commit c5a75bc

Browse files
skinandboneszookzook
authored andcommitted
add BSON.Binary{subtype: :binary_old} encoder test
1 parent e97f909 commit c5a75bc

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

lib/bson/encoder.ex

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ defmodule BSON.Encoder do
1717
def encode(:BSON_max),
1818
do: ""
1919

20+
def encode(%BSON.Binary{binary: binary, subtype: :binary_old}) do
21+
subtype = subtype(:binary_old)
22+
size = IO.iodata_length(binary)
23+
[<<size + 4::int32>>, subtype, <<size::int32>>, binary]
24+
end
25+
2026
def encode(%BSON.Binary{binary: binary, subtype: subtype}) do
2127
subtype = subtype(subtype)
2228
[<<IO.iodata_length(binary)::int32>>, subtype | binary]

0 commit comments

Comments
 (0)