function setpart_check_test ( )

%*****************************************************************************80
%
%% setpart_check_test() tests setpart_check().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    31 December 2015
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'setpart_check test():\n' );
  fprintf ( 1, '  setpart_check() checks a set partition.\n' );
  
  for test = 1 : 6

    if ( test == 1 )
      m = 0;
      nsub = 3;
      s = [ 3, 6, 1, 4, 7, 2, 5, 8 ];
      index = [ 2, 5, 8 ];
    elseif ( test == 2 )
      m = 8;
      nsub = 0;
      s = [ 3, 6, 1, 4, 7, 2, 5, 8 ];
      index = [ 2, 5, 8 ];
    elseif ( test == 3 )
      m = 8;
      nsub = 3;
      s = [ 3, 6, 1, 4, 7, 2, 5, 8 ];
      index = [ 2, 8, 5 ];
    elseif ( test == 4 )
      m = 8;
      nsub = 3;
      s = [ 3, 6, 1, 4, 9, 2, 5, 8 ];
      index = [ 2, 5, 8 ];
    elseif ( test == 5 )
      m = 8;
      nsub = 3;
      s = [ 3, 6, 1, 4, 6, 2, 5, 8 ];
      index = [ 2, 5, 8 ];
    elseif ( test == 6 )
      m = 8;
      nsub = 3;
      s = [ 3, 6, 1, 4, 7, 2, 5, 8 ];
      index = [ 2, 5, 8 ];
    end

    fprintf ( 1, ' \n' );
    fprintf ( 1, '  The set partition\n' );
    fprintf ( 1, '  M = %d\n', m );
    fprintf ( 1, '  NSUB = %d\n', nsub );
    fprintf ( 1, ' \n' );
    jlo = 1;
    for i = 1 : nsub
      for j = jlo : index(i)
        fprintf ( 1, '%4d', s(j) );
      end
      fprintf ( 1, '\n');
      jlo = index(i) + 1;
    end

    check = setpart_check ( m, nsub, s, index );
    fprintf ( 1, '  Check = %5s\n', mat2str ( check ) );
    
  end

  return
end
