% **********************************************************************
%  Subroutine OkQuadrature_tests.m by www.boundary-element-method.com *
% **********************************************************************

% OkQuadrature_tests.m Version 1, Sept 2015
% by Stephen Kirkup, 
% http://www.researchgate.net/profile/Stephen_Kirkup
% School of Engineering
% University of Central Lancashire

% A set of tests for OkQuadrature.m
% Source of this code:
%  http://www.boundary-element-method.com/mfiles/OkQuadrature_tests.m
% Source of the user-guide:
%  http://www.boundary-element-method.com/mfiles/OkQuadrature_tests_m.pdf
% Source of the OkQuadrature code:
%  http://www.boundary-element-method.com/mfiles/OkQuadrature.m


function OkQuadrature_tests();
    passed=false;
    
    tolQuad=0.000001;

% Set up 8-point Gaussian quadrature rule    
    [wts,pts,n]=gl8();
    xStar=-1.0;
    
% Tests in the standard 8-point Gaussian quadrature rule
    '8 point Gaussian quadrature test'
    passed=OkQuadrature(n, wts, pts, xStar, tolQuad);
    if (passed) 
        'passed'
    else
        'failed'        
    end

% Set up 16-point (2x8 point) Gaussian quadrature rule
    '2x8 point composite Gaussian quadrature test'
    n2=2*n;
    wts2=[wts/2; wts/2];
    pts2=wts2;    
    for i=1:n
        pts2(i)=pts(i)/2.0;
        pts2(n+i)=0.5+pts2(i);
    end
    xStar=0.5;
    passed=OkQuadrature(n2, wts2, pts2, xStar, tolQuad);
    if (passed) 
        'passed'
    else
        'failed'        
    end
    