Scilab Website | Contribute with GitLab | Scilab Community | ATOMS toolboxes
Scilab Online Help
2027.0.0 - Português


assert_checktrue

Check that condition is true.

Syntax

flag = assert_checktrue ( condition )
flag = assert_checktrue ( condition , msg )
[flag,errmsg] = assert_checktrue ( condition )
[...] = assert_checktrue ( condition , msg )

Arguments

condition

a matrix of booleans

flag

a 1-by-1 matrix of boolean, %t if condition is true, %f if not

errmsg

a 1-by-1 matrix of strings, the error message. If flag==%t, then errormsg=="". If flag==%f, then errmsg contains the error message.

msg :

a 1-by-1 matrix of strings, a custom message to prepend to the error message (default msg=""). If provided and the assertion fails, the message is prepended as "msg: " before the default error message.

Description

Performs silently if all entries in condition are true.

Generates an error if any entry in the condition matrix is false. Generates an error if condition is not a boolean.

If any entry in condition is false,

  • if the errmsg output variable is not used, an error is generated,

  • if the errmsg output variable is used, no error is generated.

If a custom msg is provided and the assertion fails, it is prepended to the error message (both the thrown error and the returned errmsg).

Examples

// Tests which pass
assert_checktrue ( %t );
flag = assert_checktrue ( %t )
[flag,errmsg] = assert_checktrue ( %t )
[flag,errmsg] = assert_checktrue ( [%t %t] );

// Tests which fail
assert_checktrue ( [%t %f] );
flag = assert_checktrue ( [%t %f] )
// No error generated
[flag,errmsg] = assert_checktrue ( [%t %f] )

// Wrong calls
assert_checktrue ( "a" )

// With a custom message on failure
[flag, errmsg] = assert_checktrue ( [%t %f], "my custom message" )

History

VersãoDescrição
5.4.0 Function introduced
2027.0.0 Optional msg input argument added.
Report an issue
<< assert_checkfilesequal Assert assert_comparecomplex >>

Copyright (c) 2022-2026 (Dassault Systèmes S.E.)
Copyright (c) 2017-2022 (ESI Group)
Copyright (c) 2011-2017 (Scilab Enterprises)
Copyright (c) 1989-2012 (INRIA)
Copyright (c) 1989-2007 (ENPC)
with contributors
Last updated:
Thu Oct 15 11:20:00 CEST 2026