[grisbi-cvs] grisbi/src gsb_real_cunit.c,1.6,1.7

Mickaƫl Remars mykeul at users.sourceforge.net
Wed May 20 21:32:03 CEST 2009


Update of /cvsroot/grisbi/grisbi/src
In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv19173/src

Modified Files:
	gsb_real_cunit.c 
Log Message:
Added a new unit-test on gsb_real_add(), most of them fail with current version of the function

Index: gsb_real_cunit.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/gsb_real_cunit.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- gsb_real_cunit.c	20 May 2009 19:03:07 -0000	1.6
+++ gsb_real_cunit.c	20 May 2009 19:32:01 -0000	1.7
@@ -233,6 +233,55 @@
     CU_ASSERT_EQUAL(0, r.exponent);
 }
 
+void gsb_real_cunit__gsb_real_sub()
+{
+    gsb_real a = { -1, 0 };
+    gsb_real b = { 31415, 4 };
+    gsb_real r = gsb_real_sub ( a, b );
+    CU_ASSERT_EQUAL ( -41415, r.mantissa );
+    CU_ASSERT_EQUAL ( 4, r.exponent );
+    
+    a.mantissa = 0x7FFFFFFE;
+    a.exponent = 0;
+    b.mantissa = -1;
+    b.exponent = 0;
+    r = gsb_real_sub ( a, b );
+    CU_ASSERT_EQUAL ( 0x7FFFFFFF, r.mantissa );
+    CU_ASSERT_EQUAL ( 0, r.exponent );
+    
+    a.mantissa = 0x7FFFFFFF;
+    a.exponent = 0;
+    b.mantissa = -2;
+    b.exponent = 0;
+    r = gsb_real_sub ( a, b );
+    CU_ASSERT_EQUAL ( 0x80000000, r.mantissa );
+    CU_ASSERT_EQUAL ( 0, r.exponent );
+    
+    a.mantissa = 0x80000001;
+    a.exponent = 0;
+    b.mantissa = 2;
+    b.exponent = 0;
+    r = gsb_real_sub ( a, b );
+    CU_ASSERT_EQUAL ( 0x80000000, r.mantissa );
+    CU_ASSERT_EQUAL  (0, r.exponent );
+
+    a.mantissa = 0x80000000;
+    a.exponent = 0;
+    b.mantissa = 100;
+    b.exponent = 0;
+    r = gsb_real_sub ( a, b );
+    CU_ASSERT_EQUAL ( 0x80000000, r.mantissa );
+    CU_ASSERT_EQUAL ( 0, r.exponent );
+
+    a.mantissa = 100;
+    a.exponent = 0;
+    b.mantissa = 0x80000000;
+    b.exponent = 0;
+    r = gsb_real_sub ( a, b );
+    CU_ASSERT_EQUAL ( 0x80000000, r.mantissa );
+    CU_ASSERT_EQUAL ( 0, r.exponent );
+}
+
 CU_pSuite gsb_real_cunit_create_suite ( void )
 {
     CU_pSuite pSuite = CU_add_suite("gsb_real",
@@ -244,6 +293,7 @@
     if((NULL == CU_add_test(pSuite, "of gsb_real_get_from_string()",   gsb_real_cunit__gsb_real_get_from_string))
     || (NULL == CU_add_test(pSuite, "of gsb_real_raw_format_string()", gsb_real_cunit__gsb_real_raw_format_string))
     || (NULL == CU_add_test(pSuite, "of gsb_real_add()",               gsb_real_cunit__gsb_real_add))
+    || (NULL == CU_add_test(pSuite, "of gsb_real_sub()",               gsb_real_cunit__gsb_real_sub))
        )
         return NULL;
 



More information about the cvs mailing list