[gcalctool] Fix new negative sign with unittests



commit ecb40d6426eaf0e43ec385b26509d7260f36ad45
Author: Robert Ancell <robert ancell gmail com>
Date:   Tue Jun 16 15:33:15 2009 +1000

    Fix new negative sign with unittests

 src/mp-convert.c |    2 +-
 src/unittest.c   |   90 +++++++++++++++++++++++++++---------------------------
 2 files changed, 46 insertions(+), 46 deletions(-)
---
diff --git a/src/mp-convert.c b/src/mp-convert.c
index 2a51b3e..c7d1a3f 100644
--- a/src/mp-convert.c
+++ b/src/mp-convert.c
@@ -580,7 +580,7 @@ mp_cast_to_string(const MPNumber *MPnumber, int base, int accuracy, int trim_zer
     *optr = '\0';
     
     /* Remove negative sign if the number was rounded down to zero */
-    if (strcmp(buffer, "-0") == 0) {
+    if (strcmp(buffer, "â??0") == 0) {
         buffer[0] = '0';
         buffer[1] = '\0';
     }
diff --git a/src/unittest.c b/src/unittest.c
index 048e663..0645bd3 100644
--- a/src/unittest.c
+++ b/src/unittest.c
@@ -118,31 +118,31 @@ test_parser()
     test("4+1", "5", 0);
     test("40000+0.001", "40000.001", 0);
     test("0.001+40000", "40000.001", 0);
-    test("2â??3", "-1", 0);
-    test("2-3", "-1", 0);
-    test("3-2", "1", 0);
-    test("1-0.9-0.1", "0", 0);   
-    test("40000-0.001", "39999.999", 0);
-    test("0.001-40000", "-39999.999", 0);
-    test("40000000-40000000", "0", 0);
+    test("2-3", "â??1", 0);
+    test("2â??3", "â??1", 0);
+    test("3â??2", "1", 0);
+    test("1â??0.9â??0.1", "0", 0);   
+    test("40000â??0.001", "39999.999", 0);
+    test("0.001â??40000", "â??39999.999", 0);
+    test("40000000â??40000000", "0", 0);
     test("2Ã?3", "6", 0);
     test("2*3", "6", 0);
-    test("-2*3", "-6", 0);
-    test("2*-3", "-6", 0);
-    test("-2*-3", "6", 0);
+    test("â??2*3", "â??6", 0);
+    test("2*â??3", "â??6", 0);
+    test("â??2*â??3", "6", 0);
     //FIXME: Need to update mperr() test("1/2", "0.5", 0);
     //FIXME: Need to update mperr() test("1/0", "", 0);
     //FIXME: Need to update mperr() test("0/0", "", 0);
     test("6÷3", "2", 0);
     test("6/3", "2", 0);
-    test("-6/3", "-2", 0);
-    test("6/-3", "-2", 0);
-    test("-6/-3", "2", 0);
+    test("â??6/3", "â??2", 0);
+    test("6/â??3", "â??2", 0);
+    test("â??6/â??3", "2", 0);
     test("2/2", "1", 0);
     test("1203/1", "1203", 0);
-    test("-0/32352.689", "0", 0);
+    test("â??0/32352.689", "0", 0);
     test("1/4", "0.25", 0);
-    test("(-3)/(-6)", "0.5", 0);
+    test("(â??3)/(â??6)", "0.5", 0);
     test("1/3", "0.333333333", 0);
     test("2/3", "0.666666667", 0);    
 
@@ -153,7 +153,7 @@ test_parser()
     test("100%", "1", 0);
     test("1%", "0.01", 0);
     test("100+1%", "101", 0);
-    test("100-1%", "99", 0);
+    test("100â??1%", "99", 0);
     test("100*1%", "1", 0);
     test("100/1%", "10000", 0);    
 
@@ -162,16 +162,16 @@ test_parser()
     test("5!", "120", 0);
     test("69!", "171122452428141311372468338881272839092270544893520369393648040923257279754140647424000000000000000", 0);
     test("0.1!", "", -20001);
-    test("-1!", "-1", 0);
-    test("(-1)!", "", -20001);    
+    test("â??1!", "â??1", 0);
+    test("(â??1)!", "", -20001);    
 
     test("2^0", "1", 0);
     test("2^1", "2", 0);
     test("2^2", "4", 0);
-    test("2^-1", "0.5", 0);
-    test("2^(-1)", "0.5", 0);    
-    test("-10^2", "-100", 0);
-    test("(-10)^2", "100", 0);
+    test("2^â??1", "0.5", 0);
+    test("2^(â??1)", "0.5", 0);    
+    test("â??10^2", "â??100", 0);
+    test("(â??10)^2", "100", 0);
     test("2^100", "1267650600228229401496703205376", 0);
     test("4^3^2", "262144", 0);
     test("4^(3^2)", "262144", 0);    
@@ -179,7 +179,7 @@ test_parser()
     test("2²", "4", 0);
     test("2³", "8", 0);
     test("â??4", "2", 0);
-    test("â??4-2", "0", 0);    
+    test("â??4â??2", "0", 0);    
     test("â??8", "2", 0);
     test("â??16", "2", 0);
     test("â??(2+2)", "2", 0);
@@ -189,68 +189,68 @@ test_parser()
     test("Sqrt(2)", "1.414213562", 0);
     test("4^(1/2)", "2", 0);
     test("2^(1/2)", "1.414213562", 0);
-    test("(-4)^(1/2)", "", -20001);
-    test("(-8)^(1/3)", "-2", 0);
+    test("(â??4)^(1/2)", "", -20001);
+    test("(â??8)^(1/3)", "â??2", 0);
     
     test("0 Mod 7", "0", 0);
     test("6 Mod 7", "6", 0);
     test("7 Mod 7", "0", 0);
     test("8 Mod 7", "1", 0);
-    test("-1 Mod 7", "6", 0);
+    test("â??1 Mod 7", "6", 0);
     
     test("Int(3.2)", "3", 0);
     test("Frac(3.2)", "0.2", 0);
-    test("Int(-3.2)", "-3", 0);
-    test("Frac(-3.2)", "-0.2", 0);
+    test("Int(â??3.2)", "â??3", 0);
+    test("Frac(â??3.2)", "â??0.2", 0);
 
     test("|1|", "1", 0);
-    test("|-1|", "1", 0);
-    test("|3-5|", "2", 0);    
+    test("|â??1|", "1", 0);
+    test("|3â??5|", "2", 0);    
     test("Abs(1)", "1", 0);
-    test("Abs(-1)", "1", 0);
+    test("Abs(â??1)", "1", 0);
     
     test("Ln(e^1)", "1", 0);
 
     v->ttype = MP_DEGREES;
     test("Sin(0)", "0", 0);
-    test("Sin(45) - 1/Sqrt(2)", "0", 0);
-    test("Sin(20) + Sin(-20)", "0", 0);
+    test("Sin(45) â?? 1/Sqrt(2)", "0", 0);
+    test("Sin(20) + Sin(â??20)", "0", 0);
     test("Sin(90)", "1", 0);
     test("Sin(180)", "0", 0);
    
     test("Cos(0)", "1", 0);
-    test("Cos(45) - 1/Sqrt(2)", "0", 0);
-    test("Cos(20) - Cos(-20)", "0", 0);
+    test("Cos(45) â?? 1/Sqrt(2)", "0", 0);
+    test("Cos(20) â?? Cos(â??20)", "0", 0);
     test("Cos(90)", "0", 0);
-    test("Cos(180)", "-1", 0);
+    test("Cos(180)", "â??1", 0);
 
     test("Tan(0)", "0", 0);
-    test("Tan(10) - Sin(10)/Cos(10)", "0", 0);
+    test("Tan(10) â?? Sin(10)/Cos(10)", "0", 0);
     test("Tan(90)", "", -20001);
 
     test("Acos(0)", "90", 0);
     test("Acos(1)", "0", 0);
-    test("Acos(-1)", "180", 0);
+    test("Acos(â??1)", "180", 0);
     test("Acos(1/Sqrt(2))", "45", 0);
 
     test("Asin(0)", "0", 0);
     test("Asin(1)", "90", 0);
-    test("Asin(-1)", "-90", 0);
+    test("Asin(â??1)", "â??90", 0);
     test("Asin(1/Sqrt(2))", "45", 0);
 
     test("Cosh(0)", "1", 0);
-    test("Cosh(10) - (e^(10)+e^(-10))/2", "0", 0);
+    test("Cosh(10) â?? (e^(10)+e^(â??10))/2", "0", 0);
 
     test("Sinh(0)", "0", 0);
-    test("Sinh(10) - (e^(10)-e^(-10))/2", "0", 0);
-    test("Sinh(-10) +Sinh(10)", "0", 0);
+    test("Sinh(10) â?? (e^(10)â??e^(â??10))/2", "0", 0);
+    test("Sinh(â??10) +Sinh(10)", "0", 0);
 
-    test("Cosh(-5)^2 - Sinh(-5)^2", "1", 0);
+    test("Cosh(â??5)^2 â?? Sinh(â??5)^2", "1", 0);
     test("Tanh(0)", "0", 0);
-    test("Tanh(10) - Sinh(10)/Cosh(10)", "0", 0);
+    test("Tanh(10) â?? Sinh(10)/Cosh(10)", "0", 0);
 
     test("Atanh(0)", "0", 0);
-    test("Atanh(1/10) - 1/2*Ln(11/9)", "0", 0);
+    test("Atanh(1/10) â?? 1/2*Ln(11/9)", "0", 0);
 
     v->ttype = MP_DEGREES;
     test("Sin(90)", "1", 0);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]