function hexagon_quadrature_test ( rule, rule_name )

%*****************************************************************************80
%
%%  hexagon_quadrature_test() tests a hexagon quadrature rule.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    21 April 2019
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    @rule, a pointer to the rule function.
%
%    string rule_name, a name for the rule.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'hexagon_quadrature_test():\n' );
  fprintf ( 1, '  Test %s\n', rule_name );
  fprintf ( 1, '\n' );

  [ n, x, y, w, s ] = rule ( );
  degree_max = s;
  degree = 0;
  ex = 0;
  ey = degree;

  while ( true )

    if ( mod ( ex, 2 ) == 0 && mod ( ey, 2 ) == 0 )

      v = monomial_value_2d ( n, ex, ey, x, y );
      q = hexagon01_area ( ) * w' * v;
      exact = hexagon01_integral ( ex, ey );
      fprintf ( 1, '  %d: Integral x^%d y^%d dxdy = %g, exact = %g\n', degree, ex, ey, q, exact );

    end

    if ( ex < degree )
      ex = ex + 1;
      ey = ey - 1;
    elseif ( degree < degree_max )
      degree = degree + 1;
      ex = 0;
      ey = degree;
    else
      break;
    end

  end

  return
end

