classdef TestMorphologyEx
    %TestMorphologyEx

    properties (Constant)
        img = uint8([...
            0 0 0 0 0 0 0 0 0 0;...
            0 0 0 0 0 0 0 0 0 0;...
            0 0 0 0 0 0 0 0 0 0;...
            0 0 0 1 1 1 0 0 0 0;...
            0 0 0 1 1 1 0 0 0 0;...
            0 0 0 1 1 1 0 0 0 0;...
            0 0 0 0 0 0 0 0 0 0;...
            0 0 0 0 0 0 0 0 0 0;...
            0 0 0 0 0 0 0 0 0 0;...
            0 0 0 0 0 0 0 0 0 0;...
        ]);
    end

    methods (Static)
        function test_1
            result = cv.morphologyEx(TestMorphologyEx.img, 'Tophat');
            validateattributes(result, {class(TestMorphologyEx.img)}, ...
                {'size',size(TestMorphologyEx.img)});
        end

        function test_2
            result = cv.morphologyEx(TestMorphologyEx.img, 'Tophat', ...
                'Element',eye(3), 'Anchor',[1,1], 'Iterations',1, ...
                'BorderType','Constant', 'BorderValue',255);
            validateattributes(result, {class(TestMorphologyEx.img)}, ...
                {'size',size(TestMorphologyEx.img)});
        end

        function test_error_argnum
            try
                cv.morphologyEx();
                throw('UnitTest:Fail');
            catch e
                assert(strcmp(e.identifier,'mexopencv:error'));
            end
        end
    end

end
