add some coverage tests
authorLaurent Mazet <laurent.mazet@thalesgroup.com>
Fri, 27 Jan 2023 08:51:47 +0000 (09:51 +0100)
committerLaurent Mazet <laurent.mazet@thalesgroup.com>
Fri, 27 Jan 2023 08:51:47 +0000 (09:51 +0100)
calc.c
parser.c

diff --git a/calc.c b/calc.c
index 771f7f09657d513877c3846d4368edb2ffe086b9..75189f5ec32404e5eb9ac705fc2f9cd30d6cc881 100644 (file)
--- a/calc.c
+++ b/calc.c
@@ -333,6 +333,7 @@ int main (int argc, char *argv[])
 // test: echo -e '{sto (1, 1 + 1), rcl (1) * 3}' | calc.exe | grep -q '=> 6'
 // 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)}' | calc.exe | grep -c error | xargs test 6 =
 // test: echo -e '1 }\n1 )\n1 , 2\n ' | calc.exe | grep -c error | xargs test 3 =
+// test: echo -e 'print (1)' | calc.exe -v 3 | grep -q Print
 // test: echo -e 'si\t\t (pi / 2)' | calc.exe | grep -q '=> 1'
 
 // Gauss sequence
index 9b6d5bb2f3f101a2d49c664c404f85fa789b70f4..c70a15cfde5b65282851d52587cd3920971c317f 100644 (file)
--- a/parser.c
+++ b/parser.c
@@ -829,38 +829,30 @@ char **generate_completion_list ()
                 list[i][j] = '\0';
             }
         }
-        if (list[l] == NULL) {
-            VERBOSE (ERROR, fprintf (stderr, "can't allocate memory\n"));
-            exit (1);
+        if (list[l] != NULL) {
+            l++;
         }
-        l++;
     }
 
     for (i = 0; i < NB_FUNCTIONS; i++) {
         list[l] = strdup ((functions + i)->keyword);
-        if (list[l] == NULL) {
-            VERBOSE (ERROR, fprintf (stderr, "can't allocate memory\n"));
-            exit (1);
+        if (list[l] != NULL) {
+            l++;
         }
-        l++;
     }
 
     for (i = 0; i < NB_CONSTANTS; i++) {
         list[l] = strdup ((constants + i)->keyword);
-        if (list[l] == NULL) {
-            VERBOSE (ERROR, fprintf (stderr, "can't allocate memory\n"));
-            exit (1);
+        if (list[l] != NULL) {
+            l++;
         }
-        l++;
     }
 
     for (i = 0; i < NB_SYMBOLS; i++) {
         list[l] = strdup (symbols[i]);
-        if (list[l] == NULL) {
-            VERBOSE (ERROR, fprintf (stderr, "can't allocate memory\n"));
-            exit (1);
+        if (list[l] != NULL) {
+            l++;
         }
-        l++;
     }
 
     return (list);