function OK = nc_actual_range_test

%nc_actual_range_test  test for nc_actual_range
%
% att char    actual_range = '1 2'
% att numeric actual_range = [1 2]
%
% 1D array edges no actual_range 
% 2D array edges no actual_range 
% 3D array edges no actual_range 
% 4D array edges no actual_range 
%

%See also: nc_actual_range, snctools


 ncfile = 'nc_actual_range_test.nc';

 nc_create_empty(ncfile)
 
 nc_adddim(ncfile,'dim1',2);
 nc_adddim(ncfile,'dim2',2);
 nc_adddim(ncfile,'dim3',2);
 nc_adddim(ncfile,'dim4',2);
 
i=1;
      v(i).Name = 'txt0';
      v(i).Datatype = 'double';
      v(i).Dimension = {}; 
      v(i).Attribute.Name  = 'actual_range';
      v(i).Attribute.Value = '1 2';
i=i+1;
      v(i).Name = 'num0';
      v(i).Datatype = 'double';
      v(i).Dimension = {}; 
      v(i).Attribute.Name  = 'actual_range';
      v(i).Attribute.Value = [1 2];
i=i+1;
      v(i).Name = 'val0';
      v(i).Datatype = 'double';
      v(i).Dimension = {}; 
      
i=i+1;
      v(i).Name = 'txt1';
      v(i).Datatype = 'double';
      v(i).Dimension = {'dim1'}; 
      v(i).Attribute.Name  = 'actual_range';
      v(i).Attribute.Value = '1 2';
i=i+1;
      v(i).Name = 'num1';
      v(i).Datatype = 'double';
      v(i).Dimension = {'dim1'}; 
      v(i).Attribute.Name  = 'actual_range';
      v(i).Attribute.Value = [1 2];
i=i+1;
      v(i).Name = 'val1';
      v(i).Datatype = 'double';
      v(i).Dimension = {'dim1'}; 
      
i=i+1;
      v(i).Name = 'txt2';
      v(i).Datatype = 'double';
      v(i).Dimension = {'dim1','dim2'}; 
      v(i).Attribute.Name  = 'actual_range';
      v(i).Attribute.Value = '1 2';
i=i+1;
      v(i).Name = 'num2';
      v(i).Datatype = 'double';
      v(i).Dimension = {'dim1','dim2'}; 
      v(i).Attribute.Name  = 'actual_range';
      v(i).Attribute.Value = [1 2];
i=i+1;
      v(i).Name = 'val2';
      v(i).Datatype = 'double';
      v(i).Dimension = {'dim1','dim2'}; 
      
i=i+1;
      v(i).Name = 'txt3';
      v(i).Datatype = 'double';
      v(i).Dimension = {'dim1','dim2','dim3'}; 
      v(i).Attribute.Name  = 'actual_range';
      v(i).Attribute.Value = '1 2';
i=i+1;
      v(i).Name = 'num3';
      v(i).Datatype = 'double';
      v(i).Dimension = {'dim1','dim2','dim3'}; 
      v(i).Attribute.Name  = 'actual_range';
      v(i).Attribute.Value = [1 2];
i=i+1;
      v(i).Name = 'val3';
      v(i).Datatype = 'double';
      v(i).Dimension = {'dim1','dim2','dim3'}; 
      
i=i+1;
      v(i).Name = 'txt4';
      v(i).Datatype = 'double';
      v(i).Dimension = {'dim1','dim2','dim3','dim4'}; 
      v(i).Attribute.Name  = 'actual_range';
      v(i).Attribute.Value = '1 2';
i=i+1;
      v(i).Name = 'num4';
      v(i).Datatype = 'double';
      v(i).Dimension = {'dim1','dim2','dim3','dim4'}; 
      v(i).Attribute.Name  = 'actual_range';
      v(i).Attribute.Value = [1 2];
i=i+1;
      v(i).Name = 'val4';
      v(i).Datatype = 'double';
      v(i).Dimension = {'dim1','dim2','dim3','dim4'}; 
      
      for i=1:length(v)
      nc_addvar(ncfile,v(i));
      end

      nc_varput(ncfile,'val0',[1]);
      nc_varput(ncfile,'val1',[1 2]);
      nc_varput(ncfile,'val2',[1 1;2 2]);
      nc_varput(ncfile,'val3',repmat([1 1;2 2],[1 1 2]));
      nc_varput(ncfile,'val4',repmat([1 1;2 2],[1 1 2 2]));
      

%% att char

   OK = 1;
   
   %disp('text')
   OK(end+1) =isequal( nc_actual_range(ncfile,'txt0'),[1 2]);
   OK(end+1) =isequal( nc_actual_range(ncfile,'txt1'),[1 2]);
   OK(end+1) =isequal( nc_actual_range(ncfile,'txt2'),[1 2]);
   OK(end+1) =isequal( nc_actual_range(ncfile,'txt3'),[1 2]);
   OK(end+1) =isequal( nc_actual_range(ncfile,'txt4'),[1 2]);
   
   %disp('num')
   OK(end+1) = isequal(nc_actual_range(ncfile,'num0'),[1 2]);
   OK(end+1) = isequal(nc_actual_range(ncfile,'num1'),[1 2]);
   OK(end+1) = isequal(nc_actual_range(ncfile,'num2'),[1 2]);
   OK(end+1) = isequal(nc_actual_range(ncfile,'num3'),[1 2]);
   OK(end+1) = isequal(nc_actual_range(ncfile,'num4'),[1 2]);
   
   %disp('val')
   OK(end+1) = isequal(nc_actual_range(ncfile,'val0'),[1 1]);
   OK(end+1) = isequal(nc_actual_range(ncfile,'val1'),[1 2]);
   OK(end+1) = isequal(nc_actual_range(ncfile,'val2'),[1 2]);
   OK(end+1) = isequal(nc_actual_range(ncfile,'val3'),[1 2]);
   OK(end+1) = isequal(nc_actual_range(ncfile,'val4'),[1 2]);
   
   OK = all(OK)
