xtd 0.2.0
Loading...
Searching...
No Matches

◆ assert_

#define assert_ (   ...)

#include <xtd.core/include/xtd/diagnostics/assert.h>

Checks for a condition; if the condition is false, displays a message box that shows the call stack.

Header
#include <xtd/diagnostics/assert>
Library
xtd.core
Parameters
conditionThe conditional expression to evaluate. If the condition is true, a failure message is not sent and the message box is not displayed.
message(optional) The brief message to send to the xtd::diagnostics::debug::listeners collection.
detail_message(optional) The detail message to send to the xtd::diagnostics::debug::listeners collection.
Examples
The following example shows how to use assert_ macro.
#include <xtd/xtd>
using namespace xtd;
int main() {
// Uncomment following line to remove assert dialog
//diagnostics::debug::show_assert_dialog(false);
auto index = 0;
console::write_line("Start application");
assert_(index > 0);
console::write_line("End application");
}
// This code produces the following output :
//
// > If user clicks assert dialog 'Abort' button:
// Start application
//
// > If user clicks assert dialog 'Retry' button:
// Start application
// > Break the debugger on file assert_.cpp line 11.
// > If user choose continue running after break.
// End application
//
// > If user clicks assert dialog 'Ignore' button:
// Start application
// End application
#define assert_(...)
Checks for a condition; if the condition is false, displays a message box that shows the call stack.
Definition assert.h:25
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.h:10
Examples
The following example shows how to use assert_ macro with message.
#include <xtd/xtd>
using namespace xtd;
int main() {
// Uncomment following line to remove assert dialog
//diagnostics::debug::show_assert_dialog(false);
auto index = 0;
console::write_line("Start application");
assert_(index > 0, "index must be greater than 0");
console::write_line("End application");
}
// This code produces the following output :
//
// > If user clicks assert dialog 'Abort' button:
// Start application
//
// > If user clicks assert dialog 'Retry' button:
// Start application
// > Break the debugger on file assert_with_message.cpp line 11.
// > If user choose continue running after break.
// End application
//
// > If user clicks assert dialog 'Ignore' button:
// Start application
// End application
Examples
application_and_assert.cpp, assert_.cpp, and assert_with_message.cpp.