Mercurial > repos > public > sbplib
diff +blockmatrix/getDivisionTest.m @ 205:f0ef314e2070 feature/grids
blockmatrix: added function to calculate the block division for a given blockmatrix.
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Wed, 15 Jun 2016 16:28:22 +0200 |
parents | |
children | a5f1b0267dba |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/+blockmatrix/getDivisionTest.m Wed Jun 15 16:28:22 2016 +0200 @@ -0,0 +1,69 @@ +function tests = getDivisionTest() + tests = functiontests(localfunctions); +end + +function testError(testCase) + cases = { + magic(3), + {[2 2 2];{1,2}}, + {[2 2 2];[1 2]}, + {[2; 2; 2], [1; 2]}, + }; + + for i =1:length(cases) + testCase.verifyError(@()blockmatrix.getDivision(cases{i}), 'blockmatrix:getDivision:NotABlockmatrix') + end +end + +function testGetDivision(testCase) + cases = { + { + {}, + {[],[]}; + }, + { + { + [2 2; 2 1], [1; 2]; + [2 2], [1] + }, + {[2 1], [2 1]} + }, + { + { + [2 2; 2 1], []; + [2 2], [1] + }, + {[2 1], [2 1]} + }, + { + { + [2 2; 2 1], []; + [2 2], [] + }, + {[2 1], [2 0]} + }, + { + { + [2 2; 2 1], [1; 2]; + [], [] + }, + {[2 0], [2 1]} + }, + { + { + [2 2; 2 1]; + [2 2] + }, + {[2 1], 2} + }, + }; + + for i = 1:length(cases) + in = cases{i}{1}; + out = blockmatrix.getDivision(in); + expected = cases{i}{2}; + testCase.verifyEqual(out, expected); + end +end + +