view +blockmatrix/getDivisionTest.m @ 433:eef74cd9b49c feature/grids

Move 3d transfinite interpolation to it's correct location.
author Jonatan Werpers <jonatan@werpers.com>
date Thu, 09 Feb 2017 08:37:55 +0100
parents f0ef314e2070
children a5f1b0267dba
line wrap: on
line source

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