add some coverage tests
authorMazet Laurent <mazet@softndesign.org>
Wed, 25 Jan 2023 22:42:40 +0000 (23:42 +0100)
committerMazet Laurent <mazet@softndesign.org>
Wed, 25 Jan 2023 22:42:40 +0000 (23:42 +0100)
calc.c
parser.c

diff --git a/calc.c b/calc.c
index b964ad6e409b7ce74ed6fe276b716c6ebb19d830..60cdad3596dc84c259b0ae12aab3b85d57d96838 100644 (file)
--- a/calc.c
+++ b/calc.c
@@ -244,7 +244,7 @@ int main (int argc, char *argv[])
 // test: echo -e '1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1\n1 + 1' | calc.exe | grep -q 64
 // test: echo -e '1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1\n1 + 1' | calc.exe | grep -q 2
 // test: echo -e '-cos (1)\n1 + 1\n1 - 1\n1 * 1\n1 / 1\n3%2\n2^2\nsqrt (2)\ncos (0)\nsin (0)\natan (0)\nlog (1)\nexp (1)\nans\ne\npi\nsto (1)\nrcl (2)\ndisp\nhelp\nquit' | calc.exe -v 3 | grep -q bye
-// test: echo -e '1 +\n1 -\n1 * 1\n1 /\n3%\n2^\nsqrt ()\ncos ()\nsin ()\natan ()\nlog ()\nexp ()\n1 + (' | calc.exe | grep -c error | xargs test 12 =
+// test: echo -e '1 +\n1 -\n1 * 1\n1 /\n3%\n2^\nsqrt ()\ncos ()\nsin ()\natan ()\nlog ()\nexp ()\n1 + (\n1+2(\n1+2cos\n1+2pi' | calc.exe | grep -c error | xargs test 15 =
 // test: echo -e '1 + 1\nans' | calc.exe -p 3 | grep -c 2 | xargs test 2 =
 // test: echo -e 'sin (pi / 2)' | calc.exe -p 4 | grep -q 1
 // test: echo -e 'e ^ 2' | calc.exe | grep -q '7\.38906'
@@ -296,6 +296,6 @@ int main (int argc, char *argv[])
 // test: echo -e 'whl (0, 1)' | calc.exe -v 3 | grep -q While
 // test: echo -e '{sto (1, 1 + 1), rcl (1) * 3}' | calc.exe -v 3 | grep -q 'Program'
 // test: echo -e '{sto (1, 1 + 1), rcl (1) * 3}' | calc.exe | grep -q '=> 6'
-// test: echo -e '{\n{}\n{sto (1, 1 + 1),\npow(2, {sto (1, 1 + 2), 2}, {rcl(2)})\n2 {sto (1, 1 + 1)}' 2>&1 | calc.exe | grep -c error | xargs test 5 =
+// test: echo -e '{\n{}\n{1, 2\n{sto (1, 1 + 1),\npow(2, {sto (1, 1 + 2), 2}, {rcl(2)})\n2 {sto (1, 1 + 1)}' 2>&1 | calc.exe | grep -c error | xargs test 6 =
 
 /* vim: set ts=4 sw=4 et: */
index ebb56a9c678a35aa2fae9404394598a4375406a4..f8a7367a8f5a1812a51257b3551c1e2c7624c4f9 100644 (file)
--- a/parser.c
+++ b/parser.c
@@ -225,7 +225,7 @@ element_t *parser (char *str, char **next, int prio)
                     delelement (new);
                     new = ERROR_OP;
                 }
-                if ((new == NULL) || (new == ERROR_OP)) {
+                if (new == ERROR_OP) {
                     delelement (root);
                     return ERROR_OP;
                 }