<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN" "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" [
<!ENTITY version SYSTEM "version.xml">
]>
<refentry id="cutter-Assertions-with-C++-support">
<refmeta>
<refentrytitle role="top_of_page" id="cutter-Assertions-with-C++-support.top_of_page">Assertions with C++ support</refentrytitle>
<manvolnum>3</manvolnum>
<refmiscinfo>
  CUTTER Library
</refmiscinfo>
</refmeta>
<refnamediv>
<refname>Assertions with C++ support</refname>
<refpurpose>Checks that your program works as you
expect with C++ support.</refpurpose>
</refnamediv>

<refsynopsisdiv id="cutter-Assertions-with-C++-support.synopsis" role="synopsis">
<title role="synopsis.title">Synopsis</title>

<synopsis>#define             <link linkend="cppcut-assert-equal">cppcut_assert_equal</link>                 (expected,
                                                         actual,
                                                         ...)
#define             <link linkend="cppcut-assert-not-equal">cppcut_assert_not_equal</link>             (expected,
                                                         actual,
                                                         ...)
#define             <link linkend="cppcut-assert-null">cppcut_assert_null</link>                  (object,
                                                         ...)
#define             <link linkend="cppcut-assert-not-null">cppcut_assert_not_null</link>              (object,
                                                         ...)
#define             <link linkend="cppcut-assert-operator">cppcut_assert_operator</link>              (lhs,
                                                         operator,
                                                         rhs,
                                                         ...)
</synopsis>
</refsynopsisdiv>

<refsect1 id="cutter-Assertions-with-C++-support.description" role="desc">
<title role="desc.title">Description</title>

</refsect1>
<refsect1 id="cutter-Assertions-with-C++-support.details" role="details">
<title role="details.title">Details</title>
<refsect2 id="cppcut-assert-equal" role="macro" condition="since:1.0.9">
<title>cppcut_assert_equal()</title>
<indexterm zone="cppcut-assert-equal" role="1.0.9"><primary>cppcut_assert_equal</primary></indexterm>
<programlisting>#define             cppcut_assert_equal(expected, actual, ...)</programlisting>
<para>
This assertion is a generic method based on template. You
can pass any object's reference as <parameter>expected</parameter> and <parameter>actual</parameter>.
</para>
<para>
Passes if <parameter>expected</parameter> == <parameter>actual</parameter>.
</para>
<para>
e.g.:
<informalexample><programlisting>
cppcut_assert_equal(3, 1 + 2);
cppcut_assert_equal(3, 1 + 2, cppcut_message("easy expression"));
cppcut_assert_equal(3, 1 + 2, cppcut_message() &lt;&lt; "easy expression"));
</programlisting></informalexample>
</para><variablelist role="params">
<varlistentry><term><parameter>expected</parameter>&#160;:</term>
<listitem><simpara>an expected value.</simpara></listitem></varlistentry>
<varlistentry><term><parameter>actual</parameter>&#160;:</term>
<listitem><simpara>an actual value.</simpara></listitem></varlistentry>
<varlistentry><term><parameter>...</parameter>&#160;:</term>
<listitem><simpara>an optional message. Use <link linkend="cppcut-message"><function>cppcut_message()</function></link> for this.</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 1.0.9</para></refsect2>
<refsect2 id="cppcut-assert-not-equal" role="macro" condition="since:1.2.0">
<title>cppcut_assert_not_equal()</title>
<indexterm zone="cppcut-assert-not-equal" role="1.2.0"><primary>cppcut_assert_not_equal</primary></indexterm>
<programlisting>#define             cppcut_assert_not_equal(expected, actual, ...)</programlisting>
<para>
This assertion is a generic method based on template. You
can pass any object's reference as <parameter>expected</parameter> and <parameter>actual</parameter>.
</para>
<para>
Passes if <parameter>expected</parameter> != <parameter>actual</parameter>.
</para>
<para>
e.g.:
<informalexample><programlisting>
cppcut_assert_not_equal(3, 3 + 1);
cppcut_assert_not_equal(3, 3 + 1, cppcut_message("easy expression"));
cppcut_assert_not_equal(3, 3 + 1, cppcut_message() &lt;&lt; "easy expression"));
</programlisting></informalexample>
</para><variablelist role="params">
<varlistentry><term><parameter>expected</parameter>&#160;:</term>
<listitem><simpara>an expected value.</simpara></listitem></varlistentry>
<varlistentry><term><parameter>actual</parameter>&#160;:</term>
<listitem><simpara>an actual value.</simpara></listitem></varlistentry>
<varlistentry><term><parameter>...</parameter>&#160;:</term>
<listitem><simpara>an optional message. Use <link linkend="cppcut-message"><function>cppcut_message()</function></link> for this.</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 1.2.0</para></refsect2>
<refsect2 id="cppcut-assert-null" role="macro" condition="since:1.2.0">
<title>cppcut_assert_null()</title>
<indexterm zone="cppcut-assert-null" role="1.2.0"><primary>cppcut_assert_null</primary></indexterm>
<programlisting>#define             cppcut_assert_null(object, ...)</programlisting>
<para>
This assertion is a generic method based on template. You
can pass any object's pointer as <parameter>object</parameter>.
</para>
<para>
Passes if <parameter>object</parameter> is <link linkend="NULL:CAPS"><literal>NULL</literal></link>.
</para>
<para>
e.g.:
<informalexample><programlisting>
std::string message("hello");
std::string *not_null_string = &amp;message;
std::string *null_string = NULL;
cppcut_assert_null(not_null_string); // fail
cppcut_assert_null(null_string);     // pass
</programlisting></informalexample>
</para><variablelist role="params">
<varlistentry><term><parameter>object</parameter>&#160;:</term>
<listitem><simpara>the object to be checked.</simpara></listitem></varlistentry>
<varlistentry><term><parameter>...</parameter>&#160;:</term>
<listitem><simpara>an optional message. Use <link linkend="cppcut-message"><function>cppcut_message()</function></link> for this.</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 1.2.0</para></refsect2>
<refsect2 id="cppcut-assert-not-null" role="macro" condition="since:1.2.0">
<title>cppcut_assert_not_null()</title>
<indexterm zone="cppcut-assert-not-null" role="1.2.0"><primary>cppcut_assert_not_null</primary></indexterm>
<programlisting>#define             cppcut_assert_not_null(object, ...)</programlisting>
<para>
This assertion is a generic method based on template. You
can pass any object's pointer as <parameter>object</parameter>.
</para>
<para>
Passes if <parameter>object</parameter> is not <link linkend="NULL:CAPS"><literal>NULL</literal></link>.
</para>
<para>
e.g.:
<informalexample><programlisting>
std::string message("hello");
std::string *not_null_string = &amp;message;
std::string *null_string = NULL;
cppcut_assert_not_null(not_null_string); // pass
cppcut_assert_not_null(null_string);     // fail
</programlisting></informalexample>
</para><variablelist role="params">
<varlistentry><term><parameter>object</parameter>&#160;:</term>
<listitem><simpara>the object to be checked.</simpara></listitem></varlistentry>
<varlistentry><term><parameter>...</parameter>&#160;:</term>
<listitem><simpara>an optional message. Use <link linkend="cppcut-message"><function>cppcut_message()</function></link> for this.</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 1.2.0</para></refsect2>
<refsect2 id="cppcut-assert-operator" role="macro" condition="since:1.2.0">
<title>cppcut_assert_operator()</title>
<indexterm zone="cppcut-assert-operator" role="1.2.0"><primary>cppcut_assert_operator</primary></indexterm>
<programlisting>#define             cppcut_assert_operator(lhs, operator, rhs, ...)</programlisting>
<para>
This assertion is a generic method based on template. You
can pass any object as <parameter>lhs</parameter> and <parameter>rhs</parameter>.
</para>
<para>
Passes if (<parameter>lhs</parameter> <parameter>operator</parameter> <parameter>rhs</parameter>) is TRUE.
</para>
<para>
e.g.:
<informalexample><programlisting>
cppcut_assert_operator(1, &lt;, 2); // pass
cppcut_assert_operator(1, &gt;, 2); // fail
</programlisting></informalexample>
</para><variablelist role="params">
<varlistentry><term><parameter>lhs</parameter>&#160;:</term>
<listitem><simpara>a left hand side value.</simpara></listitem></varlistentry>
<varlistentry><term><parameter>operator</parameter>&#160;:</term>
<listitem><simpara>a binary operator.</simpara></listitem></varlistentry>
<varlistentry><term><parameter>rhs</parameter>&#160;:</term>
<listitem><simpara>a right hand side value.</simpara></listitem></varlistentry>
<varlistentry><term><parameter>...</parameter>&#160;:</term>
<listitem><simpara>an optional message. Use <link linkend="cppcut-message"><function>cppcut_message()</function></link> for this.</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 1.2.0</para></refsect2>

</refsect1>

</refentry>
