changeset 18297:1589b2fc74ae

imformats.m: add test for updating a format with invalid struct.
author Carnë Draug <carandraug@octave.org>
date Fri, 17 Jan 2014 19:09:42 +0000
parents c8d6ca222bcc
children 15db54c4a572
files scripts/image/imformats.m
diffstat 1 files changed, 11 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/image/imformats.m	Thu Jan 16 22:33:48 2014 -0800
+++ b/scripts/image/imformats.m	Fri Jan 17 19:09:42 2014 +0000
@@ -280,7 +280,6 @@
   end_try_catch
 endfunction
 
-
 ## changing the function to read
 %!testif HAVE_MAGICK
 %! fmt = imformats ("jpg");
@@ -318,10 +317,15 @@
 %! new_fmt = imformats ("jpg");
 %! assert (new_fmt.description, ori_fmt.description);
 
-## FIXME: how to test for error together with testif?
-## update to an invalid format
-#%!testif HAVE_MAGICK
-#%! fmt = imformats ("jpg");
-#%! fmt = rmfield (fmt, "read");
-#%! error imformats ("update", "jpg", fmt);
+## updating to an invalid format should cause an error
+%!testif HAVE_MAGICK
+%! fmt = imformats ("jpg");
+%! fmt = rmfield (fmt, "read");
+%! error_thrown = false;
+%! try
+%!   imformats ("update", "jpg", fmt);
+%! catch
+%!   error_thrown = true;
+%! end_try_catch
+%! assert (error_thrown, true);