Commit 73253b69 authored by Colin Eles's avatar Colin Eles
Browse files

added some unit tests and unit test suite for matlab

git-svn-id: https://groke.mcmaster.ca/svn/grad/colin/trunk/TableTool@5943 57e6efec-57d4-0310-aeb1-a6c144bb1a8b
parent 0943d0ff
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -74,8 +74,16 @@ classdef Data < handle
        % creates copy of object
        function copy = clone(obj,handle)
            % assume that dialog is closed
            if ~obj.valid
                copy = [];
                return;
            end
            copy = Data();
            if ~isempty(handle)
            copy.function_name =   get(handle,'Name');
            else
                copy.function_name = '';
            end
            copy.function_inputs = obj.function_inputs;
            copy.checked = obj.checked;
            copy.settings = obj.settings;
+1 −2
Original line number Diff line number Diff line
@@ -32,14 +32,13 @@ classdef EMLGenerator < handle
                    %new_inputs{i}(1) = inputs{i}(1:c_locations{i}(1))
                    %new_inputs{i}(2) = inputs{i}(c_locations{i}(1):end)
                end
                    
           end
           
           %inputs = regexp(inputs,':','split')
           
           for i=1:size(new_inputs,2)
                valid = regexp(new_inputs{i}(1),'[a-zA-Z][_a-zA-Z0-9]*','match');
                if ~strcmp(new_inputs{i}(1),valid{1})
                if isempty(char(new_inputs{i}(1))) || ~strcmp(new_inputs{i}(1),valid{1})
                    new_inputs{i}(2) = {'error'};
                    %revised_input = cat(2,revised_input,[char(inputs{i}(1)); 'error'])
                end
+1 −1
Original line number Diff line number Diff line
@@ -45,7 +45,7 @@ classdef RGrid < handle
        % outputs;
        %   cell:boolean - 1 if cell is found, 0 if cell is not found
        function cell = search(obj,cell1,cell2)
            cell = 0
            cell = 0;
            for i=1:size(obj.Cells,2)
                if (obj.Cells(i).Cell1 == cell1 && obj.Cells(i).Cell2 == cell2);
                    cell = 1;

Tests/Untitled.m

0 → 100644
+7 −0
Original line number Diff line number Diff line
function [ output_args ] = Untitled( input_args )
%UNTITLED Summary of this function goes here
%   Detailed explanation goes here


end

Tests/testData.m

0 → 100644
+45 −0
Original line number Diff line number Diff line
function test_suite = testData
initTestSuite;
end

function testConstructor
    d = Data;
    assertEqual(class(d),'Data');
end

function testInit
    d = Data;
    d.init;
    assertEqual(size(d.Grid2.cells,2),1);
    assertEqual(size(d.Grid1.cells,2),1);
    assertEqual(size(d.Grid0.Cells,2),1);
end

function testClone
    d = Data;
    d.init;
    d.function_name = 'test_name';
    d.function_inputs = 'input_test';
    d.checked = 1;
    d.Grid1.cells(1).cond_text = 'test_cond';
    d2 = d.clone([]);
    assertEqual(d2.function_name,'');
    assertEqual(d2.function_inputs,d.function_inputs);
    assertEqual(d2.Grid1.cells(1).cond_text,'test_cond');
end

function testClone2
    d = Data;
    d2 = d.clone;
    assertEqual(d2,[]);
end

function testSave
    d = Data;
    d.init;
    d.function_name = 'test_file';
    d.save;
    assertEqual(exist('test_file.table'),2);
    delete('test_file.table');
end
        
 No newline at end of file
Loading