Mercurial > octave-nkf
comparison scripts/general/cell2mat.m @ 20653:9cef0a1207e4 @
cell2mat: add tests for cells of cells and char arrays
author | Carnë Draug <carandraug@octave.org> |
---|---|
date | Tue, 13 Oct 2015 11:40:05 +0100 |
parents | 7503499a252b |
children |
comparison
equal
deleted
inserted
replaced
20652:a3b9ee5c040a | 20653:9cef0a1207e4 |
---|---|
112 %! assert (cell2mat (c), m); | 112 %! assert (cell2mat (c), m); |
113 %!test | 113 %!test |
114 %! m = {1, 2, 3}; | 114 %! m = {1, 2, 3}; |
115 %! assert (cell2mat (mat2cell (m, 1, [1 1 1])), m); | 115 %! assert (cell2mat (mat2cell (m, 1, [1 1 1])), m); |
116 | 116 |
117 ## cell2mat from cell into another cell | |
118 %!assert (cell2mat ({{"foo", "bar", "qux"}}), {"foo", "bar", "qux"}) | |
119 %!assert (cell2mat ({{"foo"}, {"bar", "qux"}}), {"foo", "bar", "qux"}) | |
120 %!assert (cell2mat ({{"foo"}; {"bar"; "qux"}}), {"foo"; "bar"; "qux"}) | |
121 %!assert (cell2mat ({{"foo", "lol"}; {"bar", "qux"}}), | |
122 %! {"foo", "lol"; "bar", "qux"}) | |
123 | |
124 ## cell2mat cell strings | |
125 %!assert (cell2mat ({"foo", "lol"; "bar", "qux"}), | |
126 %! reshape ("fboaorlqoulx", [2 6])) | |
127 | |
117 %!error cell2mat () | 128 %!error cell2mat () |
118 %!error cell2mat (1,2) | 129 %!error cell2mat (1,2) |
119 %!error <C must be a cell array> cell2mat ([1,2]) | 130 %!error <C must be a cell array> cell2mat ([1,2]) |
120 %!error <mixed cells, structs, and matrices> cell2mat ({[1], struct()}) | 131 %!error <mixed cells, structs, and matrices> cell2mat ({[1], struct()}) |
121 %!error <mixed cells, structs, and matrices> cell2mat ({[1], {1}}) | 132 %!error <mixed cells, structs, and matrices> cell2mat ({[1], {1}}) |
122 %!error <mixed cells, structs, and matrices> cell2mat ({struct(), {1}}) | 133 %!error <mixed cells, structs, and matrices> cell2mat ({struct(), {1}}) |
123 | 134 %!error <dimension mismatch> cell2mat ({{"foo"}; {"bar", "qux"}}) |
135 %!error <dimension mismatch> cell2mat ({"foox", "lol"; "bar", "qux"}) |