function gray_code_successor_test ( )

%*****************************************************************************80
%
%% GRAY_CODE_SUCCESSOR_TEST tests GRAY_CODE_SUCCESSOR.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    21 November 2015
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'GRAY_CODE_SUCCESSOR_TEST:\n' );
  fprintf ( 1, '  GRAY_CODE_SUCCESSOR returns the next Gray code.\n' );

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

  fprintf ( 1, '\n' );
  while ( 1 );

    rank_old = rank;

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

    if ( rank <= rank_old )
      break
    end

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

  end

  return
end

