os/ossrv/genericopenlibs/cppstdlib/stl/test/unit/cmath_test.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 //
    15 
    16 #define _STLP_DO_IMPORT_CSTD_FUNCTIONS
    17 
    18 #include <limits>
    19 #include <cmath>
    20 #include <complex>
    21 //We also test math functions imported from stdlib.h or
    22 //defined in cstdlib
    23 #include <cstdlib>
    24 
    25 #include "math_aux.h"
    26 #include "cppunit/cppunit_proxy.h"
    27 
    28 //This test purpose is to check the right import of math.h C symbols
    29 //into the std namespace so we do not use the using namespace std
    30 //specification
    31 
    32 //
    33 // TestCase class
    34 //
    35 class CMathTest : public CPPUNIT_NS::TestCase // codescanner::missingcclass
    36 {
    37   CPPUNIT_TEST_SUITE(CMathTest);
    38   CPPUNIT_TEST(test);
    39   CPPUNIT_TEST(complex_double_cov1);
    40   CPPUNIT_TEST(complex_double_cov2);
    41   CPPUNIT_TEST(complex_double_cov3);
    42   CPPUNIT_TEST(complex_double_cov4);
    43   CPPUNIT_TEST(complex_float_cov1);
    44   CPPUNIT_TEST(complex_float_cov2);
    45   CPPUNIT_TEST(complex_float_cov3);
    46   CPPUNIT_TEST(complex_float_cov4);
    47   CPPUNIT_TEST(complex_longdouble_cov1);
    48   CPPUNIT_TEST(complex_longdouble_cov2);
    49   CPPUNIT_TEST(complex_longdouble_cov3);
    50   CPPUNIT_TEST(complex_longdouble_cov4);
    51   CPPUNIT_TEST(complex_trigonometric_cov);
    52   CPPUNIT_TEST(complex_cmath_cov);
    53   CPPUNIT_TEST(complex_templates_cov1);
    54   CPPUNIT_TEST(complex_templates_cov2);
    55   CPPUNIT_TEST(complex_constructors_cov1);
    56   CPPUNIT_TEST(complex_constructors_cov2);
    57   CPPUNIT_TEST_SUITE_END();
    58 
    59   protected:
    60     void test();
    61     void complex_double_cov1();
    62     void complex_double_cov2();
    63     void complex_double_cov3();
    64     void complex_double_cov4();
    65     void complex_float_cov1();
    66     void complex_float_cov2();
    67     void complex_float_cov3();
    68     void complex_float_cov4();
    69     void complex_longdouble_cov1();
    70     void complex_longdouble_cov2();
    71     void complex_longdouble_cov3();
    72     void complex_longdouble_cov4();
    73     void complex_trigonometric_cov();
    74     void complex_cmath_cov();
    75     void complex_templates_cov1();
    76     void complex_templates_cov2();
    77     void complex_constructors_cov1();
    78     void complex_constructors_cov2();
    79 };
    80 
    81 CPPUNIT_TEST_SUITE_REGISTRATION(CMathTest);
    82 
    83 //
    84 // tests implementation
    85 //
    86 void CMathTest::test()
    87 {
    88   int int_val = -1;
    89   long long_val = -1l;
    90   float float_val = -1.0f;
    91   double double_val = -1.0;
    92 #if !defined (_STLP_NO_LONG_DOUBLE)
    93   long double long_double_val = -1.0l;
    94 #endif
    95 
    96   CPPUNIT_CHECK( are_equals(std::abs(int_val), -int_val) );
    97   CPPUNIT_CHECK( are_equals(std::abs(long_val), -long_val) );
    98   CPPUNIT_CHECK( are_equals(std::labs(long_val), -long_val) );
    99   CPPUNIT_CHECK( are_equals(std::abs(float_val), -float_val) );
   100   CPPUNIT_CHECK( are_equals(std::abs(double_val), -double_val) );
   101 #if !defined (_STLP_NO_LONG_DOUBLE)
   102   CPPUNIT_CHECK( are_equals(std::abs(long_double_val), -long_double_val) );
   103 #endif
   104 
   105   CPPUNIT_CHECK( are_equals(std::fabs(float_val), -float_val) );
   106   CPPUNIT_CHECK( are_equals(std::fabs(double_val), -double_val) );
   107 #if !defined (_STLP_NO_LONG_DOUBLE)
   108   CPPUNIT_CHECK( are_equals(std::fabs(long_double_val), -long_double_val) );
   109 #endif
   110 
   111   std::div_t div_res = std::div(3, 2);
   112   CPPUNIT_CHECK( div_res.quot == 1 );
   113   CPPUNIT_CHECK( div_res.rem == 1 );
   114   std::ldiv_t ldiv_res = std::ldiv(3l, 2l);
   115   CPPUNIT_CHECK( ldiv_res.quot == 1l );
   116   CPPUNIT_CHECK( ldiv_res.rem == 1l );
   117   ldiv_res = std::div(3l, 2l);
   118   CPPUNIT_CHECK( ldiv_res.quot == 1l );
   119   CPPUNIT_CHECK( ldiv_res.rem == 1l );
   120 
   121   std::srand(2);
   122   int rand_val = std::rand();
   123   CPPUNIT_CHECK( rand_val >= 0 && rand_val <= RAND_MAX );
   124 
   125   CPPUNIT_CHECK( are_equals(std::floor(1.5), 1.0) );
   126   CPPUNIT_CHECK( are_equals(std::ceil(1.5), 2.0) );
   127   CPPUNIT_CHECK( are_equals(std::fmod(1.5, 1.0), 0.5) );
   128   CPPUNIT_CHECK( are_equals(std::sqrt(4.0), 2.0) );
   129   CPPUNIT_CHECK( are_equals(std::pow(2.0, 2), 4.0) );
   130   /*
   131    * Uncomment the following to check that it generates an ambiguous call
   132    * as there is no Standard pow(int, int) function only pow(double, int),
   133    * pow(float, int) and some others...
   134    * If it do not generate a compile time error it should at least give
   135    * the good result.
   136    */
   137   //CPPUNIT_CHECK( are_equals(std::pow(10, -2), 0.01) );
   138   CPPUNIT_CHECK( are_equals(std::pow(10.0, -2), 0.01) );
   139   CPPUNIT_CHECK( are_equals(std::exp(0.0), 1.0) );
   140   CPPUNIT_CHECK( are_equals(std::log(std::exp(1.0)), 1.0) );
   141   CPPUNIT_CHECK( are_equals(std::log10(100.0), 2.0) );
   142 #if !defined (STLPORT) || !defined (_STLP_USING_PLATFORM_SDK_COMPILER) || !defined (_WIN64)
   143   CPPUNIT_CHECK( are_equals(std::modf(100.5, &double_val), 0.5) );
   144   CPPUNIT_CHECK( are_equals(double_val, 100.0) );
   145 #endif
   146   double_val = std::frexp(8.0, &int_val);
   147   CPPUNIT_CHECK( are_equals(double_val * std::pow(2.0, int_val), 8.0) );
   148   CPPUNIT_CHECK( are_equals(std::ldexp(1.0, 2), 4.0) );
   149   CPPUNIT_CHECK( are_equals(std::cos(std::acos(1.0)), 1.0) );
   150   CPPUNIT_CHECK( are_equals(std::sin(std::asin(1.0)), 1.0) );
   151   CPPUNIT_CHECK( are_equals(std::tan(std::atan(1.0)), 1.0) );
   152   CPPUNIT_CHECK( are_equals(std::tan(std::atan2(1.0, 1.0)), 1.0) );
   153   CPPUNIT_CHECK( are_equals(std::cosh(0.0), 1.0) );
   154   CPPUNIT_CHECK( are_equals(std::sinh(0.0), 0.0) );
   155 #if !defined (STLPORT) || !defined (_STLP_USING_PLATFORM_SDK_COMPILER) || !defined (_M_AMD64)
   156   CPPUNIT_CHECK( are_equals(std::tanh(0.0), 0.0) );
   157 #endif
   158 
   159   CPPUNIT_CHECK( are_equals(std::floor(1.5f), 1.0f) );
   160   CPPUNIT_CHECK( are_equals(std::ceil(1.5f), 2.0f) );
   161   CPPUNIT_CHECK( are_equals(std::fmod(1.5f, 1.0f), 0.5f) );
   162   CPPUNIT_CHECK( are_equals(std::sqrt(4.0f), 2.0f) );
   163   CPPUNIT_CHECK( are_equals(std::pow(2.0f, 2), 4.0f) );
   164   CPPUNIT_CHECK( are_equals(std::exp(0.0f), 1.0f) );
   165   CPPUNIT_CHECK( are_equals(std::log(std::exp(1.0f)), 1.0f) );
   166   CPPUNIT_CHECK( are_equals(std::log10(100.0f), 2.0f) );
   167 #if !defined (STLPORT) || !defined (_STLP_USING_PLATFORM_SDK_COMPILER) || !defined (_WIN64)
   168   CPPUNIT_CHECK( are_equals(std::modf(100.5f, &float_val), 0.5f) );
   169   CPPUNIT_CHECK( are_equals(float_val, 100.0f) );
   170 #endif
   171   float_val = std::frexp(8.0f, &int_val);
   172   CPPUNIT_CHECK( are_equals(float_val * std::pow(2.0f, int_val), 8.0f) );
   173   CPPUNIT_CHECK( are_equals(std::ldexp(1.0f, 2), 4.0f) );
   174   CPPUNIT_CHECK( are_equals(std::cos(std::acos(1.0f)), 1.0f) );
   175   CPPUNIT_CHECK( are_equals(std::sin(std::asin(1.0f)), 1.0f) );
   176   CPPUNIT_CHECK( are_equals(std::tan(std::atan(1.0f)), 1.0f) );
   177   CPPUNIT_CHECK( are_equals(std::tan(std::atan2(1.0f, 1.0f)), 1.0f) );
   178   CPPUNIT_CHECK( are_equals(std::cosh(0.0f), 1.0f) );
   179   CPPUNIT_CHECK( are_equals(std::sinh(0.0f), 0.0f) );
   180 #if !defined (STLPORT) || !defined (_STLP_USING_PLATFORM_SDK_COMPILER) || !defined (_M_AMD64)
   181   CPPUNIT_CHECK( are_equals(std::tanh(0.0f), 0.0f) );
   182 #endif
   183 
   184 #if !defined (_STLP_NO_LONG_DOUBLE)
   185   CPPUNIT_CHECK( are_equals(std::floor(1.5l), 1.0l) );
   186   CPPUNIT_CHECK( are_equals(std::ceil(1.5l), 2.0l) );
   187   CPPUNIT_CHECK( are_equals(std::fmod(1.5l, 1.0l), 0.5l) );
   188   CPPUNIT_CHECK( are_equals(std::sqrt(4.0l), 2.0l) );
   189   CPPUNIT_CHECK( are_equals(std::pow(2.0l, 2), 4.0l) );
   190   CPPUNIT_CHECK( are_equals(std::exp(0.0l), 1.0l) );
   191   CPPUNIT_CHECK( are_equals(std::log(std::exp(1.0l)), 1.0l) );
   192   CPPUNIT_CHECK( are_equals(std::log10(100.0l), 2.0l) );
   193 #  if !defined (STLPORT) || !defined (_STLP_USING_PLATFORM_SDK_COMPILER) || !defined (_WIN64)
   194   CPPUNIT_CHECK( are_equals(std::modf(100.5l, &long_double_val), 0.5l) );
   195   CPPUNIT_CHECK( are_equals(long_double_val, 100.0l) );
   196 #  endif
   197   long_double_val = std::frexp(8.0l, &int_val);
   198   CPPUNIT_CHECK( are_equals(long_double_val * std::pow(2.0l, int_val), 8.0l) );
   199   CPPUNIT_CHECK( are_equals(std::ldexp(1.0l, 2), 4.0l) );
   200   CPPUNIT_CHECK( are_equals(std::cos(std::acos(1.0l)), 1.0l) );
   201   CPPUNIT_CHECK( are_equals(std::sin(std::asin(1.0l)), 1.0l) );
   202   CPPUNIT_CHECK( are_equals(std::tan(0.0l), 0.0l) );
   203   CPPUNIT_CHECK( are_equals(std::atan(0.0l), 0.0l) );
   204   CPPUNIT_CHECK( are_equals(std::atan2(0.0l, 1.0l), 0.0l) );
   205   CPPUNIT_CHECK( are_equals(std::cosh(0.0l), 1.0l) );
   206   CPPUNIT_CHECK( are_equals(std::sinh(0.0l), 0.0l) );
   207 #  if !defined (STLPORT) || !defined (_STLP_USING_PLATFORM_SDK_COMPILER) || !defined (_M_AMD64)
   208   CPPUNIT_CHECK( are_equals(std::tanh(0.0l), 0.0l) );
   209 #  endif
   210 #endif
   211 
   212   CPPUNIT_CHECK( are_equals(std::sqrt(std::sqrt(std::sqrt(256.0))), 2.0) );
   213   CPPUNIT_CHECK( are_equals(std::sqrt(std::sqrt(std::sqrt(256.0f))), 2.0f) );
   214 #if !defined (_STLP_NO_LONG_DOUBLE)
   215   CPPUNIT_CHECK( are_equals(std::sqrt(std::sqrt(std::sqrt(256.0l))), 2.0l) );
   216 #endif
   217 }
   218 void CMathTest::complex_double_cov1()
   219 	{
   220 	using namespace std;
   221 	double pi = 3.14159265359;
   222 	// Test Case for abs,arg abd SQRT
   223 	{
   224 	complex <double> c1( polar ( 5.0 ) ); 
   225 	complex <double> c2 ( polar ( 5.0 , pi / 6 ) );
   226 	double absc1 = abs ( c1 );
   227 	double argc1 = arg ( c1 );
   228 	CPPUNIT_CHECK( absc1 == 5 );
   229 	CPPUNIT_CHECK( argc1 == 0 );
   230 	double normc2 = norm ( c2 );
   231 	double sqrtnormc2 = sqrt ( normc2 );
   232 	CPPUNIT_CHECK(sqrtnormc2 == 5);
   233 	}
   234 	// Test case for the real,imag and conj
   235 	{
   236 	complex <double> c1 ( 4.0 , 3.0 );
   237 	double dr1 = real ( c1 );
   238 	CPPUNIT_CHECK(dr1 == 4);
   239 	double di1 = imag ( c1 );
   240 	CPPUNIT_CHECK(di1 == 3);
   241 	complex <double> c2 = conj ( c1 );
   242 	double dr2 = real ( c2 );
   243 	CPPUNIT_CHECK(dr2 == 4);
   244 	double di2 = imag ( c2 );
   245 	CPPUNIT_CHECK(di2 == -3);
   246 	}
   247 	// test case for the operator "=" , the 3 templates 
   248 	{
   249 	complex <double> cl1 ( polar (3.0 , pi / 6 ) );
   250 	complex <double> cr1a ( polar (2.0 , pi /3 ) );
   251 	complex <double> cr1b ( polar (2.0 , pi / 3 ) );
   252 	CPPUNIT_CHECK(cl1 != cr1a);
   253 	CPPUNIT_CHECK(cr1b == cr1a);
   254 	
   255 	double cl3a =3;
   256 	double cl3b =5;
   257 	complex <double> cr3a ( 3 , 4 );
   258 	complex <double> cr3b ( 5 ,0 );
   259 	CPPUNIT_CHECK(cl3a != cr3a);
   260 	CPPUNIT_CHECK(cl3b == cr3b);
   261 	
   262 	complex <int> cl2a ( 3 , 4 );
   263 	complex <int> cl2b ( 5 ,0 );
   264 	int cr2a =3;
   265 	CPPUNIT_CHECK(cl2a != cr2a);
   266 	}
   267 }
   268 void CMathTest::complex_double_cov2()
   269 	{
   270 	using namespace std;
   271 	double pi = 3.14159265359;
   272 	// test case for the operator "*" , the 3 templates 
   273 	{
   274 	complex <double> cl1 ( polar (3.0 , pi / 6 ) );
   275 	complex <double> cr1 ( 5,0 );
   276 	complex <double> cs1 = cl1 * cr1;	
   277 	complex <double> cl2 ( polar ( 3.0 , pi / 6 ) );
   278 	double cr2 =5;
   279 	complex <double> cs2 = cl2 * cr2;
   280 	double cl3 = 5;
   281 	complex <double> cr3 ( polar (3.0 , pi / 6 ) );
   282 	complex <double> cs3 = cl3 * cr3;
   283 	
   284 	CPPUNIT_CHECK(cs1 == cs2);
   285 	CPPUNIT_CHECK(cs3 == cs2);
   286 	}
   287 	// test case for the operator "+" , the 3 templates 
   288 	{
   289 	complex <double> cl1 ( polar (3.0 , pi / 6 ) );
   290 	complex <double> cr1 ( 5,0 );
   291 	complex <double> cs1 = cl1 + cr1;	
   292 	complex <double> cl2 ( polar ( 3.0 , pi / 6 ) );
   293 	double cr2 =5;
   294 	complex <double> cs2 = cl2 + cr2;
   295 	double cl3 = 5;
   296 	complex <double> cr3 ( polar (3.0 , pi / 6 ) );
   297 	complex <double> cs3 = cl3 + cr3;
   298 	
   299 	complex <double> cr4 ( 3.0 , 4.0 );
   300 	complex <double> cs4 = + cr4;
   301 	   
   302 	CPPUNIT_CHECK(cs4 == cr4);
   303 	CPPUNIT_CHECK(cs1 == cs2);
   304 	CPPUNIT_CHECK(cs3 == cs2);
   305 	}
   306 	// test case for the operator "-" , the 3 templates 
   307 	{
   308 	complex <double> cl1 (3 , 4);
   309 	complex <double> cr1 ( 2,3 );
   310 	complex <double> cs1 = cl1 - cr1;
   311 	complex <double> cs11 ( 1,1 );
   312 	CPPUNIT_CHECK(cs1 == cs11);
   313 	
   314 	complex <double> cl2 (3 , 4);
   315 	double cr2 =5;
   316 	complex <double> cs2 = cl2 - cr2;
   317 	complex <double> cs22 (-2 , 4);
   318 	CPPUNIT_CHECK(cs2 == cs22);
   319 	
   320 	double cl3 = 5;
   321 	complex <double> cr3 (3 , 4);
   322 	complex <double> cs3 = cl3 - cr3;
   323 	complex <double> cs33 (2 , -4);
   324 	CPPUNIT_CHECK(cs3 == cs33);
   325 	
   326 	complex <double> cr4 ( 3 , 4 );
   327 	complex <double> cs4 = -cr4;
   328 	complex <double> cs44 (-3 , -4);
   329 	CPPUNIT_CHECK(cs4 == cs44);
   330 	}
   331 	// test case for the operator "/" , the 3 templates 
   332 	{
   333 	complex <double> cl1 (4 , 4);
   334 	complex <double> cr1 ( 2,2 );
   335 	complex <double> cs1 = cl1/cr1;
   336 	complex <double> cs11 ( 2,0 );
   337 	CPPUNIT_CHECK(cs1 == cs11);
   338 	
   339 	complex <double> cl2 (4 , 4);
   340 	double cr2 =2;
   341 	complex <double> cs2 = cl2/cr2;
   342 	complex <double> cs22 (2 , 2);
   343 	CPPUNIT_CHECK(cs2 == cs22);
   344 	
   345 	double cl3 = 4;
   346 	complex <double> cr3 (2 , 2);
   347 	complex <double> cs3 = cl3/cr3;
   348 	complex <double> cs33 (1 , -1);
   349 	CPPUNIT_CHECK(cs3 == cs33);
   350 	}
   351 }
   352 
   353 void CMathTest::complex_double_cov3()
   354 	{
   355 	using namespace std;
   356 	double pi = 3.14159265359;
   357 	// test case for the operator "*=" , the 3 templates 
   358 	{
   359 	complex <double> cl1 ( polar (3.0 , pi / 6 ) );
   360 	complex <double> cr1 ( 5,0 );
   361 	complex <double> cs1 = cl1 * cr1;	
   362 	complex <double> cs11 (10,0);	
   363 	complex <int> cint1 ( 2,0 );
   364 	complex <double> csresult (20,0);	
   365 	cl1 *= cr1;
   366 	CPPUNIT_CHECK(cs1 == cl1);
   367 	
   368 	double val = 2;
   369 	cr1 *= val;
   370 	CPPUNIT_CHECK(cr1 == cs11);	
   371 	cs11 *= cint1;
   372 	CPPUNIT_CHECK(csresult == cs11);	
   373 	}
   374 	// test case for the operator "+=" , the 3 templates 
   375 	{
   376 	complex <double> cl1 ( polar (3.0 , pi / 6 ) );
   377 	complex <double> cr1 ( 5,0 );
   378 	complex <double> cs1 = cl1 + cr1;	
   379 	complex <double> cs11 (7,0);	
   380 	complex <int> cint1 ( 2,0 );
   381 	complex <double> csresult (9,0);
   382 	cl1 += cr1;
   383 	CPPUNIT_CHECK(cs1 == cl1);
   384 	
   385 	double val = 2;
   386 	cr1 += val;
   387 	CPPUNIT_CHECK(cr1 == cs11);	
   388 	cs11 += cint1;
   389 	CPPUNIT_CHECK(csresult == cs11);	
   390 	}
   391 }
   392 
   393 void CMathTest::complex_double_cov4()
   394 	{
   395 	using namespace std;
   396 	double pi = 3.14159265359;
   397 	// test case for the operator "-=" , the 3 templates 
   398 	{
   399 	complex <double> cl1 ( polar (3.0 , pi / 6 ) );
   400 	complex <double> cr1 ( 5,0 );
   401 	complex <double> cs1 = cl1 - cr1;	
   402 	complex <double> cs11 (3,0);	
   403 	complex <int> cint1 ( 2,0 );
   404 	complex <double> csresult (1,0);
   405 	cl1 -= cr1;
   406 	CPPUNIT_CHECK(cs1 == cl1);
   407 	
   408 	double val = 2;
   409 	cr1 -= val;
   410 	CPPUNIT_CHECK(cr1 == cs11);	
   411 	cs11 -= cint1;
   412 	CPPUNIT_CHECK(csresult == cs11);
   413 	}
   414 	// test case for the operator "/=" , the 3 templates 
   415 	{
   416 	complex <double> cl1 ( 10,0 );
   417 	complex <double> cr1 ( 5,0 );
   418 	complex <double> cs1 = cl1/cr1;	
   419 	complex <double> cs11 (1,0);
   420 	complex <int> cint1 ( 1,0 );
   421 	complex <double> csresult (1,0);	
   422 	cl1 /= cr1;
   423 	CPPUNIT_CHECK(cs1 == cl1);
   424 	
   425 	double val = 5;
   426 	cr1 /= val;
   427 	CPPUNIT_CHECK(cr1 == cs11);
   428 	cs11 /= cint1;
   429 	CPPUNIT_CHECK(csresult == cs11);
   430 	}
   431 	// test case for the operator "=" , the 3 templates 
   432 	{
   433 	complex <double> cl1 ( 3.0 , 4.0 );
   434 	complex <double> cr1 ( 2.0 , -1.0 );
   435 	cl1  = cr1;
   436 	CPPUNIT_CHECK(cl1 == cr1);
   437 	complex <double> cl2 ( -2 , 4 );
   438 	double cr2 =5.0;
   439 	cl2 = cr2;
   440 	CPPUNIT_CHECK(cl2 == cr2);
   441 	complex<double> cl3(3.0, 4.0);
   442 	cl2 = cl3;
   443 	CPPUNIT_CHECK(cl2 == cl3);
   444 	}
   445 }
   446 
   447 void CMathTest::complex_float_cov1()
   448 	{
   449 		using namespace std;
   450 		// test case for the abs,arg and sqrt 
   451 		{
   452 		complex <float> c1( polar ( 5.0 ) ); 
   453 		complex <float> c2 ( 5,0 );
   454 		float absc1 = abs ( c1 );
   455 		float argc1 = arg ( c1 );
   456 		CPPUNIT_CHECK( absc1 == 5 );
   457 		CPPUNIT_CHECK( argc1 == 0 );
   458 		float normc2 = norm ( c2 );
   459 		float val = 25;
   460 		float sqrtnormc2 = sqrt ( normc2 );
   461 		CPPUNIT_CHECK(normc2 == val);
   462 		CPPUNIT_CHECK(sqrtnormc2 == 5);
   463 		}
   464 		// test case for the real,imag and conj
   465 		{
   466 		complex <float> c1 ( 4.0 , 3.0 );
   467 		float dr1 = real ( c1 );
   468 	    CPPUNIT_CHECK(dr1 == 4);
   469 	    float di1 = imag ( c1 );
   470 	    CPPUNIT_CHECK(di1 == 3);
   471 	    complex <float> c2 = conj ( c1 );
   472 		float dr2 = real ( c2 );
   473 		CPPUNIT_CHECK(dr2 == 4);
   474 		float di2 = imag ( c2 );
   475 		CPPUNIT_CHECK(di2 == -3);
   476 		}
   477 		// test case for the operator "=" , the 3 templates 
   478 		{
   479 	    complex <float> cl1 ( 7,7 );
   480 	    complex <float> cr1a ( 5,7 );
   481 	    complex <float> cr1b ( 5,7 );
   482 		CPPUNIT_CHECK(cl1 != cr1a);
   483 		CPPUNIT_CHECK(cr1b == cr1a);
   484 		
   485 		float cl3a =3;
   486 		float cl3b =5;
   487 	    complex <float> cr3a ( 3 , 4 );
   488 	    complex <float> cr3b ( 5 ,0 );
   489 	    CPPUNIT_CHECK(cl3a != cr3a);
   490 	    CPPUNIT_CHECK(cl3b == cr3b);
   491 	    
   492 	    complex <int> cl2a ( 3 , 4 );
   493 	    complex <int> cl2b ( 5 ,0 );
   494 	    int cr2a =3;
   495 	    CPPUNIT_CHECK(cl2a != cr2a);
   496 		}
   497 	}
   498 void CMathTest::complex_float_cov2()
   499 	{
   500 	using namespace std;
   501 		// test case for the operator "*" , the 3 templates 
   502 		{
   503 	    complex <float> cl1 ( 7,5 );
   504 		complex <float> cr1 ( 5,0 );
   505 		complex <float> cs1 = cl1 * cr1;	
   506 		complex <float> cl2 ( 7,5 );
   507 		float cr2 =5;
   508 		complex <float> cs2 = cl2 * cr2;
   509 		float cl3 = 5;
   510 		complex <float> cr3 ( 7,5 );
   511 		complex <float> cs3 = cl3 * cr3;
   512 		
   513 		CPPUNIT_CHECK(cs1 == cs2);
   514 		CPPUNIT_CHECK(cs3 == cs2);
   515 		}
   516 		// test case for the operator "+" , the 3 templates 
   517 		{
   518 	    complex <float> cl1 ( 7,0 );
   519 		complex <float> cr1 ( 5,0 );
   520 		complex <float> cs1 = cl1 + cr1;	
   521 		complex <float> cl2 ( 7,0 );
   522 		float cr2 =5;
   523 		complex <float> cs2 = cl2 + cr2;
   524 		float cl3 = 5;
   525 		complex <float> cr3 ( 7,0 );
   526 		complex <float> cs3 = cl3 + cr3;
   527 		
   528 		complex <float> cr4 ( 3.0 , 4.0 );
   529 	    complex <float> cs4 = + cr4;
   530 		   
   531 	    CPPUNIT_CHECK(cs4 == cr4);
   532 		CPPUNIT_CHECK(cs1 == cs2);
   533 		CPPUNIT_CHECK(cs3 == cs2);
   534 		}
   535 		// test case for the operator "-" , the 3 templates 
   536 		{
   537 	    complex <float> cl1 (3 , 4);
   538 		complex <float> cr1 ( 2,3 );
   539 		complex <float> cs1 = cl1 - cr1;
   540 		complex <float> cs11 ( 1,1 );
   541 	    CPPUNIT_CHECK(cs1 == cs11);
   542 	    
   543 		complex <float> cl2 (3 , 4);
   544 		float cr2 =5;
   545 		complex <float> cs2 = cl2 - cr2;
   546 		complex <float> cs22 (-2 , 4);
   547 		CPPUNIT_CHECK(cs2 == cs22);
   548 		
   549 		float cl3 = 5;
   550 		complex <float> cr3 (3 , 4);
   551 		complex <float> cs3 = cl3 - cr3;
   552 		complex <float> cs33 (2 , -4);
   553 		CPPUNIT_CHECK(cs3 == cs33);
   554 		
   555 		complex <float> cr4 ( 3 , 4 );
   556 	    complex <float> cs4 = -cr4;
   557 		complex <float> cs44 (-3 , -4);
   558 		CPPUNIT_CHECK(cs4 == cs44);
   559 		}
   560 		// test case for the operator "/" , the 3 templates 
   561 		{
   562 	    complex <float> cl1 (4 , 4);
   563 		complex <float> cr1 ( 2,2 );
   564 		complex <float> cs1 = cl1/cr1;
   565 		complex <float> cs11 ( 2,0 );
   566 	    CPPUNIT_CHECK(cs1 == cs11);
   567 	    
   568 		complex <float> cl2 (4 , 4);
   569 		float cr2 =2;
   570 		complex <float> cs2 = cl2/cr2;
   571 		complex <float> cs22 (2 , 2);
   572 		CPPUNIT_CHECK(cs2 == cs22);
   573 		
   574 		float cl3 = 4;
   575 		complex <float> cr3 (2 , 2);
   576 		complex <float> cs3 = cl3/cr3;
   577 		complex <float> cs33 (1 , -1);
   578 		CPPUNIT_CHECK(cs3 == cs33);
   579 		}
   580 	}
   581 void CMathTest::complex_float_cov3()
   582 	{
   583 		using namespace std;
   584 		// test case for the operator "*=" , the 3 templates 
   585 		{
   586 	    complex <float> cl1 ( 7,0 );
   587 		complex <float> cr1 ( 5,0 );
   588 		complex <float> cs1 = cl1 * cr1;	
   589 		complex <float> cs11 (10,0);	
   590 		complex <int> cint1 ( 2,0 );
   591 		complex <float> csresult (20,0);	
   592 		cl1 *= cr1;
   593 		CPPUNIT_CHECK(cs1 == cl1);
   594 	
   595 		float val = 2;
   596 		cr1 *= val;
   597 		CPPUNIT_CHECK(cr1 == cs11);	
   598 		cs11 *= cint1;
   599 		CPPUNIT_CHECK(csresult == cs11);	
   600 		}
   601 		// test case for the operator "+=" , the 3 templates 
   602 		{
   603 	    complex <float> cl1 ( 7,0 );
   604 		complex <float> cr1 ( 5,0 );
   605 		complex <float> cs1 = cl1 + cr1;	
   606 		complex <float> cs11 (7,0);	
   607 		complex <int> cint1 ( 2,0 );
   608 		complex <float> csresult (9,0);
   609 		cl1 += cr1;
   610 		CPPUNIT_CHECK(cs1 == cl1);
   611 	
   612 		float val = 2;
   613 		cr1 += val;
   614 		CPPUNIT_CHECK(cr1 == cs11);	
   615 		cs11 += cint1;
   616 		CPPUNIT_CHECK(csresult == cs11);	
   617 		}
   618 		// test case for the operator "-=" , the 3 templates 
   619 		{
   620 	    complex <float> cl1 ( 7,7 );
   621 		complex <float> cr1 ( 5,0 );
   622 		complex <float> cs1 = cl1 - cr1;	
   623 		complex <float> cs11 (3,0);	
   624 		complex <int> cint1 ( 2,0 );
   625 		complex <float> csresult (1,0);
   626 		cl1 -= cr1;
   627 		CPPUNIT_CHECK(cs1 == cl1);
   628 	
   629 		float val = 2;
   630 		cr1 -= val;
   631 		CPPUNIT_CHECK(cr1 == cs11);	
   632 		cs11 -= cint1;
   633 		CPPUNIT_CHECK(csresult == cs11);
   634 		}
   635 	}
   636 void CMathTest::complex_float_cov4()
   637 	{
   638 		using namespace std;
   639 		// test case for the operator "/=" , the 3 templates 
   640 		{
   641 	    complex <float> cl1 ( 10,0 );
   642 		complex <float> cr1 ( 5,0 );
   643 		complex <float> cs1 = cl1/cr1;	
   644 		complex <float> cs11 (1,0);
   645 		complex <int> cint1 ( 1,0 );
   646 		complex <float> csresult (1,0);	
   647 		cl1 /= cr1;
   648 		CPPUNIT_CHECK(cs1 == cl1);
   649 	
   650 		float val = 5;
   651 		cr1 /= val;
   652 		CPPUNIT_CHECK(cr1 == cs11);
   653 		cs11 /= cint1;
   654 		CPPUNIT_CHECK(csresult == cs11);	
   655 		}
   656 		// test case for the operator "=" , the 3 templates 
   657 		{
   658 		complex <float> cl1 ( 3.0 , 4.0 );
   659 		complex <float> cr1 ( 2.0 , -1.0 );
   660 		cl1  = cr1;
   661 		CPPUNIT_CHECK(cl1 == cr1);
   662 		complex <float> cl2 ( -2 , 4 );
   663 		float cr2 =5.0;
   664 		cl2 = cr2;
   665 		CPPUNIT_CHECK(cl2 == cr2);
   666 		complex<float> cl3(3.0, 4.0);
   667 		cl2 = cl3;
   668 		CPPUNIT_CHECK(cl2 == cl3);
   669 		}
   670 }
   671 
   672 void CMathTest::complex_longdouble_cov1()
   673 		{
   674 		using namespace std;
   675 		// test case for the abs,arg and sqrt
   676 		{
   677 		complex <long double> c1( polar ( 5.0 ) ); 
   678 		complex <long double> c2 ( 5,0 );
   679 		long double absc1 = abs ( c1 );
   680 		long double argc1 = arg ( c1 );
   681 		CPPUNIT_CHECK( absc1 == 5 );
   682 		CPPUNIT_CHECK( argc1 == 0 );
   683 		long double normc2 = norm ( c2 );
   684 		long double val = 25;
   685 		long double sqrtnormc2 = sqrt ( normc2 );
   686 		CPPUNIT_CHECK(normc2 == val);
   687 		CPPUNIT_CHECK(sqrtnormc2 == 5);
   688 		}
   689 		// test case for the real,imag and conj 
   690 		{
   691 		complex <long double> c1 ( 4.0 , 3.0 );
   692 		long double dr1 = real ( c1 );
   693 	    CPPUNIT_CHECK(dr1 == 4);
   694 	    long double di1 = imag ( c1 );
   695 	    CPPUNIT_CHECK(di1 == 3);
   696 	    complex <long double> c2 = conj ( c1 );
   697 		long double dr2 = real ( c2 );
   698 		CPPUNIT_CHECK(dr2 == 4);
   699 		long double di2 = imag ( c2 );
   700 		CPPUNIT_CHECK(di2 == -3);
   701 		}
   702 		// test case for the operator "=" , the 3 templates 
   703 		{
   704 	    complex <long double> cl1 ( 7,7 );
   705 	    complex <long double> cr1a ( 5,7 );
   706 	    complex <long double> cr1b ( 5,7 );
   707 		CPPUNIT_CHECK(cl1 != cr1a);
   708 		CPPUNIT_CHECK(cr1b == cr1a);
   709 		
   710 		long double cl3a =3;
   711 		long double cl3b =5;
   712 	    complex <long double> cr3a ( 3 , 4 );
   713 	    complex <long double> cr3b ( 5 ,0 );
   714 	    CPPUNIT_CHECK(cl3a != cr3a);
   715 	    CPPUNIT_CHECK(cl3b == cr3b);
   716 	    
   717 	    complex <int> cl2a ( 3 , 4 );
   718 	    complex <int> cl2b ( 5 ,0 );
   719 	    int cr2a =3;
   720 	    CPPUNIT_CHECK(cl2a != cr2a);
   721 		}
   722 	}
   723 void CMathTest::complex_longdouble_cov2()
   724 	{
   725 	using namespace std;
   726 		// test case for the operator "*" , the 3 templates 
   727 		{
   728 	    complex <long double> cl1 ( 7,5 );
   729 		complex <long double> cr1 ( 5,0 );
   730 		complex <long double> cs1 = cl1 * cr1;	
   731 		complex <long double> cl2 ( 7,5 );
   732 		long double cr2 =5;
   733 		complex <long double> cs2 = cl2 * cr2;
   734 		long double cl3 = 5;
   735 		complex <long double> cr3 ( 7,5 );
   736 		complex <long double> cs3 = cl3 * cr3;
   737 		
   738 		CPPUNIT_CHECK(cs1 == cs2);
   739 		CPPUNIT_CHECK(cs3 == cs2);
   740 		}
   741 		// test case for the operator "+" , the 3 templates 
   742 		{
   743 	    complex <long double> cl1 ( 7,0 );
   744 		complex <long double> cr1 ( 5,0 );
   745 		complex <long double> cs1 = cl1 + cr1;	
   746 		complex <long double> cl2 ( 7,0 );
   747 		long double cr2 =5;
   748 		complex <long double> cs2 = cl2 + cr2;
   749 		long double cl3 = 5;
   750 		complex <long double> cr3 ( 7,0 );
   751 		complex <long double> cs3 = cl3 + cr3;
   752 		
   753 		complex <long double> cr4 ( 3.0 , 4.0 );
   754 	    complex <long double> cs4 = + cr4;
   755 		   
   756 	    CPPUNIT_CHECK(cs4 == cr4);
   757 		CPPUNIT_CHECK(cs1 == cs2);
   758 		CPPUNIT_CHECK(cs3 == cs2);
   759 		}
   760 		// test case for the operator "-" , the 3 templates 
   761 		{
   762 	    complex <long double> cl1 (3 , 4);
   763 		complex <long double> cr1 ( 2,3 );
   764 		complex <long double> cs1 = cl1 - cr1;
   765 		complex <long double> cs11 ( 1,1 );
   766 	    CPPUNIT_CHECK(cs1 == cs11);
   767 	    
   768 		complex <long double> cl2 (3 , 4);
   769 		long double cr2 =5;
   770 		complex <long double> cs2 = cl2 - cr2;
   771 		complex <long double> cs22 (-2 , 4);
   772 		CPPUNIT_CHECK(cs2 == cs22);
   773 		
   774 		long double cl3 = 5;
   775 		complex <long double> cr3 (3 , 4);
   776 		complex <long double> cs3 = cl3 - cr3;
   777 		complex <long double> cs33 (2 , -4);
   778 		CPPUNIT_CHECK(cs3 == cs33);
   779 		
   780 		complex <long double> cr4 ( 3 , 4 );
   781 	    complex <long double> cs4 = -cr4;
   782 		complex <long double> cs44 (-3 , -4);
   783 		CPPUNIT_CHECK(cs4 == cs44);
   784 		}
   785 		// test case for the operator "/" , the 3 templates 
   786 		{
   787 	    complex <long double> cl1 (4 , 4);
   788 		complex <long double> cr1 ( 2,2 );
   789 		complex <long double> cs1 = cl1/cr1;
   790 		complex <long double> cs11 ( 2,0 );
   791 	    CPPUNIT_CHECK(cs1 == cs11);
   792 	    
   793 		complex <long double> cl2 (4 , 4);
   794 		long double cr2 =2;
   795 		complex <long double> cs2 = cl2/cr2;
   796 		complex <long double> cs22 (2 , 2);
   797 		CPPUNIT_CHECK(cs2 == cs22);
   798 		
   799 		long double cl3 = 4;
   800 		complex <long double> cr3 (2 , 2);
   801 		complex <long double> cs3 = cl3/cr3;
   802 		complex <long double> cs33 (1 , -1);
   803 		CPPUNIT_CHECK(cs3 == cs33);
   804 		}
   805 	}
   806 void CMathTest::complex_longdouble_cov3()
   807 	{
   808 	using namespace std;
   809 		// test case for the operator "*=" , the 3 templates 
   810 		{
   811 	    complex <long double> cl1 ( 7,0 );
   812 		complex <long double> cr1 ( 5,0 );
   813 		complex <long double> cs1 = cl1 * cr1;	
   814 		complex <long double> cs11 (10,0);	
   815 		complex <int> cint1 ( 2,0 );
   816 		complex <long double> csresult (20,0);	
   817 		cl1 *= cr1;
   818 		CPPUNIT_CHECK(cs1 == cl1);
   819 	
   820 		long double val = 2;
   821 		cr1 *= val;
   822 		CPPUNIT_CHECK(cr1 == cs11);	
   823 		cs11 *= cint1;
   824 		CPPUNIT_CHECK(csresult == cs11);	
   825 		}
   826 		// test case for the operator "+=" , the 3 templates 
   827 		{
   828 	    complex <long double> cl1 ( 7,0 );
   829 		complex <long double> cr1 ( 5,0 );
   830 		complex <long double> cs1 = cl1 + cr1;	
   831 		complex <long double> cs11 (7,0);	
   832 		complex <int> cint1 ( 2,0 );
   833 		complex <long double> csresult (9,0);
   834 		cl1 += cr1;
   835 		CPPUNIT_CHECK(cs1 == cl1);
   836 	
   837 		long double val = 2;
   838 		cr1 += val;
   839 		CPPUNIT_CHECK(cr1 == cs11);	
   840 		cs11 += cint1;
   841 		CPPUNIT_CHECK(csresult == cs11);	
   842 		}
   843 	}
   844 void CMathTest::complex_longdouble_cov4()
   845 	{
   846 	using namespace std;
   847 		// test case for the operator "-=" , the 3 templates 
   848 		{
   849 	    complex <long double> cl1 ( 7,7 );
   850 		complex <long double> cr1 ( 5,0 );
   851 		complex <long double> cs1 = cl1 - cr1;	
   852 		complex <long double> cs11 (3,0);	
   853 		complex <int> cint1 ( 2,0 );
   854 		complex <long double> csresult (1,0);
   855 		cl1 -= cr1;
   856 		CPPUNIT_CHECK(cs1 == cl1);
   857 	
   858 		long double val = 2;
   859 		cr1 -= val;
   860 		CPPUNIT_CHECK(cr1 == cs11);	
   861 		cs11 -= cint1;
   862 		CPPUNIT_CHECK(csresult == cs11);
   863 		}
   864 		// test case for the operator "/=" , the 3 templates 
   865 		{
   866 	    complex <long double> cl1 ( 10,0 );
   867 		complex <long double> cr1 ( 5,0 );
   868 		complex <long double> cs1 = cl1/cr1;	
   869 		complex <long double> cs11 (1,0);
   870 		complex <int> cint1 ( 1,0 );
   871 		complex <long double> csresult (1,0);	
   872 		cl1 /= cr1;
   873 		CPPUNIT_CHECK(cs1 == cl1);
   874 	
   875 		long double val = 5;
   876 		cr1 /= val;
   877 		CPPUNIT_CHECK(cr1 == cs11);
   878 		cs11 /= cint1;
   879 		CPPUNIT_CHECK(csresult == cs11);	
   880 		}
   881 		// test case for the operator "=" , the 3 templates 
   882 		{
   883 		complex <long double> cl1 ( 3.0 , 4.0 );
   884 		complex <long double> cr1 ( 2.0 , -1.0 );
   885 		cl1  = cr1;
   886 		CPPUNIT_CHECK(cl1 == cr1);
   887 		complex <long double> cl2 ( -2 , 4 );
   888 		long double cr2 =5.0;
   889 		cl2 = cr2;
   890 		CPPUNIT_CHECK(cl2 == cr2);
   891 		complex<long double> cl3(3.0, 4.0);
   892 		cl2 = cl3;
   893 		CPPUNIT_CHECK(cl2 == cl3);
   894 		}
   895 }
   896 void CMathTest::complex_trigonometric_cov()
   897 	{
   898 	using namespace std;
   899 	
   900 	complex <double> c1 ( 5,0 );
   901 	complex <float> c2 ( 5,0 );
   902 	complex <long double> c3 ( 5,0 );
   903 	
   904 	complex <double> cdresult;
   905 	complex <float> cfresult;
   906 	complex <long double> cldresult;
   907 	
   908 	cdresult = cos ( c1 );	
   909 	cfresult = cos ( c2 );	
   910 	cldresult = cos ( c3 );	
   911 	
   912 	cdresult = cosh ( c1 );	
   913 	cfresult = cosh ( c2 );	
   914 	cldresult = cosh ( c3 );	
   915 	
   916 	cdresult = sin ( c1 );	
   917 	cfresult = sin ( c2 );	
   918 	cldresult = sin ( c3 );	
   919 	
   920 	cdresult = sinh ( c1 );	
   921 	cfresult = sinh ( c2 );	
   922 	cldresult = sinh ( c3 );	
   923 	
   924 	cdresult = tan ( c1 );	
   925 	cfresult = tan ( c2 );	
   926 	cldresult = tan ( c3 );
   927 	
   928 	cdresult = tanh ( c1 );	
   929 	cfresult = tanh ( c2 );	
   930 	cldresult = tanh ( c3 );
   931 	}
   932 
   933 void CMathTest::complex_cmath_cov()
   934 	{
   935 	using namespace std;
   936 		{
   937 		complex <double> c1 ( 5,5 );
   938 		complex <float> c2 ( 5,5 );
   939 		complex <long double> c3 ( 5,5 );
   940 		
   941 		complex <double> cdresult;
   942 		complex <float> cfresult;
   943 		complex <long double> cldresult;
   944 		
   945 		CPPUNIT_CHECK( are_equals(abs(c1), (double)(sqrt(2.0)*5) ));		
   946 		CPPUNIT_CHECK( are_equals(abs(c2), (float)(sqrt(2.0)*5) ));		
   947 		CPPUNIT_CHECK( are_equals(abs(c3), (long double)(sqrt(2.0)*5) ));		
   948 		
   949 		double val1 = arg(c1);
   950 		float val2 = arg(c2);
   951 		long double val3 = arg(c3);
   952 		
   953 		cdresult = exp(c1);
   954 		cfresult = exp(c2);
   955 		cldresult = exp(c3);
   956 		
   957 		cdresult = log(c1);
   958 		cfresult = log(c2);
   959 		cldresult = log(c3);
   960 		
   961 		cdresult = log10(c1);
   962 		cfresult = log10(c2);
   963 		cldresult = log10(c3);
   964 		}
   965 		{
   966 		complex <double> c1 ( 5,5 );
   967 		complex <float> c2 ( 5,5 );
   968 		complex <long double> c3 ( 5,5 );
   969 		
   970 		complex <double> cpower1 ( 5,5 );
   971 		complex <float> cpower2 ( 5,5 );
   972 		complex <long double> cpower3 ( 5,5 );
   973 		
   974 		complex <double> cdresult;
   975 		complex <float> cfresult;
   976 		complex <long double> cldresult;
   977 		
   978 		double dval = 2;
   979 		float fval = 2;
   980 		long double ldval = 2;
   981 		
   982 		cdresult = pow(c1 , cpower1);
   983 		cdresult = pow(c1 , dval);
   984 		cdresult = pow(c1 , (int)2);
   985 		cdresult = pow(dval , cpower1);
   986 		
   987 		cfresult = pow(c2 , cpower2);
   988 		cfresult = pow(c2 , fval);
   989 		cfresult = pow(c2 , (int)2);
   990 		cfresult = pow(fval , cpower2);
   991 		
   992 		cldresult = pow(c3 , cpower3);
   993 		cldresult = pow(c3 , ldval);
   994 		cldresult = pow(c3 , (int)2);
   995 		cldresult = pow(ldval , cpower3);
   996 		}
   997 		{
   998 		complex <double> c1 ( 5,5 );
   999 		complex <float> c2 ( 5,5 );
  1000 		complex <long double> c3 ( 5,5 );
  1001 		
  1002 		complex <double> cdresult;
  1003 		complex <float> cfresult;
  1004 		complex <long double> cldresult;
  1005 		
  1006 		cdresult = sqrt(c1);
  1007 		cfresult = sqrt(c2);
  1008 		cldresult = sqrt(c3);
  1009 		}
  1010 		{
  1011 		double pi = 3.14159265359;
  1012 		complex <double> c1( polar ( (long double)5.0 , (long double)pi / 6 ) ); 
  1013 		complex <double> c2 ( polar ( (float)5.0 , (float)pi / 6 ) );
  1014 		double absc1 = abs ( c1 );
  1015 		double argc1 = arg ( c1 );
  1016 		CPPUNIT_CHECK( absc1 == 5 );
  1017 		float normc2 = norm ( c2 );
  1018 		float sqrtnormc2 = sqrt ( normc2 );
  1019 		CPPUNIT_CHECK(sqrtnormc2 == 5);
  1020 		}
  1021 	}
  1022 
  1023 void CMathTest::complex_templates_cov1()
  1024 	{
  1025 	using namespace std;
  1026 		{
  1027 		complex <int> c1( 5,0 ); 
  1028 		complex <int> c2 ( polar ( 3 , 0) );
  1029 		complex <int> c3 ( 4 , 3 );
  1030 	    
  1031 		int dr1 = real ( c3 );
  1032 		CPPUNIT_CHECK(dr1 == 4);
  1033 	    int di1 = imag ( c3 );
  1034 		CPPUNIT_CHECK(di1 == 3);
  1035 		
  1036 		int normc2 = norm ( c2 );
  1037 		int sqrtnormc2 = sqrt ( (double)normc2 );
  1038 		CPPUNIT_CHECK(normc2 == 9);
  1039 		CPPUNIT_CHECK(sqrtnormc2 == 3);
  1040 		
  1041 		int absc1 = abs ( c1 );
  1042 		int argc1 = arg ( c1 );
  1043 		CPPUNIT_CHECK( absc1 == 5 );
  1044 		CPPUNIT_CHECK( argc1 == 0 );
  1045 		}
  1046 		{/*
  1047     	complex <int> cl1 (4 , 4);
  1048 		complex <int> cr1 ( 2,2 );
  1049 		complex <int> cs1 = cl1/cr1;
  1050 		complex <int> cs11 ( 2,0 );
  1051     	CPPUNIT_CHECK(cs1 == cs11);
  1052     
  1053 		complex <int> cl2 (4 , 4);
  1054 		int cr2 =2;
  1055 		complex <int> cs2 = cl2/cr2;
  1056 		complex <int> cs22 (2 , 2);
  1057 		CPPUNIT_CHECK(cs2 == cs22);
  1058 	
  1059 		int cl3 = 4;
  1060 		complex <int> cr3 (2 , 2);
  1061 		complex <int> cs3 = cl3/cr3;
  1062 		complex <int> cs33 (1 , -1);
  1063 		CPPUNIT_CHECK(cs3 == cs33);*/
  1064 		}
  1065 		{
  1066 	    complex <int> cl1 ( 3,0 );
  1067 		complex <int> cr1 ( 5,0 );
  1068 		complex <int> cs1 = cl1 * cr1;	
  1069 		complex <int> cs11 (10,0);	
  1070 		complex <int> cint1 ( 2,0 );
  1071 		complex <float> cint11 ( 2,0 );
  1072 		complex <int> csresult (4,0);	
  1073 		cl1 *= cr1;
  1074 		CPPUNIT_CHECK(cs1 == cl1);
  1075 
  1076 		int val = 2;
  1077 		cr1 *= val;
  1078 		CPPUNIT_CHECK(cr1 == cs11);	
  1079 		cint1 *= cint11;
  1080 		CPPUNIT_CHECK(csresult == cint1);	
  1081 		}
  1082 	}
  1083 void CMathTest::complex_templates_cov2()
  1084 	{
  1085 	using namespace std;
  1086 		{
  1087 	    complex <int> cl1 ( 3,0 );
  1088 		complex <int> cr1 ( 5,0 );
  1089 		complex <int> cs1 = cl1 + cr1;	
  1090 		complex <int> cs11 (7,0);	
  1091 		complex <int> cint1 ( 2,0 );
  1092 		complex <float> cint11 ( 2,0 );
  1093 		complex <int> csresult (4,0);	
  1094 		cl1 += cr1;
  1095 		CPPUNIT_CHECK(cs1 == cl1);
  1096 
  1097 		int val = 2;
  1098 		cr1 += val;
  1099 		CPPUNIT_CHECK(cr1 == cs11);	
  1100 		cint1 += cint11;
  1101 		CPPUNIT_CHECK(csresult == cint1);	
  1102 		}
  1103 		{
  1104 	    complex <int> cl1 ( 3,0 );
  1105 		complex <int> cr1 ( 5,0 );
  1106 		complex <int> cs1 = cl1 - cr1;	
  1107 		complex <int> cs11 (3,0);	
  1108 		complex <int> cint1 ( 2,0 );
  1109 		complex <float> cint11 ( 2,0 );
  1110 		complex <int> csresult (0,0);	
  1111 		cl1 -= cr1;
  1112 		CPPUNIT_CHECK(cs1 == cl1);
  1113 
  1114 		int val = 2;
  1115 		cr1 -= val;
  1116 		CPPUNIT_CHECK(cr1 == cs11);	
  1117 		cint1 -= cint11;
  1118 		CPPUNIT_CHECK(csresult == cint1);	
  1119 		}
  1120 		{/*
  1121     	complex <int> cl1 ( 10,0 );
  1122 		complex <int> cr1 ( 5,0 );
  1123 		complex <int> cs1 = cl1/cr1;	
  1124 		complex <int> cs11 (1,0);
  1125 		complex <int> cint1 ( 5,0 );
  1126 		complex <double> cint11 ( 5,0 );
  1127 		complex <int> csresult (1,0);	
  1128 		cl1 /= cr1;
  1129 		CPPUNIT_CHECK(cs1 == cl1);
  1130 
  1131 		int val = 5;
  1132 		cr1 /= val;
  1133 		CPPUNIT_CHECK(cr1 == cs11);
  1134 		cint1 /= cint11;
  1135 		CPPUNIT_CHECK(csresult == cint1);	*/
  1136 		}
  1137 		{
  1138 		complex <int> cl1 ( 3 , 4 );
  1139 		complex <int> cr1 ( 2 , -1 );
  1140 		cl1  = cr1;
  1141 		CPPUNIT_CHECK(cl1 == cr1);
  1142 		complex <int> cl2 ( -2 , 4 );
  1143 		int cr2 =5;
  1144 		cl2 = cr2;
  1145 		CPPUNIT_CHECK(cl2 == cr2);
  1146 		complex<int> cl3(3, 4);
  1147 		cl2 = cl3;
  1148 		CPPUNIT_CHECK(cl2 == cl3);
  1149 		complex<double> cld(5, 0);
  1150 		cl2 = cld;
  1151 		}
  1152 	}
  1153 void CMathTest::complex_constructors_cov1()
  1154 	{
  1155 	using namespace std;
  1156 		{
  1157 		complex<int> c1;
  1158 		int dr1 = real ( c1 );
  1159 	    CPPUNIT_CHECK(dr1 == 0);
  1160 	    int di1 = imag ( c1 );
  1161 	    CPPUNIT_CHECK(di1 == 0);
  1162 		}
  1163 		{
  1164 		complex<int> c1(3,4) ;
  1165 		complex<int> c2(c1);
  1166 		CPPUNIT_CHECK(c1 == c2);
  1167 		}
  1168 		{
  1169 		complex<double> c1(3.0,4.0) ;
  1170 		complex<int> c2(c1);
  1171 		double dr1 = real ( c1 );
  1172 	    CPPUNIT_CHECK(dr1 == 3);
  1173 	    double di1 = imag ( c1 );
  1174 	    CPPUNIT_CHECK(di1 == 4);
  1175 	    
  1176 	    int dr2 = real ( c2 );
  1177 	    CPPUNIT_CHECK(dr1 == 3);
  1178 	    int di2 = imag ( c2 );
  1179 	    CPPUNIT_CHECK(di1 == 4);
  1180 		}
  1181 		{
  1182 		complex<int> c1(5);
  1183 		int dr1 = real ( c1 );
  1184 	    CPPUNIT_CHECK(dr1 == 5);
  1185 	    int di1 = imag ( c1 );
  1186 	    CPPUNIT_CHECK(di1 == 0);
  1187 		}
  1188 	}
  1189 void CMathTest::complex_constructors_cov2()
  1190 	{
  1191 	using namespace std;
  1192 		{
  1193 		complex<float> c1(3.0,4.0) ;
  1194 		complex<long double> c2(4.0,5.0) ;
  1195 		complex<double> c3(c1);
  1196 		complex<double> c4(c2);
  1197 		
  1198 		float dr1 = real ( c1 );
  1199 	    CPPUNIT_CHECK(dr1 == 3);
  1200 	    float di1 = imag ( c1 );
  1201 	    CPPUNIT_CHECK(di1 == 4);
  1202 	    
  1203 	    double dr3 = real ( c3 );
  1204 	    CPPUNIT_CHECK(dr3 == 3);
  1205 	    double di3 = imag ( c3 );
  1206 	    CPPUNIT_CHECK(di3 == 4);
  1207 	    
  1208 	    double dr4 = real ( c4 );
  1209 	    CPPUNIT_CHECK(dr4 == 4);
  1210 	    double di4 = imag ( c4 );
  1211 	    CPPUNIT_CHECK(di4 == 5);
  1212 		}
  1213 		{
  1214 		complex<long double> c1(3.0,4.0) ;
  1215 		complex<float> c2(c1);
  1216 		long double dr1 = real ( c1 );
  1217 	    CPPUNIT_CHECK(dr1 == 3);
  1218 	    long double di1 = imag ( c1 );
  1219 	    CPPUNIT_CHECK(di1 == 4);
  1220 	    
  1221 	    float dr2 = real ( c2 );
  1222 	    CPPUNIT_CHECK(dr1 == 3);
  1223 	    float di2 = imag ( c2 );
  1224 	    CPPUNIT_CHECK(di1 == 4);
  1225 		}
  1226 		{
  1227 		complex<float> c1(3.0,4.0) ;
  1228 		complex<long double> c2(c1);
  1229 		float dr1 = real ( c1 );
  1230 	    CPPUNIT_CHECK(dr1 == 3);
  1231 	    float di1 = imag ( c1 );
  1232 	    CPPUNIT_CHECK(di1 == 4);
  1233 	    
  1234 	    long double dr2 = real ( c2 );
  1235 	    CPPUNIT_CHECK(dr1 == 3);
  1236 	    long double di2 = imag ( c2 );
  1237 	    CPPUNIT_CHECK(di1 == 4);
  1238 		}
  1239 	}