diff scripts/image/imformats.m @ 21489:ea81c2fdd568

imformats: return empty instead of error if there's no support for image IO. * __magick_read__.cc (__magick_formats__): if Octave was built without support for image IO, return an empty struct instead of error. If we have no support for image format, it doesn't matter if that's because of limited configuration on the GraphicsMagick build or Octave. Remember we can't even promise support for all formats at the same time, that's dependent on the configuration of GraphicsMagick. * imformats.m: add simple test for even when we were built without support for image IO.
author Carnë Draug <carandraug@octave.org>
date Fri, 18 Mar 2016 22:52:28 +0000
parents 516bb87ea72e
children ecce63c99c3f
line wrap: on
line diff
--- a/scripts/image/imformats.m	Fri Mar 18 17:52:30 2016 -0400
+++ b/scripts/image/imformats.m	Fri Mar 18 22:52:28 2016 +0000
@@ -315,6 +315,20 @@
 
 endfunction
 
+## This must work, even without support for image IO
+%!test
+%! formats = imformats ();
+%! assert (isstruct (formats))
+%!
+%! min_fields = {"ext", "read", "isa", "write", "info", "alpha", "description"};
+%! assert (all (ismember (min_fields, fieldnames (formats))))
+%!
+%! if (__have_feature__ ("MAGICK"))
+%!   assert (numel (formats) > 0)
+%! else
+%!   assert (numel (formats), 0)
+%! endif
+
 ## When imread or imfinfo are called, the file must exist or the
 ## function defined by imformats will never be called.  Because
 ## of this, we must create a file for the tests to work.