function perm1_next2_test ( )

%*****************************************************************************80
%
%% perm1_next2_test() tests perm1_next2().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    13 April 2009
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'perm1_next2_test():\n' );
  fprintf ( 1, '  perm1_next2() generates permutations of (1,...,N).\n' );
  fprintf ( 1, '\n' );
  
  n = 4;
  p = [];
  invers = [];
  done = 1;
 
  while ( true )

    [ p, invers, done ] = perm1_next2 ( n, p, invers, done );
 
    if ( done )
      break
    end

    perm1_print ( n, p, '' );

  end

  return
end
