function ksub_next_test ( )

%*****************************************************************************80
%
%% KSUB_NEXT_TEST tests KSUB_NEXT.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    12 May 2018
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'KSUB_NEXT_TEST\n' );
  fprintf ( 1, '  KSUB_NEXT generates all K subsets of an N set\n' );
  fprintf ( 1, '  in lexicographic order.\n' );
  fprintf ( 1, '\n' );

  rank = 0;

  n = 5;
  k = 3;
  a = zeros ( k, 1 );
  more = false;
  m = 0;
  m2 = 0;
 
  while ( true )

    [ a, more, m, m2 ] = ksub_next ( n, k, a, more, m, m2 );

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

    if ( ~ more )
      break
    end

  end

  return
end
