Skip to content
Snippets Groups Projects
test_expcodes.m 2.49 KiB
Newer Older
classdef test_expcodes < matlab.unittest.TestCase
  
  properties
    expcode_obj;
    SCDexps;
Federico Felici's avatar
Federico Felici committed
    shot = 65668; % a shot with data, for actualize/sim purposes
  end
  
  properties(MethodSetupParameter)
    expcode_number = {'1','1005','1010'}; % list of expcodes to test
  end
  
  methods(TestClassSetup)
    function setup_environment(testCase)
      testCase.addTeardown(@cd,pwd);
      testCase.addTeardown(@path,path);
      
      testCase.addTeardown(@() SCDclass_expcode.close_all(0))
      
      basePath = fullfile(fileparts(mfilename('fullpath')),'..');
      run(fullfile(basePath,'rtccode_paths'));
      
      % get SCD experimental code object container
      testCase.SCDexps = SCDconf_createexpcodes;
      
      SCDconf_setSIMconf; % set ConfigurationSettings for Simulation
  methods(TestMethodSetup)
    function setup_expcode(testCase,expcode_number)
      % get this expcode object from expcode object container
      fprintf('\n=== Testing expcode %s ===\n',expcode_number);
      testCase.expcode_obj = getbymaincode(testCase.SCDexps,str2double(expcode_number));
Federico Felici's avatar
Federico Felici committed
    function test_expcode_printinfo(testCase)
      testCase.expcode_obj.printinfo
    end
    
    function test_expcode_printparameters(testCase)
      testCase.expcode_obj.printparameters
    end
    
    function test_expcode_printwavegens(testCase)
      testCase.expcode_obj.printwavegens;
    end
    
    function test_expcode_printtasks(testCase)
      testCase.expcode_obj.printtasks;
    end
    
    function test_expcode_printinits(testCase)
      testCase.expcode_obj.printinits
    end
    
    function test_expcode_setup(testCase)
      fprintf('\n=== Testing callinits for expcode %d: %s === \n',...
Federico Felici's avatar
Federico Felici committed
        testCase.expcode_obj.maincode,...
        testCase.expcode_obj.name);
      
      testCase.expcode_obj.callinits(testCase.shot);
      fprintf('\n=== Testing setup for expcode %d: %s === \n',...
Federico Felici's avatar
Federico Felici committed
        testCase.expcode_obj.maincode,...
        testCase.expcode_obj.name);
      testCase.expcode_obj.setup; % run setup this exp code
    end
    
  end
  
  methods(Test)
    function test_expcode_compile(testCase)
      fprintf('\n === Testing Simulink compilation for expcode %d: %s === \n',...
        testCase.expcode_obj.maincode,testCase.expcode_obj.name);
      % attempt compiling tcv.slx for this expcode
Federico Felici's avatar
Federico Felici committed

      testCase.expcode_obj.compile; % compile tcv.slx with this expcode
    function test_build(testCase)
      testCase.expcode_obj.build;