diff options
author | Sverker Eriksson <[email protected]> | 2019-04-26 19:43:53 +0200 |
---|---|---|
committer | Sverker Eriksson <[email protected]> | 2019-04-26 19:43:53 +0200 |
commit | 01aa8b82dd0f8229355ffd2bb2bc8e8f496d2df6 (patch) | |
tree | 0a3ae48dfe7f442aa138d7c06fbf5444e9f7c8b6 /lib/erl_interface/test/ei_decode_encode_SUITE.erl | |
parent | 8f6d45ddc8b2b12376c252a30b267a822cad171a (diff) | |
download | otp-01aa8b82dd0f8229355ffd2bb2bc8e8f496d2df6.tar.gz otp-01aa8b82dd0f8229355ffd2bb2bc8e8f496d2df6.tar.bz2 otp-01aa8b82dd0f8229355ffd2bb2bc8e8f496d2df6.zip |
erl_interface: Tweak bit string encode/decode API
to support zero copy decoding
and bit offset arguments for future unaligned bit strings.
Diffstat (limited to 'lib/erl_interface/test/ei_decode_encode_SUITE.erl')
-rw-r--r-- | lib/erl_interface/test/ei_decode_encode_SUITE.erl | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/erl_interface/test/ei_decode_encode_SUITE.erl b/lib/erl_interface/test/ei_decode_encode_SUITE.erl index d8b0bce3ae..3451d9f503 100644 --- a/lib/erl_interface/test/ei_decode_encode_SUITE.erl +++ b/lib/erl_interface/test/ei_decode_encode_SUITE.erl @@ -122,9 +122,29 @@ test_ei_decode_encode(Config) when is_list(Config) -> [send_rec(P, <<16#dec0deb175:B/little>>) || B <- lists:seq(0,48)], + % And last an ugly duckling to test ei_encode_bitstring with bitoffs != 0 + encode_bitstring(P), + runner:recv_eot(P), ok. +encode_bitstring(P) -> + %% Send one bitstring to c-node + Bits = <<16#18f6d4b2907e5c3a1:66>>, + P ! {self(), {command, term_to_binary(Bits, [{minor_version, 2}])}}, + + %% and then receive and verify a number of different sub-bitstrings + receive_sub_bitstring(P, Bits, 0, bit_size(Bits)). + +receive_sub_bitstring(_, _, _, NBits) when NBits < 0 -> + ok; +receive_sub_bitstring(P, Bits, BitOffs, NBits) -> + <<_:BitOffs, Sub:NBits/bits, _/bits>> = Bits, + %%io:format("expecting term_to_binary(~p) = ~p\n", [Sub, term_to_binary(Sub)]), + {_B,Sub} = get_buf_and_term(P), + receive_sub_bitstring(P, Bits, BitOffs+1, NBits - ((NBits div 20)+1)). + + %% ######################################################################## %% |