<?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>

<refsect1 id="cutter-CppCutter.functions" role="functions_proto">
<title role="functions_proto.title">Functions</title>
<informaltable pgwide="1" frame="none">
<tgroup cols="2">
<colspec colname="functions_return" colwidth="150px"/>
<colspec colname="functions_name"/>
<tbody>
<row><entry role="define_keyword">#define</entry><entry role="function_name"><link linkend="cppcut-message">cppcut_message</link><phrase role="c_punctuation">()</phrase></entry></row>

</tbody>
</tgroup>
</informaltable>
</refsect1>
<refsect1 id="cutter-CppCutter.other" role="other_proto">
<title role="other_proto.title">Types and Values</title>
<informaltable role="enum_members_table" pgwide="1" frame="none">
<tgroup cols="2">
<colspec colname="name" colwidth="150px"/>
<colspec colname="description"/>
<tbody>
<row><entry role="define_keyword">#define</entry><entry role="function_name"><link linkend="CPPCUTTER-ENABLED:CAPS">CPPCUTTER_ENABLED</link></entry></row>
<row><entry role="define_keyword">#define</entry><entry role="function_name"><link linkend="CPPCUT-BEGIN-TEST-DECLS:CAPS">CPPCUT_BEGIN_TEST_DECLS</link></entry></row>
<row><entry role="define_keyword">#define</entry><entry role="function_name"><link linkend="CPPCUT-END-TEST-DECLS:CAPS">CPPCUT_END_TEST_DECLS</link></entry></row>

</tbody>
</tgroup>
</informaltable>
</refsect1>


<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:</para>
<informalexample><programlisting><![CDATA[
-#include <cutter.h>
+#include <cppcutter.h>
]]></programlisting></informalexample>
<para></para>
<para>configure.ac:</para>
<informalexample><programlisting><![CDATA[
-AC_CHECK_CUTTER
+AC_CHECK_CPPCUTTER
]]></programlisting></informalexample>
<para></para>
<para>Makefile.am:</para>
<informalexample><programlisting><![CDATA[
-XXX_CFLAGS = $(CUTTER_CFLAGS)
-XXX_LIBS = $(CUTTER_LIBS)
+XXX_CFLAGS = $(CPPCUTTER_CFLAGS)
+XXX_LIBS = $(CPPCUTTER_LIBS)
]]></programlisting></informalexample>
<para></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:</para>
<informalexample><programlisting><![CDATA[
#include <cppcutter.h>

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>
<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.functions_details" role="details">
<title role="details.title">Functions</title>
<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 language="C">#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.:</para>
<informalexample><programlisting><![CDATA[
cppcut_assert_equal("abc", "def",
                    cppcut_message("should fail!"));
cppcut_assert_equal("abc", "def",
                    cppcut_message() << "should fail!");
]]></programlisting></informalexample>
<para></para>
<refsect3 id="cppcut-message.parameters" role="parameters">
<title>Parameters</title>
<informaltable role="parameters_table" pgwide="1" frame="none">
<tgroup cols="3">
<colspec colname="parameters_name" colwidth="150px"/>
<colspec colname="parameters_description"/>
<colspec colname="parameters_annotations" colwidth="200px"/>
<tbody>
<row><entry role="parameter_name"><para>...</para></entry>
<entry role="parameter_description"><para>the parameters to insert into the format string.</para></entry>
<entry role="parameter_annotations"></entry></row>
</tbody></tgroup></informaltable>
</refsect3><para role="since">Since: <link linkend="api-index-1.1.0">1.1.0</link></para></refsect2>

</refsect1>
<refsect1 id="cutter-CppCutter.other_details" role="details">
<title role="details.title">Types and Values</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 language="C">#define CPPCUTTER_ENABLED 1
</programlisting>
<para>Defined when CppCutter is enabled.</para>
<para role="since">Since: <link linkend="api-index-1.0.9">1.0.9</link></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 language="C">#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.</para> <para>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>
<informalexample><programlisting><![CDATA[
CPPCUT_BEGIN_TEST_DECLS
void test_add ();
void test_remove ();
CPPCUT_END_TEST_DECLS
]]></programlisting></informalexample>
<para></para>
<para>Those macros just surround prototype declarations for
test functions with 'extern "C" {...}'.</para>
<para role="since">Since: <link linkend="api-index-1.0.9">1.0.9</link></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 language="C">#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.</para> <para>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: <link linkend="api-index-1.0.9">1.0.9</link></para></refsect2>

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

</refsect1>

</refentry>
