# HG changeset patch # User Carnë Draug # Date 1389985782 0 # Node ID 1589b2fc74aef5c8be6210ded3a1960443ce4ae8 # Parent c8d6ca222bccbc8cbeb1fa3cf2a23639ec036319 imformats.m: add test for updating a format with invalid struct. diff -r c8d6ca222bcc -r 1589b2fc74ae scripts/image/imformats.m --- 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);