<?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-CppCutter">
<refmeta>
<refentrytitle role="top_of_page" id="cutter-CppCutter.top_of_page">CppCutter</refentrytitle>
<manvolnum>3</manvolnum>
<refmiscinfo>
  CUTTER Library
</refmiscinfo>
</refmeta>
<refnamediv>
<refname>CppCutter</refname>
<refpurpose>Cutter with C++ support.</refpurpose>
</refnamediv>

<refsynopsisdiv id="cutter-CppCutter.synopsis" role="synopsis">
<title role="synopsis.title">Synopsis</title>

<synopsis>#define             <link linkend="CPPCUTTER-ENABLED:CAPS">CPPCUTTER_ENABLED</link>
#define             <link linkend="CPPCUT-BEGIN-TEST-DECLS:CAPS">CPPCUT_BEGIN_TEST_DECLS</link>
#define             <link linkend="CPPCUT-END-TEST-DECLS:CAPS">CPPCUT_END_TEST_DECLS</link>
#define             <link linkend="cppcut-message">cppcut_message</link>                      (...)
</synopsis>
</refsynopsisdiv>

<refsect1 id="cutter-CppCutter.description" role="desc">
<title role="desc.title">Description</title>
<para>
CppCutter provides C++ friendly interface of Cutter. If
you want to write tests with C++, it's good idea that you
consider CppCutter to be used too.
</para>
<para>
It's easy to use CppCutter. You just include &lt;cppcutter.h&gt;
instead of &lt;cutter.h&gt; and use cppcutter.pc instead of
cutter.pc:
</para>
<para>
test-xxx.cpp:
<informalexample><programlisting>
-#include &lt;cutter.h&gt;
+#include &lt;cppcutter.h&gt;
</programlisting></informalexample>
</para>
<para>
configure.ac:
<informalexample><programlisting>
-AC_CHECK_CUTTER
+AC_CHECK_CPPCUTTER
</programlisting></informalexample>
</para>
<para>
Makefile.am:
<informalexample><programlisting>
-XXX_CFLAGS = $(CUTTER_CFLAGS)
-XXX_LIBS = $(CUTTER_LIBS)
+XXX_CFLAGS = $(CPPCUTTER_CFLAGS)
+XXX_LIBS = $(CPPCUTTER_LIBS)
</programlisting></informalexample>
</para>
<para>
Test functions are defined in namespace. Naming
convention is the same as Cutter. i.e.: 'test_...'
function is test function, 'setup' or 'cut_setup' is
setup function and 'teardown' or 'cut_teardown' is
teardown function.
</para>
<para>
test-calc.cpp:
<informalexample><programlisting>
#include &lt;cppcutter.h&gt;

namespace calc
{
    void
    test_add (void)
    {
        cppcut_assert_equal(3, calc.add(1, 2));
    }

    void
    test_sub (void)
    {
        cppcut_assert_equal(5, calc.sub(9, 4));
    }
}
</programlisting></informalexample>
</para>
<para>
You just define a function for adding a new test. You
don't need to use magical macros.
</para>
</refsect1>
<refsect1 id="cutter-CppCutter.details" role="details">
<title role="details.title">Details</title>
<refsect2 id="CPPCUTTER-ENABLED:CAPS" role="macro" condition="since:1.0.9">
<title>CPPCUTTER_ENABLED</title>
<indexterm zone="CPPCUTTER-ENABLED:CAPS" role="1.0.9"><primary>CPPCUTTER_ENABLED</primary></indexterm>
<programlisting>#define CPPCUTTER_ENABLED 1
</programlisting>
<para>
Defined when CppCutter is enabled.
</para><para role="since">Since 1.0.9</para></refsect2>
<refsect2 id="CPPCUT-BEGIN-TEST-DECLS:CAPS" role="macro" condition="deprecated:1.1.0: Use namespace instead.|since:1.0.9">
<title>CPPCUT_BEGIN_TEST_DECLS</title>
<indexterm zone="CPPCUT-BEGIN-TEST-DECLS:CAPS" role="deprecated"><primary>CPPCUT_BEGIN_TEST_DECLS</primary></indexterm><indexterm zone="CPPCUT-BEGIN-TEST-DECLS:CAPS" role="1.0.9"><primary>CPPCUT_BEGIN_TEST_DECLS</primary></indexterm>
<programlisting>#define CPPCUT_BEGIN_TEST_DECLS extern "C" {
</programlisting>
<warning><para><literal>CPPCUT_BEGIN_TEST_DECLS</literal> has been deprecated since version 1.1.0 and should not be used in newly-written code. Use namespace instead.</para></warning>
<para>
Use <link linkend="CPPCUT-BEGIN-TEST-DECLS:CAPS"><literal>CPPCUT_BEGIN_TEST_DECLS</literal></link> and <link linkend="CPPCUT-END-TEST-DECLS:CAPS"><literal>CPPCUT_END_TEST_DECLS</literal></link>
pair for prototype declarations for test functions:
</para>
<para>
<informalexample><programlisting>
CPPCUT_BEGIN_TEST_DECLS
void test_add ();
void test_remove ();
CPPCUT_END_TEST_DECLS
</programlisting></informalexample>
</para>
<para>
Those macros just surround prototype declarations for
test functions with 'extern "C" {...}'.
</para><para role="since">Since 1.0.9</para></refsect2>
<refsect2 id="CPPCUT-END-TEST-DECLS:CAPS" role="macro" condition="deprecated:1.1.0: Use namespace instead.|since:1.0.9">
<title>CPPCUT_END_TEST_DECLS</title>
<indexterm zone="CPPCUT-END-TEST-DECLS:CAPS" role="deprecated"><primary>CPPCUT_END_TEST_DECLS</primary></indexterm><indexterm zone="CPPCUT-END-TEST-DECLS:CAPS" role="1.0.9"><primary>CPPCUT_END_TEST_DECLS</primary></indexterm>
<programlisting>#define CPPCUT_END_TEST_DECLS }
</programlisting>
<warning><para><literal>CPPCUT_END_TEST_DECLS</literal> has been deprecated since version 1.1.0 and should not be used in newly-written code. Use namespace instead.</para></warning>
<para>
See <link linkend="CPPCUT-BEGIN-TEST-DECLS:CAPS"><literal>CPPCUT_BEGIN_TEST_DECLS</literal></link>.
</para><para role="since">Since 1.0.9</para></refsect2>
<refsect2 id="cppcut-message" role="macro" condition="since:1.1.0">
<title>cppcut_message()</title>
<indexterm zone="cppcut-message" role="1.1.0"><primary>cppcut_message</primary></indexterm>
<programlisting>#define             cppcut_message(...)</programlisting>
<para>
Specifies optional assertion message with C++ friendly
API. The optional message can be specified with <link linkend="printf"><function>printf()</function></link>
style API or "&lt;&lt;" stream style API.
</para>
<para>
e.g.:
<informalexample><programlisting>
cppcut_assert_equal("abc", "def",
                    cppcut_message("should fail!"));
cppcut_assert_equal("abc", "def",
                    cppcut_message() &lt;&lt; "should fail!");
</programlisting></informalexample>
</para><variablelist role="params">
<varlistentry><term><parameter>...</parameter>&#160;:</term>
<listitem><simpara>the parameters to insert into the format string.
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara>
</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 1.1.0</para></refsect2>

</refsect1>
<refsect1 id="cutter-CppCutter.see-also">
<title>See Also</title>
<link
           linkend="cutter-Assertions-with-C++-support">
           Assertions with C++ support</link>
</refsect1>

</refentry>
