Mercurial > repos > public > sbplib
comparison CellTest.m @ 477:97c505c87f56 feature/sublassable_cellarray
Implement tests for size, length and transpose
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Wed, 02 Aug 2017 10:31:48 +0200 |
parents | 949ffe238f61 |
children | d91f27460741 |
comparison
equal
deleted
inserted
replaced
476:949ffe238f61 | 477:97c505c87f56 |
---|---|
1 function tests = CellTest() | 1 function tests = CellTest() |
2 tests = functiontests(localfunctions); | 2 tests = functiontests(localfunctions); |
3 end | 3 end |
4 | 4 |
5 function testSize(testCase) | 5 function testSize(testCase) |
6 testCase.verifyFail(); | 6 cases = { |
7 {{}, [0, 0]}, | |
8 {{1}, [1, 1]}, | |
9 {{1, 2}, [1, 2]}, | |
10 {{1; 2}, [2, 1]}, | |
11 {{1, 2; 3, 4}, [2,2]}, | |
12 }; | |
13 | |
14 for i = 1:length(cases) | |
15 A = Cell(cases{i}{1}); | |
16 expected = cases{i}{2}; | |
17 | |
18 testCase.verifyEqual(size(A),expected); | |
19 end | |
7 end | 20 end |
8 | 21 |
9 function testLength(testCase) | 22 function testLength(testCase) |
10 testCase.verifyFail(); | 23 cases = { |
24 {{}, 0}, | |
25 {{1}, 1}, | |
26 {{1, 2}, 2}, | |
27 {{1; 2}, 2}, | |
28 {{1, 2; 3, 4}, 2}, | |
29 }; | |
30 | |
31 for i = 1:length(cases) | |
32 A = Cell(cases{i}{1}); | |
33 expected = cases{i}{2}; | |
34 | |
35 testCase.verifyEqual(length(A),expected); | |
36 end | |
11 end | 37 end |
12 | 38 |
13 function testTranspose(testCase) | 39 function testTranspose(testCase) |
14 testCase.verifyFail(); | 40 testCase.verifyEqual(Cell({1, 2})', Cell({1; 2})); |
41 testCase.verifyEqual(Cell({1; 2})', Cell({1, 2})); | |
15 end | 42 end |
16 | 43 |
17 function testRoundIndexWithProperty(testCase) | 44 function testRoundIndexWithProperty(testCase) |
18 A = Cell({3,2,1}); | 45 A = Cell({3,2,1}); |
19 | 46 |