anchor.diff:  padding_test() ->
       Set = ?set:from_binary(<<0:8, 0:6, 1:1, 0:1>>, 15),
       ?assert(?set:is_member(14, Set)),
  -    ?assert(not ?set:is_member(15, Set)).
  +    ?assertError(badarg, ?set:is_member(15, Set)).
   
   %% If the padding is invalid, the conversion from
   %% bitfield to pieceset should crash.
  
positive.code: %% Piece indexes can never be less than zero
  negative_index_test() ->
      ?assertError(badarg, ?set:is_member(-1, undefined)).
  
  %%
  %% Modifying the contents of a pieceset
  
negative.code:     end,
      #pieceset{size=Size, elements=Elements}.
  
  %% @doc
  %% Convert a piece set to a bitfield, the bitfield will
  %% be padded with at most 7 bits set to zero.
  %% @end
  to_binary(Pieceset) ->
      #pieceset{size=Size, elements=Elements} = Pieceset,
      PaddingLen = paddinglen(Size),
      <<Elements:Size, 0:PaddingLen>>.
  
  %% @doc
  %% Returns true if the piece is a member of the piece set,
  %% false if not. If the piece index is negative or is larger
  %% than the size of this piece set, the function exits with badarg.
  %% @end
  is_member(PieceIndex, _) when PieceIndex < 0 ->
      error(badarg);
  is_member(PieceIndex, Pieceset) ->
      #pieceset{size=Size, elements=Elements} = Pieceset,
      case PieceIndex < Size of
          false ->
              error(badarg);
          true ->
              (Elements band piecemask(PieceIndex, Size)) > 0
      end.
  
  %% @doc
  %% Insert a piece into the piece index. If the piece index is
  %% negative or larger than the size of this piece set, this
  %% function exists with the reason badarg.
  %% @end
  insert(PieceIndex, _) when PieceIndex < 0 ->
      error(badarg);
  insert(PieceIndex, Pieceset) ->
  