function subset_sum_next_test ( s, n, v )

%*****************************************************************************80
%
%% SUBSET_SUM_NEXT_TEST tests the SUBSET_SUM_NEXT library.
%
%  Licensing:
%
%    I don't care what you do with this code.
%
%  Modified:
%
%    14 July 2017
%
%  Author:
%
%    John Burkardt
%
%  Parameters:
%
%    Input, integer S, the desired sum.
%
%    Input, integer N, the number of values.
%
%    Input, integer V(N), the values.
%    These must be nonnegative, and sorted in ascending order.  
%    Duplicate values are allowed.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'SUBSET_SUM_NEXT_TEST:\n' );
  fprintf ( 1, '  SUBSET_SUM_NEXT finds the "next" subset of the values V\n' );
  fprintf ( 1, '  which sum to the desired total S.\n' );

  more = false;
  u = zeros ( n, 1 );
  t = 0;
  
  fprintf ( 1, '\n' );
  fprintf ( 1, '  Desired sum S = %d\n', s );
  fprintf ( 1, '  Number of targets = %d\n', n );
  fprintf ( 1, '  Targets:' );
  for i = 1 : n
    fprintf ( 1, ' %d', v(i) );
  end
  fprintf ( 1, '\n' );
  fprintf ( 1, '\n' );

  k = 0;
  
  while ( true )

    [ more, u, t ] = subset_sum_next ( s, n, v, more, u, t );
    if ( ~ more )
      break
    end

    k = k + 1;
    fprintf ( 1, '  %d:  %d = ', k, s );
    plus = false;
    for i = 1 : n
      if ( u(i) ~= 0 )
        if ( plus ) 
          fprintf ( 1, '%s', '+' );
        end
        fprintf ( 1, '%d', v(i) );
        plus = true;
      end
    end
    fprintf ( 1, '\n' );
  end
  
  return
end
