function r8vec_bracket4_test ( )

%*****************************************************************************80
%
%% r8vec_bracket4_test() tests r8vec_bracket4().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    05 August 2018
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'R8VEC_BRACKET4_TEST\n' );
  fprintf ( 1, '  R8VEC_BRACKET4 finds a pair of entries in a\n' );
  fprintf ( 1, '  sorted real array which bracket a value.\n' );

  n = 11;
  x = r8vec_indicator1 ( n );
  x = x - 0.25;
  x(6) = x(5);
  r8vec_print ( n, x, '  Sorted array:' );

  ntest = 6;
  xtest(1:6) = [ -10.1, 1.2, 4.5, 5.2, 10.4, 12.5 ];
  r8vec_print ( ntest, xtest, '  Values to be bracketed:' );

  left = r8vec_bracket4 ( n, x, ntest, xtest );

  fprintf ( 1, '\n' );
  fprintf ( 1, '  Item  Value  Left  Right\n' );
  fprintf ( 1, '\n' );
  for i = 1 : ntest
    fprintf ( 1, '    %2d  %6.2f  %2d  %2d\n', i, xtest(i), left(i), left(i)+1 );
  end

  return
end
