# HG changeset patch # User Carnë Draug # Date 1444732805 -3600 # Node ID 9cef0a1207e4a0d2fff2d7a54ff2b6baca20006e # Parent a3b9ee5c040aecff5cd9930a9b1923c6d9b0c943 cell2mat: add tests for cells of cells and char arrays diff -r a3b9ee5c040a -r 9cef0a1207e4 scripts/general/cell2mat.m --- a/scripts/general/cell2mat.m Mon Oct 12 21:28:32 2015 -0700 +++ b/scripts/general/cell2mat.m Tue Oct 13 11:40:05 2015 +0100 @@ -114,10 +114,22 @@ %! m = {1, 2, 3}; %! assert (cell2mat (mat2cell (m, 1, [1 1 1])), m); +## cell2mat from cell into another cell +%!assert (cell2mat ({{"foo", "bar", "qux"}}), {"foo", "bar", "qux"}) +%!assert (cell2mat ({{"foo"}, {"bar", "qux"}}), {"foo", "bar", "qux"}) +%!assert (cell2mat ({{"foo"}; {"bar"; "qux"}}), {"foo"; "bar"; "qux"}) +%!assert (cell2mat ({{"foo", "lol"}; {"bar", "qux"}}), +%! {"foo", "lol"; "bar", "qux"}) + +## cell2mat cell strings +%!assert (cell2mat ({"foo", "lol"; "bar", "qux"}), +%! reshape ("fboaorlqoulx", [2 6])) + %!error cell2mat () %!error cell2mat (1,2) %!error cell2mat ([1,2]) %!error cell2mat ({[1], struct()}) %!error cell2mat ({[1], {1}}) %!error cell2mat ({struct(), {1}}) - +%!error cell2mat ({{"foo"}; {"bar", "qux"}}) +%!error cell2mat ({"foox", "lol"; "bar", "qux"})