changeset 474:c91464ef1dd9 feature/sublassable_cellarray

Implement tests for horzcat and vertcat. Fix bugs found
author Jonatan Werpers <jonatan@werpers.com>
date Wed, 02 Aug 2017 09:38:12 +0200
parents 605a8c075388
children e0e81e7df671
files Cell.m CellTest.m
diffstat 2 files changed, 39 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
diff -r 605a8c075388 -r c91464ef1dd9 Cell.m
--- a/Cell.m	Wed Aug 02 09:34:45 2017 +0200
+++ b/Cell.m	Wed Aug 02 09:38:12 2017 +0200
@@ -61,7 +61,7 @@
             C = callConstructor(varargin{1}, c);
         end
 
-        function vertcat(varargin)
+        function C = vertcat(varargin)
             dataArray = cell(1, length(varargin));
 
             for i = 1:length(varargin)
diff -r 605a8c075388 -r c91464ef1dd9 CellTest.m
--- a/CellTest.m	Wed Aug 02 09:34:45 2017 +0200
+++ b/CellTest.m	Wed Aug 02 09:38:12 2017 +0200
@@ -11,5 +11,42 @@
 end
 
 function testConcat(testCase)
-    testCase.verifyFail();
+    cases = {
+        {{},{}},
+        {{1},{}},
+        {{},{1}},
+        {{1},{2}},
+        {{1, 2},{3, 4}},
+        {{1; 2},{3; 4}},
+    };
+
+    horzCat = {
+        {},
+        {1},
+        {1},
+        {1,2},
+        {1, 2, 3, 4},
+        {1, 3; 2, 4},
+    };
+
+    vertCat = {
+        {},
+        {1},
+        {1},
+        {1; 2},
+        {1, 2; 3, 4},
+        {1; 2; 3; 4},
+    };
+
+    for i = 1:length(cases)
+        A = Cell(cases{i}{1});
+        B = Cell(cases{i}{2});
+
+        C_horz = [A, B];
+        C_vert = [A; B];
+
+        testCase.verifyEqual(C_horz.data, horzCat{i});
+        testCase.verifyEqual(C_vert.data, vertCat{i});
+
+    end
 end