anchor.diff:  %% Size pieces, as a set returned from new/1 is.
   %% The bitfield is expected to not be padded with more than 7 bits.
   %% @end
  +-spec from_binary(binary(), pos_integer()) -> pieceset().
   from_binary(Bin, Size) when is_binary(Bin) ->
       PaddingLen = paddinglen(Size),
       <<_:Size, PaddingValue:PaddingLen>> = Bin,
  
positive.code: -export([new/1,
           from_binary/2,
           to_binary/1,
           is_member/2,
           insert/2,
           intersection/2]).
  
  -record(pieceset, {
      size :: pos_integer(),
  
negative.code:     Set = ?set:new(8),
      ?assertError(badarg, ?set:is_member(8, Set)).
  
  %% An empty piece set should contain 0 pieces
  empty_size_test() ->
      ?assertEqual(0, ?set:size(?set:new(8))),
      ?assertEqual(0, ?set:size(?set:new(14))).
  
  full_size_test() ->
      Set0 = ?set:from_binary(<<255:8>>, 8),
      ?assertEqual(8, ?set:size(Set0)),
      Set1 = ?set:from_binary(<<255:8, 1:1, 0:7>>, 9),
      ?assertEqual(9, ?set:size(Set1)).
  
  %% An empty set should be converted to an empty list
  empty_list_test() ->
      Set = ?set:new(8),
      ?assertEqual([], ?set:to_list(Set)).
  
  %% Expect the list to be ordered from smallest to largest
  list_order_test() ->
      Set = ?set:from_binary(<<1:1, 0:7, 1:1, 0:7>>, 9),
      ?assertEqual([0,8], ?set:to_list(Set)).
  
  %% Expect an empty list to be converted to an empty set
  from_empty_list_test() ->
      Set0 = ?set:new(8),
      Set1 = ?set:from_list([], 8),
      ?assertEqual(Set0, Set1).
  
  from_full_list_test() ->
      Set0 = ?set:from_binary(<<255:8>>, 8),
      Set1 = ?set:from_list(lists:seq(0,7), 8),
      ?assertEqual(Set0, Set1).
  
  %%
  %% Modifying the contents of a pieceset
  %%
  