assert.m

Assert function that expands like the C macro assert
3,9K téléchargements
Mise à jour 7 nov. 2006

Aucune licence

%assert(testCondition)
% Evaluates the test condition in the caller's context. If the result is
% false, an error is thrown indicating that the test failed.
% TESTCONDITION should be a string.
%
%assert(truthValue)
%assert(truthValue,errMsg)
% If TRUTHVALUE is zero, an error is thrown. The text of the error
% contains ERRMSG if supplied. This version of ASSERT was made to
% promote compatibility with Kevin Murphy's Bayes Net Toolbox (i.e. he
% uses this syntax). TRUTHVALUE must be a logical or a number.
%
%EXAMPLES:
% assert('1==2') ==> assertion error generated
% assert(1==2) ==> assertion error generated (BNT syntax)
% assert 1==2; ==> assertion error generated
% x=1; assert('x==1') ==> no error
% x=1; assert x==1; ==> no error
% assert('{a==3') ==> error generated by Matlab (bad assert code)

Citation pour cette source

Gerald Dalley (2025). assert.m (https://fr.mathworks.com/matlabcentral/fileexchange/10002-assert-m), MATLAB Central File Exchange. Extrait(e) le .

Compatibilité avec les versions de MATLAB
Créé avec R14SP2
Compatible avec toutes les versions
Plateformes compatibles
Windows macOS Linux
Catégories
En savoir plus sur Testing Frameworks dans Help Center et MATLAB Answers
Remerciements

A inspiré : Assertion function

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Publié le Notes de version
1.0.0.0

quick bug fix relative to the last update (which added support for Kevin Murphy's syntax)