aboutsummaryrefslogtreecommitdiffstats
path: root/lib/stdlib/test/binref.erl
diff options
context:
space:
mode:
authorPatrik Nyblom <[email protected]>2010-04-29 20:06:55 +0200
committerBjörn Gustavsson <[email protected]>2010-05-17 15:51:50 +0200
commit1dad48ee9f2e1aba6a0ec69d9cf688705d6f187c (patch)
treed846c1e74473c6ee9504cb563cd8a1b3a06ce3fb /lib/stdlib/test/binref.erl
parent02af6209ed16b8588b76e8c1972000eee12ba225 (diff)
downloadotp-1dad48ee9f2e1aba6a0ec69d9cf688705d6f187c.tar.gz
otp-1dad48ee9f2e1aba6a0ec69d9cf688705d6f187c.tar.bz2
otp-1dad48ee9f2e1aba6a0ec69d9cf688705d6f187c.zip
Add binary:list_to_bin/1 and binary:copy/1,2
Add testcases for binary:list_to_bin/1 and binary:copy/1,2. Add reference implementation of list_to_bin/1.
Diffstat (limited to 'lib/stdlib/test/binref.erl')
-rw-r--r--lib/stdlib/test/binref.erl13
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/stdlib/test/binref.erl b/lib/stdlib/test/binref.erl
index e09a0f2743..2322d036a2 100644
--- a/lib/stdlib/test/binref.erl
+++ b/lib/stdlib/test/binref.erl
@@ -4,7 +4,8 @@
split/2,split/3,replace/3,replace/4,first/1,last/1,at/2,
part/2,part/3,copy/1,copy/2,encode_unsigned/1,encode_unsigned/2,
decode_unsigned/1,decode_unsigned/2,referenced_byte_size/1,
- longest_common_prefix/1,longest_common_suffix/1,bin_to_list/1, bin_to_list/2, bin_to_list/3 ]).
+ longest_common_prefix/1,longest_common_suffix/1,bin_to_list/1,
+ bin_to_list/2,bin_to_list/3,list_to_bin/1]).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -351,6 +352,16 @@ bin_to_list(Subject,A,B) ->
_:_ ->
erlang:error(badarg)
end.
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% list_to_bin
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+list_to_bin(List) ->
+ try
+ erlang:list_to_binary(List)
+ catch
+ _:_ ->
+ erlang:error(badarg)
+ end.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% longest_common_prefix