OSDN Git Service

new
authortsutsumi <>
Sun, 5 Oct 2003 10:02:10 +0000 (10:02 +0000)
committertsutsumi <>
Sun, 5 Oct 2003 10:02:10 +0000 (10:02 +0000)
12 files changed:
examples/.cvsignore [new file with mode: 0644]
examples/Makefile.am [new file with mode: 0644]
examples/complex/Makefile.am [new file with mode: 0644]
examples/complex/complex.c [new file with mode: 0644]
examples/complex/complex.h [new file with mode: 0644]
examples/complex/complexTestSuite.c [new file with mode: 0644]
examples/complex/runTest.c [new file with mode: 0644]
examples/complex/runTestFixture.c [new file with mode: 0644]
examples/complex/runTestRunner.c [new file with mode: 0644]
examples/complex/runTestSuite.c [new file with mode: 0644]
examples/complex/testComplex.c [new file with mode: 0644]
examples/complex/testComplexMulDiv.c [new file with mode: 0644]

diff --git a/examples/.cvsignore b/examples/.cvsignore
new file mode 100644 (file)
index 0000000..b360bb4
--- /dev/null
@@ -0,0 +1,3 @@
+
+Makefile
+Makefile.in
diff --git a/examples/Makefile.am b/examples/Makefile.am
new file mode 100644 (file)
index 0000000..6ba4d06
--- /dev/null
@@ -0,0 +1,22 @@
+## Process this file with automake to produce Makefile.in
+##    Copyright (C) 2003 TSUTSUMI Kikuo.
+##    This file is part of the CCUnit Library.
+
+##    The CCUnit Library is free software; you can redistribute it and/or
+##    modify it under the terms of the GNU Lesser General Public License
+##    as published by the Free Software Foundation; either version 2.1 of
+##    the License, or (at your option) any later version.
+
+##    The CCUnit Library is distributed in the hope that it will be
+##    useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+##    of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+##    GNU Lesser General Public License for more details.
+
+##    You should have received a copy of the GNU Lesser General Public
+##    License along with the CCUnit Library; see the file COPYING.LESSER.
+##    If not, write to the Free Software Foundation, Inc., 59 Temple
+##    Place - Suite 330, Boston, MA 02111-1307, USA.  
+
+# $Id$
+
+SUBDIRS = complex
diff --git a/examples/complex/Makefile.am b/examples/complex/Makefile.am
new file mode 100644 (file)
index 0000000..63a466e
--- /dev/null
@@ -0,0 +1,54 @@
+## Process this file with automake to produce Makefile.in
+##   Copyright (C) 2003 TSUTSUMI Kikuo.
+##   This file is part of the CCUnit Library.
+##
+##   The CCUnit Library is free software; you can redistribute it and/or
+##   modify it under the terms of the GNU Lesser General Public License
+##   as published by the Free Software Foundation; either version 2.1 of
+##   the License, or (at your option) any later version.
+##
+##   The CCUnit Library is distributed in the hope that it will be
+##   useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+##   of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+##   GNU Lesser General Public License for more details.
+##
+##   You should have received a copy of the GNU Lesser General Public
+##   License along with the CCUnit Library; see the file COPYING.LESSER.
+##   If not, write to the Free Software Foundation, Inc., 59 Temple
+##   Place - Suite 330, Boston, MA 02111-1307, USA.  
+
+# $Id$
+
+lib_LIBRARIES = libcomplex.a
+check_PROGRAMS = runTestFixture runTestSuite runTestRunner runTest
+TESTS = runTestFixture runTestSuite runTestRunner runTest
+
+libcomplex_a_SOURCES = complex.c complex.h
+runTest_SOURCES = runTest.c testComplex.c testComplexMulDiv.c
+runTest_LDADD = -lcomplex -lccunit
+nodist_runTest_SOURCES = suiteComplex.c
+BUILT_SOURCES = suiteComplex.c
+
+runTestFixture_SOURCES = runTestFixture.c testComplex.c
+runTestFixture_LDADD = -lcomplex -lccunit
+
+runTestSuite_SOURCES = runTestSuite.c testComplexMulDiv.c testComplex.c \
+       complexTestSuite.c
+runTestSuite_LDADD = -lcomplex -lccunit
+
+runTestRunner_SOURCES = runTestRunner.c testComplexMulDiv.c testComplex.c \
+       complexTestSuite.c
+runTestRunner_LDADD = -lcomplex -lccunit
+
+AM_CFLAGS=-Wall -Werror
+AM_CPPFLAGS=-I. -I$(top_srcdir)/src
+AM_LDFLAGS=-L. -L$(top_srcdir)/src/ccunit
+
+EXTRA_DIST=
+
+CLEANFILES=*~ .*~ ./\#*\# *.log suiteComplex.c
+
+MAKESUITE=$(top_srcdir)/src/tools/ccunit_makeSuite
+
+suiteComplex.c: testComplex.c
+       $(MAKESUITE) -f complex_suite -o $@ $+
diff --git a/examples/complex/complex.c b/examples/complex/complex.c
new file mode 100644 (file)
index 0000000..99de2a2
--- /dev/null
@@ -0,0 +1,87 @@
+/* Copyright (C) 2003 TSUTSUMI Kikuo.
+   This file is part of the CCUnit Library.
+
+   The CCUnit Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public License
+   as published by the Free Software Foundation; either version 2.1 of
+   the License, or (at your option) any later version.
+
+   The CCUnit Library is distributed in the hope that it will be
+   useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+   of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the CCUnit Library; see the file COPYING.LESSER.
+   If not, write to the Free Software Foundation, Inc., 59 Temple
+   Place - Suite 330, Boston, MA 02111-1307, USA.  
+*/
+
+/*
+ * $Id$
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include "complex.h"
+
+complex_t* complex_new (double real, double imaginary)
+{
+  complex_t* cp = calloc (1, sizeof (complex_t));
+  if (!cp)
+    return NULL;
+  cp->real = real;
+  cp->imaginary = imaginary;
+  return cp;
+}
+
+inline void complex_delete (const complex_t* cp)
+{
+  free ((complex_t*)cp);
+}
+
+char* complex_to_string (const complex_t* cp)
+{
+  char* str = calloc (40, sizeof (char));
+  snprintf (str, 40, "%g%+gi", cp->real, cp->imaginary);
+  return str;
+}
+
+complex_t* complex_add (complex_t* z, const complex_t* x, const complex_t* y)
+{
+  z->real = x->real + y->real;
+  z->imaginary = x->imaginary + y->imaginary;
+  return z;
+}
+
+complex_t* complex_sub (complex_t* z, const complex_t* x, const complex_t* y)
+{
+  z->real = x->real - y->real;
+  z->imaginary = x->imaginary - y->imaginary;
+  return z;
+}
+
+complex_t* complex_mul (complex_t* z, const complex_t* x, const complex_t* y)
+{
+  complex_t c;
+  c.real = x->real * y->real - x->imaginary * y->imaginary;
+  c.imaginary = x->real * y->imaginary + x->imaginary * y->real;
+  *z = c;
+  return z;
+}
+
+complex_t* complex_div (complex_t* z, const complex_t* x, const complex_t* y)
+{
+  const double r2 = y->real * y->real + y->imaginary * y->imaginary;
+  complex_t c;
+  c.real = (x->real * y->real + x->imaginary * y->imaginary) / r2;
+  c.imaginary = (x->imaginary * y->real - x->real * y->imaginary) / r2;
+  *z = c;
+  return z;
+}
+
+inline int complex_equals (const complex_t*x, const complex_t* y)
+{
+  return x->real == y->real && x->imaginary == y->imaginary;
+}
diff --git a/examples/complex/complex.h b/examples/complex/complex.h
new file mode 100644 (file)
index 0000000..4aa76b2
--- /dev/null
@@ -0,0 +1,43 @@
+/* -*- C -*- */
+/* Copyright (C) 2003 TSUTSUMI Kikuo.
+   This file is part of the CCUnit Library.
+
+   The CCUnit Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public License
+   as published by the Free Software Foundation; either version 2.1 of
+   the License, or (at your option) any later version.
+
+   The CCUnit Library is distributed in the hope that it will be
+   useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+   of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the CCUnit Library; see the file COPYING.LESSER.
+   If not, write to the Free Software Foundation, Inc., 59 Temple
+   Place - Suite 330, Boston, MA 02111-1307, USA.  
+*/
+
+/*
+ * $Id$
+ */
+
+#ifndef COMPLEX_H
+#define COMPLEX_H
+
+typedef struct complex_t
+{
+  double real;
+  double imaginary;
+} complex_t;
+
+extern complex_t* complex_new (double real, double imaginary);
+extern inline void complex_delete (const complex_t* cp);
+extern char* complex_to_string (const complex_t* cp);
+extern complex_t* complex_add (complex_t* z, const complex_t* x, const complex_t* y);
+extern complex_t* complex_sub (complex_t* z, const complex_t* x, const complex_t* y);
+extern complex_t* complex_mul (complex_t* z, const complex_t* x, const complex_t* y);
+extern complex_t* complex_div (complex_t* z, const complex_t* x, const complex_t* y);
+extern inline int complex_equals (const complex_t*x, const complex_t* y);
+
+#endif /* COMPLEX_H */
diff --git a/examples/complex/complexTestSuite.c b/examples/complex/complexTestSuite.c
new file mode 100644 (file)
index 0000000..77352c9
--- /dev/null
@@ -0,0 +1,79 @@
+/* Copyright (C) 2003 TSUTSUMI Kikuo.
+   This file is part of the CCUnit Library.
+
+   The CCUnit Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public License
+   as published by the Free Software Foundation; either version 2.1 of
+   the License, or (at your option) any later version.
+
+   The CCUnit Library is distributed in the hope that it will be
+   useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+   of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the CCUnit Library; see the file COPYING.LESSER.
+   If not, write to the Free Software Foundation, Inc., 59 Temple
+   Place - Suite 330, Boston, MA 02111-1307, USA.  
+*/
+
+/*
+ * $Id$
+ */
+
+#include <ccunit/CCUnitTestSuite.h>
+
+void setUp_complex_test ();
+void tearDown_complex_test ();
+void test_complex_equals ();
+void test_complex_add ();
+void test_complex_sub ();
+
+void setUp_complex_mul_div ();
+void tearDown_complex_mul_div ();
+void test_complex_mul ();
+void test_complex_div ();
+
+CCUnitTestSuite* complex_add_sub_suite ()
+{
+  CCUnitTestFixture* fixture;
+  CCUnitTestSuite* suite;
+  fixture = ccunit_newTestFixture ("complex add sub test",
+                                   CCUNIT_NEWTESTFUNC(setUp_complex_test),
+                                   CCUNIT_NEWTESTFUNC(tearDown_complex_test));
+  ccunit_addNewTestCase (fixture, 
+                         "test_complex_equals",
+                         "complex equals test",
+                         test_complex_equals);
+  ccunit_addNewTestCase (fixture,
+                         "test_complex_add",
+                         "complex add test",
+                         test_complex_add);
+  ccunit_addNewTestCase (fixture,
+                         "test_complex_sub",
+                         "complex sub test",
+                         test_complex_sub);
+  suite = ccunit_newTestSuite ("complex add/sub test");
+  ccunit_addTestFixture (suite, fixture);
+  return suite;
+}
+
+CCUnitTestSuite* complex_mul_div_suite ()
+{
+  CCUnitTestFixture* fixture;
+  CCUnitTestSuite* suite;
+  fixture = ccunit_newTestFixture ("complex mul div test",
+                                   CCUNIT_NEWTESTFUNC(setUp_complex_mul_div),
+                                   CCUNIT_NEWTESTFUNC(tearDown_complex_mul_div));
+  ccunit_addNewTestCase (fixture, 
+                         "test_complex_mul",
+                         "complex mul test",
+                         test_complex_mul);
+  ccunit_addNewTestCase (fixture,
+                         "test_complex_div",
+                         "complex div test",
+                         test_complex_div);
+  suite = ccunit_newTestSuite ("complex mul/div test");
+  ccunit_addTestFixture (suite, fixture);
+  return suite;
+}
diff --git a/examples/complex/runTest.c b/examples/complex/runTest.c
new file mode 100644 (file)
index 0000000..3a517c3
--- /dev/null
@@ -0,0 +1,37 @@
+/* Copyright (C) 2003 TSUTSUMI Kikuo.
+   This file is part of the CCUnit Library.
+
+   The CCUnit Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public License
+   as published by the Free Software Foundation; either version 2.1 of
+   the License, or (at your option) any later version.
+
+   The CCUnit Library is distributed in the hope that it will be
+   useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+   of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the CCUnit Library; see the file COPYING.LESSER.
+   If not, write to the Free Software Foundation, Inc., 59 Temple
+   Place - Suite 330, Boston, MA 02111-1307, USA.  
+*/
+
+/*
+ * $Id$
+ */
+
+#include <stdio.h>
+#include <ccunit/CCUnitTestRunner.h>
+#include <ccunit/CCUnitTestSuite.h>
+
+extern CCUnitTestSuite* complex_suite (const char* name);
+
+int main ()
+{
+  CCUnitTestRunner* runner;
+  CCUnitTestSuite* suite;
+  runner = ccunit_newTestRunner (stdout);
+  suite = complex_suite ("complex test suite");
+  return ccunit_runTestRunner (runner, suite);
+}
diff --git a/examples/complex/runTestFixture.c b/examples/complex/runTestFixture.c
new file mode 100644 (file)
index 0000000..62884cb
--- /dev/null
@@ -0,0 +1,50 @@
+/* Copyright (C) 2003 TSUTSUMI Kikuo.
+   This file is part of the CCUnit Library.
+
+   The CCUnit Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public License
+   as published by the Free Software Foundation; either version 2.1 of
+   the License, or (at your option) any later version.
+
+   The CCUnit Library is distributed in the hope that it will be
+   useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+   of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the CCUnit Library; see the file COPYING.LESSER.
+   If not, write to the Free Software Foundation, Inc., 59 Temple
+   Place - Suite 330, Boston, MA 02111-1307, USA.  
+*/
+
+/*
+ * $Id$
+ */
+
+#include <ccunit/CCUnit.h>
+
+extern void setUp_complex_test();
+extern void tearDown_complex_test();
+extern void test_complex_equals();
+extern void test_complex_add();
+
+int main ()
+{
+  CCUnitTestFixture* fixture;
+  CCUnitTestResult* result;
+  bool success;
+  fixture = ccunit_newTestFixture ("complex test",
+                                   CCUNIT_NEWTESTFUNC(setUp_complex_test),
+                                   CCUNIT_NEWTESTFUNC(tearDown_complex_test));
+  ccunit_addNewTestCase (fixture, 
+                         "test_complex_equals",
+                         "complex equals test",
+                         test_complex_equals);
+  ccunit_addNewTestCase (fixture,
+                         "test_complex_add",
+                         "complex add test",
+                         test_complex_add);
+  result = ccunit_runTestFixture (fixture);
+  success = ccunit_wasSuccessful (result);
+  return success ? 0 : -1;
+}
diff --git a/examples/complex/runTestRunner.c b/examples/complex/runTestRunner.c
new file mode 100644 (file)
index 0000000..bd7c7dc
--- /dev/null
@@ -0,0 +1,39 @@
+/* Copyright (C) 2003 TSUTSUMI Kikuo.
+   This file is part of the CCUnit Library.
+
+   The CCUnit Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public License
+   as published by the Free Software Foundation; either version 2.1 of
+   the License, or (at your option) any later version.
+
+   The CCUnit Library is distributed in the hope that it will be
+   useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+   of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the CCUnit Library; see the file COPYING.LESSER.
+   If not, write to the Free Software Foundation, Inc., 59 Temple
+   Place - Suite 330, Boston, MA 02111-1307, USA.  
+*/
+
+/*
+ * $Id$
+ */
+
+#include <stdio.h>
+#include <ccunit/CCUnit.h>
+
+extern CCUnitTestSuite* complex_add_sub_suite ();
+extern CCUnitTestSuite* complex_mul_div_suite ();
+
+int main ()
+{
+  CCUnitTestRunner* runner;
+  CCUnitTestSuite* suite;
+  suite = ccunit_newTestSuite ("suite");
+  ccunit_addTestSuite (suite, complex_add_sub_suite ());
+  ccunit_addTestSuite (suite, complex_mul_div_suite ());
+  runner = ccunit_newTestRunner (stdout);
+  return ccunit_runTestRunner (runner, suite);
+}
diff --git a/examples/complex/runTestSuite.c b/examples/complex/runTestSuite.c
new file mode 100644 (file)
index 0000000..c07cc2a
--- /dev/null
@@ -0,0 +1,40 @@
+/* Copyright (C) 2003 TSUTSUMI Kikuo.
+   This file is part of the CCUnit Library.
+
+   The CCUnit Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public License
+   as published by the Free Software Foundation; either version 2.1 of
+   the License, or (at your option) any later version.
+
+   The CCUnit Library is distributed in the hope that it will be
+   useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+   of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the CCUnit Library; see the file COPYING.LESSER.
+   If not, write to the Free Software Foundation, Inc., 59 Temple
+   Place - Suite 330, Boston, MA 02111-1307, USA.  
+*/
+
+/*
+ * $Id$
+ */
+
+#include <ccunit/CCUnit.h>
+
+CCUnitTestSuite* complex_add_sub_suite ();
+CCUnitTestSuite* complex_mul_div_suite ();
+
+int main ()
+{
+  CCUnitTestSuite* suite;
+  CCUnitTestResult* result;
+  bool success;
+  suite = ccunit_newTestSuite ("suite");
+  ccunit_addTestSuite (suite, complex_add_sub_suite ());
+  ccunit_addTestSuite (suite, complex_mul_div_suite ());
+  result = ccunit_runTestSuite (suite, NULL);
+  success = ccunit_wasSuccessful (result);
+  return success ? 0 : -1;
+}
diff --git a/examples/complex/testComplex.c b/examples/complex/testComplex.c
new file mode 100644 (file)
index 0000000..915cbe8
--- /dev/null
@@ -0,0 +1,75 @@
+/* Copyright (C) 2003 TSUTSUMI Kikuo.
+   This file is part of the CCUnit Library.
+
+   The CCUnit Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public License
+   as published by the Free Software Foundation; either version 2.1 of
+   the License, or (at your option) any later version.
+
+   The CCUnit Library is distributed in the hope that it will be
+   useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+   of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the CCUnit Library; see the file COPYING.LESSER.
+   If not, write to the Free Software Foundation, Inc., 59 Temple
+   Place - Suite 330, Boston, MA 02111-1307, USA.  
+*/
+
+/*
+ * $Id$
+ */
+
+#include <ccunit/CCUnitAssert.h>
+
+/** TEST CASE: complex number test */
+
+#include <complex.h>
+
+static complex_t* s10_1;
+static complex_t* s1_1;
+static complex_t* s11_2;
+
+void setUp_complex_test ()
+{
+  s10_1 = complex_new (10, 1);
+  s1_1 = complex_new (1, 1);
+  s11_2 = complex_new (11, 2);
+}
+void tearDown_complex_test ()
+{
+  complex_delete (s10_1);
+  complex_delete (s1_1);
+  complex_delete (s11_2);
+}
+
+/** test equals */
+void test_complex_equals ()
+{
+  CCUNIT_ASSERT_TEST_OBJ (s10_1, complex_equals, s10_1, complex_to_string);
+  CCUNIT_ASSERT_TEST_OBJ (s10_1, !complex_equals, s1_1, complex_to_string);
+}
+
+/** test add */
+void test_complex_add ()
+{
+  complex_t c10_1 = { 10.0, 1.0 };
+  complex_t c1_1 = { 1.0, 1.0 };
+  complex_t result;
+  complex_t c11_2 = { 11.0, 2.0 };
+  CCUNIT_ASSERT (complex_equals (&c11_2, complex_add (&result, &c10_1, &c1_1)));
+}
+
+/** test sub */
+void test_complex_sub ()
+{
+  complex_t c9_0 = { 9, 0 };
+  complex_t result;
+  CCUNIT_ASSERT_TEST_OBJ (&c9_0, complex_equals,
+                         complex_sub (&result, s10_1, s1_1),
+                         complex_to_string);
+}
+
+/** end test case */
diff --git a/examples/complex/testComplexMulDiv.c b/examples/complex/testComplexMulDiv.c
new file mode 100644 (file)
index 0000000..29cf07f
--- /dev/null
@@ -0,0 +1,68 @@
+/* Copyright (C) 2003 TSUTSUMI Kikuo.
+   This file is part of the CCUnit Library.
+
+   The CCUnit Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public License
+   as published by the Free Software Foundation; either version 2.1 of
+   the License, or (at your option) any later version.
+
+   The CCUnit Library is distributed in the hope that it will be
+   useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+   of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the CCUnit Library; see the file COPYING.LESSER.
+   If not, write to the Free Software Foundation, Inc., 59 Temple
+   Place - Suite 330, Boston, MA 02111-1307, USA.  
+*/
+
+/*
+ * $Id$
+ */
+
+#include <ccunit/CCUnitAssert.h>
+
+/** TEST SUITE: complex mul div test suite */
+
+/** TEST CASE: complex number mul/div test */
+
+#include <complex.h>
+
+static complex_t* s6_3;
+static complex_t* s3_2;
+static complex_t* smul;
+static complex_t* sdiv;
+
+void setUp_complex_mul_div ()
+{
+  const double r2 = 3*3 + 2*2;
+  s6_3 = complex_new (6, 3);
+  s3_2 = complex_new (3, 2);
+  smul = complex_new (6*3 - 3*2, 6*2 + 3*3);
+  sdiv = complex_new ((6*3 + 3*2)/r2, (3*3 - 6*2)/r2);
+}
+void tearDown_complex_mul_div ()
+{
+  complex_delete (s6_3);
+  complex_delete (s3_2);
+  complex_delete (smul);
+  complex_delete (sdiv);
+}
+
+void test_complex_mul ()
+{
+  complex_t result;
+  CCUNIT_ASSERT_TEST_OBJ (smul, complex_equals,
+                         complex_mul (&result, s6_3, s3_2),
+                         complex_to_string);
+}
+
+void test_complex_div ()
+{
+  complex_t result;
+  CCUNIT_ASSERT_TEST_OBJ (sdiv, complex_equals,
+                         complex_div (&result, s6_3, s3_2),
+                         complex_to_string);
+}