|
| 1 | +% This test file was generated by Copilot. Validate the generated output before use. |
| 2 | +classdef CodeGenMexTest < matlab.unittest.TestCase |
| 3 | + properties |
| 4 | + codeGen |
| 5 | + end |
| 6 | + |
| 7 | + methods(TestMethodSetup) |
| 8 | + function createCodeGen(testCase) |
| 9 | + testCase.codeGen = CodeGenMex(); |
| 10 | + end |
| 11 | + end |
| 12 | + |
| 13 | + methods(Test) |
| 14 | + function testConfig(testCase) |
| 15 | + testCase.codeGen.config(); |
| 16 | + testCase.verifyEqual(testCase.codeGen.cfg.Name, 'strata_trapper-mex'); |
| 17 | + testCase.verifyEqual(testCase.codeGen.cfg.Description, ... |
| 18 | + 'MEX-compiled StrataTrapper functions'); |
| 19 | + testCase.verifyEqual(testCase.codeGen.cfg.TargetLang, 'C++'); |
| 20 | + testCase.verifyEqual(testCase.codeGen.cfg.NumberOfCpuThreads, int32(32)); |
| 21 | + end |
| 22 | + |
| 23 | + function testBuild(testCase) |
| 24 | + testCase.codeGen.config(); |
| 25 | + a = int32(2); |
| 26 | + b = int32(2); |
| 27 | + sum = add_mex_test(a,b); |
| 28 | + testCase.codeGen.build_with({"-o","add_mex_test","-v"},'add_mex_test'); |
| 29 | + % Check if the MEX file was created |
| 30 | + testCase.verifyTrue(exist('add_mex_test', 'file') == 3); |
| 31 | + sum_mex = add_mex_test(a,b); |
| 32 | + testCase.verifyTrue(sum_mex == sum); % test compiled MEX function |
| 33 | + end |
| 34 | + |
| 35 | + function testClear(testCase) |
| 36 | + testCase.codeGen.config(); |
| 37 | + testCase.codeGen.build_with({"-o","add_mex_test"},'add_mex_test'); |
| 38 | + testCase.codeGen.clear(); |
| 39 | + % Check if the MEX file was deleted |
| 40 | + testCase.verifyTrue(exist('add_mex_test', 'file') == 2); |
| 41 | + end |
| 42 | + end |
| 43 | +end |
0 commit comments