From d8f4df0f1980ede6d35d24158ea484e16791c8d1 Mon Sep 17 00:00:00 2001 From: Laurent Mazet Date: Fri, 27 Jan 2023 09:51:47 +0100 Subject: [PATCH] add some coverage tests --- calc.c | 1 + parser.c | 24 ++++++++---------------- 2 files changed, 9 insertions(+), 16 deletions(-) diff --git a/calc.c b/calc.c index 771f7f0..75189f5 100644 --- 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 diff --git a/parser.c b/parser.c index 9b6d5bb..c70a15c 100644 --- 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); -- 2.30.2