function bal_seq_successor_test ( )

%*****************************************************************************80
%
%% bal_seq_successor_test() tests bal_seq_successor().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    25 November 2015
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'bal_seq_successor_test():\n' );
  fprintf ( 1, '  bal_seq_successor() lists balanced sequences of N items,\n' );
  fprintf ( 1, '  one at a time.\n' );

  n = 5;
  t = [];
  rank = -1;

  while ( true )

    rank_old = rank;

    [ t, rank ] = bal_seq_successor ( n, t, rank );

    if ( rank <= rank_old )
      break
    end

    fprintf ( 1, '    %3d  ', rank );
    for i = 1 : 2 * n
       fprintf ( 1, '%2d', t(i) );
    end
    fprintf ( 1, '\n' );

  end

  return
end
