function bal_seq_successor_test ( )

%*****************************************************************************80
%
%% BAL_SEQ_SUCCESSOR_TEST tests BAL_SEQ_SUCCESSOR.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL 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, one at a time.\n' );

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

  while ( 1 )

    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
