% Regression test function (black blox) for FreeMat v4.0
% This function is autogenerated by helpgen.
function bbtest_success = bbtest_fseek
  bbtest_success = 1;
NumErrors = 0;
try
  % First we create the file

catch
  NumErrors = NumErrors + 1;
end
try
  fp = fopen('test.dat','wb');

catch
  NumErrors = NumErrors + 1;
end
try
  fwrite(fp,float(rand(4096,1)));

catch
  NumErrors = NumErrors + 1;
end
try
  fclose(fp);

catch
  NumErrors = NumErrors + 1;
end
try
  % Now we open it

catch
  NumErrors = NumErrors + 1;
end
try
  fp = fopen('test.dat','rb');

catch
  NumErrors = NumErrors + 1;
end
try
  % Read the whole thing

catch
  NumErrors = NumErrors + 1;
end
try
  x = fread(fp,[1,inf],'float');

catch
  NumErrors = NumErrors + 1;
end
try
  % Rewind to the beginning

catch
  NumErrors = NumErrors + 1;
end
try
  fseek(fp,0,'bof');

catch
  NumErrors = NumErrors + 1;
end
try
  % Read part of the file

catch
  NumErrors = NumErrors + 1;
end
try
  y = fread(fp,[1,1024],'float');

catch
  NumErrors = NumErrors + 1;
end
try
  who x y

catch
  NumErrors = NumErrors + 1;
end
try
  % Seek 2048 bytes into the file

catch
  NumErrors = NumErrors + 1;
end
try
  fseek(fp,2048,'cof');

catch
  NumErrors = NumErrors + 1;
end
try
  % Read 512 floats from the file

catch
  NumErrors = NumErrors + 1;
end
try
  x = fread(fp,[512,1],'float');

catch
  NumErrors = NumErrors + 1;
end
try
  % Close the file

catch
  NumErrors = NumErrors + 1;
end
try
  fclose(fp);

catch
  NumErrors = NumErrors + 1;
end
if (NumErrors ~= 0) bbtest_success = 0; return; end
