<?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ライブラリ</refmiscinfo>
</refmeta>
<refnamediv>
<refname>CppCutter</refname>
<refpurpose>C++サポート付きのCutter。</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">説明</title>
<para>CppCutterはC++で便利な機能をCutterに追加します。C++でテストを書きたい場合はCppCutterの使用を検討してください。</para>
<para>CppCutterを使うことは簡単です。&lt;cutter.h&gt;の代わりに&lt;cppcutter.h&gt;をinlcudeして、cutter.pcの代わりにcppcutter.pcを使うだけです。</para>
<para>test-xxx.cpp:</para>
<informalexample><programlisting><![CDATA[
-#include <cutter.h>
+#include <cppcutter.h>
]]></programlisting></informalexample>
<para/>
<para>configure.ac:</para>
<informalexample><programlisting><![CDATA[
-AC_CHECK_CUTTER
+AC_CHECK_CPPCUTTER
]]></programlisting></informalexample>
<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>テスト関数はnamespaceの中に定義します。名前付け規則はCutterと同じです。つまり、'test_...'関数はテスト関数、'setup'または'cut_setup'は初期化関数、'teardown'または'cut_teardown'は後始末関数になります。</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>

</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>C++らしいAPIで検証の省略可能なメッセージを指定します。メッセージは<link linkend="printf"><function>printf()</function></link>と同じAPIか"&lt;&lt;"を使ったストリームと同じAPIを使って指定します。</para>
<para>例:</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/>
<refsect3 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>整形文字列に挿入されるパラメータ。</para></entry>
<entry role="parameter_annotations"/></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>CppCutterが有効なとき定義されます。</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>テスト関数のプロトタイプ宣言は<link linkend="CPPCUT-BEGIN-TEST-DECLS:CAPS"><literal>CPPCUT_BEGIN_TEST_DECLS</literal></link>と<link linkend="CPPCUT-END-TEST-DECLS:CAPS"><literal>CPPCUT_END_TEST_DECLS</literal></link>で囲みます:</para>
<informalexample><programlisting><![CDATA[
CPPCUT_BEGIN_TEST_DECLS
void test_add ();
void test_remove ();
CPPCUT_END_TEST_DECLS
]]></programlisting></informalexample>
<para/>
<para>このマクロは単にテスト関数のプロトタイプ宣言を'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><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>参考</title>
<para><link linkend="cutter-Assertions-with-C++-support">C++サポート付きの検証</link></para>

</refsect1>

</refentry>
