[gcalctool/gnome-2-26] Backport new unittests from master



commit a591509ae256a43cd674f21979de60a362f56ba2
Author: Robert Ancell <robert ancell gmail com>
Date:   Sun May 17 14:33:50 2009 +1000

    Backport new unittests from master
---
 gcalctool/unittest.c |   37 +++++++++++++++++++++++++++++++------
 1 files changed, 31 insertions(+), 6 deletions(-)

diff --git a/gcalctool/unittest.c b/gcalctool/unittest.c
index 16b84e8..acfa8f2 100644
--- a/gcalctool/unittest.c
+++ b/gcalctool/unittest.c
@@ -54,6 +54,10 @@ test(char *expression, char *expected, int expected_error)
 void
 test_parser()
 {
+    v->base = DEC;
+    v->ttype = DEG;
+    v->accuracy = 9;
+
     test("0", "0", 0);
     test("1", "1", 0);
     test("+1", "1", 0);
@@ -87,29 +91,50 @@ test_parser()
     //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("2/2", "1", 0);
     test("1203/1", "1203", 0);
     test("-0/32352.689", "0", 0);
     test("1/4", "0.25", 0);
     test("(-3)/(-6)", "0.5", 0);
+    test("1/3", "0.333333333", 0);
+    test("2/3", "0.666666667", 0);    
 
     test("1+2*3", "7", 0);
+    test("1+(2*3)", "7", 0);    
     test("(1+2)*3", "9", 0);
     
     test("100%", "1", 0);
     test("1%", "0.01", 0);
+
+    test("0!", "1", 0);
+    test("1!", "1", 0);
+    test("5!", "120", 0);
+    test("69!", "171122452428141311372468338881272839092270544893520369393648040923257279754140647424000000000000000", 0);
+    test("0.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("0!", "1", 0);
-    test("1!", "1", 0);
-    test("5!", "120", 0);
-    //FIXME: Need to update do_factorial() test("0.1!", "", 0);
-    //FIXME: Need to update do_factorial() test("-1!", "", 0);
-    
+    test("2^100", "1267650600228229401496703205376", 0);
+    test("4^3^2", "262144", 0);
+    test("4^(3^2)", "262144", 0);    
+    test("(4^3)^2", "4096", 0);
     test("Sqrt(4)", "2", 0);
     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("0 Mod 7", "0", 0);
     test("6 Mod 7", "6", 0);



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