function gray_code_successor_test ( )

%*****************************************************************************80
%
%% gray_code_successor_test() tests gray_code_successor().
%
%  Licensing:
%
%    This code is distributed under the MIT 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 ( true );

    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

