sltest.CodeImporter Class
Description
Use objects of the sltest.CodeImporter
class to import a C library or a
subset of a library into Simulink® for modeling and testing. When you import the code, a Simulink library and a test file are created. Each C-compatible function maps to a
C Caller block in the library and each C Caller block, by default, has an
attached internal test harness. The created MLDATX test file contains test cases for each
imported function. For unit tests, you can only import C code. Additionally, for unit tests, a
sandbox is created to isolate the imported C code.
Note
If your code library contains C++ class methods, only the C++ methods that are wrapped
in valid C function wrappers are imported into Simulink using the CodeImporter
.
Alternatively, you can use a wizard to set up and import your code into Simulink. In the Test Manager, use New > Test for C/C++ Code to open the wizard.
The sltest.CodeImporter
class is a handle
class.
Creation
Description
creates
a Simulink
Test™ code importer object with codeimport_obj
= sltest.CodeImporteruntitled
as the Simulink library filename and creates four additional objects, which you access using
the SandboxSettings, ParseInfo, and CustomCode, and Options
properties.
creates a code importer object and uses the specified codeimport_obj
= sltest.CodeImporter(libraryfile
)libraryfile
as
the name of the created Simulink library. It sets the LibraryFileName property to libraryfile
.
Properties
Methods
Examples
Version History
Introduced in R2021a