matlabtest.coder.results.BuildResults - Generated C/C++ code build results in equivalence tests - MATLAB (original) (raw)

Namespace: matlabtest.coder.results

Generated C/C++ code build results in equivalence tests

Since R2023a

Description

Objects of the matlabtest.coder.results.BuildResults class contain the build results for C/C++ code in a MATLAB® Test™ generated C/C++ code equivalence test.

The matlabtest.coder.results.BuildResults class is a handle class.

Properties

expand all

File path of the built function, returned as a cell array.

Example: {'C:\Users\jdoe\EquivalenceTests\myAdd.m'}

Attributes:

GetAccess public
SetAccess immutable

Code generation target build type, returned as 'MEX','LIB', or 'DLL'.

Attributes:

GetAccess public
SetAccess immutable

Data Types: char

Directory created for code generation, returned as a character vector.

Example: 'C:\Users\jdoe\AppData\Local\Temp\tp68ab0c12_ae1f'

Attributes:

GetAccess public
SetAccess immutable

Location of generated files, returned as a character vector.

Example: 'C:\Users\jdoe\AppData\Local\Temp\tp68ab0c12_ae1f\codegen\mex\myAdd'

Attributes:

GetAccess public
SetAccess immutable

Code generation log, returned as a character vector.

Attributes:

GetAccess public
SetAccess immutable

File path for the MEX function or C/C++ library, returned as a character vector.

Example: 'C:\Users\jdoe\AppData\Local\Temp\tp68ab0c12_ae1f\codegen\mex\myAdd\myAdd_mex.mexw64'

Attributes:

GetAccess public
SetAccess immutable

MEX function to use for verification, returned as a character vector.

Example: 'C:\Users\jdoe\AppData\Local\Temp\tp68ab0c12_ae1f\codegen\mex\myAdd\myAdd_mex.mexw64'

Example: 'C:\Users\jdoe\AppData\Local\Temp\tp68ab0c12_ae1f\codegen\mex\myAdd\myAdd_sil.mexw64'

Attributes:

GetAccess public
SetAccess immutable

Examples

collapse all

This example shows how to generate C code from a MATLAB function and test for equivalence by using MATLAB Coder™.

The function myAdd takes two numbers as inputs, adds them together, and outputs the result.

function y = myAdd(a,b) %#codegen y = a+b; end

This class definition file defines an equivalence test case that inherits from matlabtest.coder.TestCase. The test case in the methods block defines a test case that:

  1. Builds C code from the myAdd function with inputs set to (0,0)
  2. Executes the C code with inputs set to (1,2)
  3. Verifies the execution of the C code against the execution of the MATLAB function myAdd with the same inputs and an absolute tolerance of 0.01

classdef tEquivalence< matlabtest.coder.TestCase methods (Test) function tMyAdd(testCase) buildResults = build(testCase,"myAdd", ... Inputs={0,0});
executionResults = execute(testCase,buildResults, ... Inputs={1,2}); verifyExecutionMatchesMATLAB(testCase,executionResults, ... AbsTol=0.01) end end end

Run the tMyAdd test.

runtests("tEquivalence", ... procedureName="tMyAdd")

Running tMyAdd .. Done tMyAdd


ans = TestResult with properties:

      Name: 'tEquivalence/tMyAdd'
    Passed: 1
    Failed: 0
Incomplete: 0
  Duration: 2.6670
   Details: [1×1 struct]

Totals: 1 Passed, 0 Failed, 0 Incomplete. 2.667 seconds testing time.

Version History

Introduced in R2023a

See Also

Classes

Functions

Topics