function comb_next_test ( )

%*****************************************************************************80
%
%% comb_next_test() tests comb_next().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    10 April 2009
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'comb_next_test():\n' );
  fprintf ( 1, '  comb_next() produces combinations.\n' );
 
  n = 5;

  for k= 1 : n

    fprintf ( 1, '\n' );
    fprintf ( 1, '  Combinations of size %d:\n', k );
    fprintf ( 1, '\n' );

    a = [];
    done = 1;

    while ( true )

      [ a, done ] = comb_next ( n, k, a, done );
 
      if ( done )
        break
      end

      for i = 1 : k
        fprintf ( 1, '  %4d', a(i) );
      end
      fprintf ( 1, '\n' );

    end

  end

  return
end
