function varargout = convert_units_test
%convert_units_TEST unit test for convert_units
%
%See also: convert_units, qp_unitconversion

OK = [];
chunks = {'m^3','m3','m^+3','(1/m-3)','1 m^3','m^3 1 ','		m3		'};

str_out  = '0.001*l/mg';

for i=1:length(chunks)

   str_in=[chunks{i},' kg^-1'  ];try;OK(end+1) = convert_units(str_in,str_out);catch;OK(end+1)=0;uerr(str_in,OK);end
   str_in=[chunks{i},' kg-1'   ];try;OK(end+1) = convert_units(str_in,str_out);catch;OK(end+1)=0;uerr(str_in,OK);end
   str_in=[chunks{i},'*kg^-1'  ];try;OK(end+1) = convert_units(str_in,str_out);catch;OK(end+1)=0;uerr(str_in,OK);end
   str_in=[chunks{i},'*kg-1'   ];try;OK(end+1) = convert_units(str_in,str_out);catch;OK(end+1)=0;uerr(str_in,OK);end
   str_in=[chunks{i},' *kg^-1' ];try;OK(end+1) = convert_units(str_in,str_out);catch;OK(end+1)=0;uerr(str_in,OK);end
   str_in=[chunks{i},' *kg-1'  ];try;OK(end+1) = convert_units(str_in,str_out);catch;OK(end+1)=0;uerr(str_in,OK);end
   str_in=[chunks{i},'* kg^-1' ];try;OK(end+1) = convert_units(str_in,str_out);catch;OK(end+1)=0;uerr(str_in,OK);end
   str_in=[chunks{i},'* kg-1'  ];try;OK(end+1) = convert_units(str_in,str_out);catch;OK(end+1)=0;uerr(str_in,OK);end
   str_in=[chunks{i},' * kg^-1'];try;OK(end+1) = convert_units(str_in,str_out);catch;OK(end+1)=0;uerr(str_in,OK);end
   str_in=[chunks{i},' * kg-1' ];try;OK(end+1) = convert_units(str_in,str_out);catch;OK(end+1)=0;uerr(str_in,OK);end
   str_in=[chunks{i},'\kg'     ];try;OK(end+1) = convert_units(str_in,str_out);catch;OK(end+1)=0;uerr(str_in,OK);end
   str_in=[chunks{i},'/kg'     ];try;OK(end+1) = convert_units(str_in,str_out);catch;OK(end+1)=0;uerr(str_in,OK);end
   str_in=[chunks{i},' \kg'    ];try;OK(end+1) = convert_units(str_in,str_out);catch;OK(end+1)=0;uerr(str_in,OK);end
   str_in=[chunks{i},' /kg'    ];try;OK(end+1) = convert_units(str_in,str_out);catch;OK(end+1)=0;uerr(str_in,OK);end
   str_in=[chunks{i},'\ kg'    ];try;OK(end+1) = convert_units(str_in,str_out);catch;OK(end+1)=0;uerr(str_in,OK);end
   str_in=[chunks{i},'/ kg'    ];try;OK(end+1) = convert_units(str_in,str_out);catch;OK(end+1)=0;uerr(str_in,OK);end
   str_in=[chunks{i},' \ kg'   ];try;OK(end+1) = convert_units(str_in,str_out);catch;OK(end+1)=0;uerr(str_in,OK);end
   str_in=[chunks{i},' / kg'   ];try;OK(end+1) = convert_units(str_in,str_out);catch;OK(end+1)=0;uerr(str_in,OK);end

end

   % This one should fail
   str_in='m3kg-1'              ;try;catch;OK(end+1) = convert_units(str_in,str_out2);end

if ~all(OK)
   disp(['fail rate: ',num2str(sum(OK==0)),'/',num2str(length(OK))])
end

varargout = {all(OK)};


function uerr(str_in,OK)


disp(['Error for unit combination no. ',num2str(length(OK)),' : ''',str_in,''''])