Skip to content

Commit

Permalink
Better tests for Calc.
Browse files Browse the repository at this point in the history
  • Loading branch information
rsm-lisper committed May 22, 2024
1 parent 0636a1b commit 8158578
Show file tree
Hide file tree
Showing 84 changed files with 78 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

# define BUFSIZE 128

char buf[BUFSIZE]; /* buffer fir ungetch */
char buf[BUFSIZE]; /* buffer for ungetch */
int bufp = 0; /* next free position in buf */


/* getch: get a (possibly pushed-back) character */
int getch(void)
int getch (void)
{
return (bufp > 0) ? buf[--bufp] : getchar();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# ifndef GET_UNGETCH_H
# define GET_UNGETCH_H
# ifndef GETCH_H
# define GETCH_H

/* getch: get a (possibly pushed-back) character */
int getch (void);

/* ungetch: push character back on input */
void ungetch (int c);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# include <ctype.h>

# include "getop.h"
# include "get_ungetch.h"
# include "getch.h"


/* getop: get next character or numeric operand */
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# include <stdio.h>
# include <stdlib.h> /* for atof */

# include "pop_push.h"
# include "stack.h"
# include "getop.h"

# define MAXOP 128 /* max size of operand or operator */
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# ifndef POP_PUSH_H
# define POP_PUSH_H
# ifndef STACK_H
# define STACK_H

/* push: push f onto stack */
void push (double f);

/* pop: pop and return top value from stack */
double pop (void);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1 ( )
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
error: unknown command (
error: unknown command )
1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
5 0 /
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
error: zero divisor
5
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
5 0 %
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
error: zero modulus
5
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1024 1024 +
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2048
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1024 2048 -
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-1024
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-10 -55 -
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
45
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-2 100 -5 * *
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1000
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
125 -5 / 5 / -0.2 /
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
20 100 21 % %
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
4
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-1 1 - 100 * 5 / 25 / 1 +
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-0.6

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

# define BUFSIZE 128

char buf[BUFSIZE]; /* buffer fir ungetch */
char buf[BUFSIZE]; /* buffer for ungetch */
int bufp = 0; /* next free position in buf */


/* getch: get a (possibly pushed-back) character */
int getch(void)
int getch (void)
{
return (bufp > 0) ? buf[--bufp] : getchar();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
error: stack empty
0
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1 ( )
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
error: unknown command (
error: unknown command )
1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
5 0 /
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
error: zero divisor
5
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
5 0 %
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
error: zero modulus
5
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
:
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
error: stack empty
0
error: stack empty
0
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1024 1024 +
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2048
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1024 2048 -
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-1024
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-10 -55 -
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
45
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-2 100 -5 * *
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1000
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
125 -5 / 5 / -0.2 /
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
20 100 21 % %
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
4
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-1 1 - 100 * 5 / 25 / 1 +
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-0.6
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.01 : 999
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
1.01
999
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1 2 3 |
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1 22 300 !
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
error: stack empty
0

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

4 changes: 2 additions & 2 deletions chapter_4.functions_progr_structure/4_05.calc__math/getch.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

# define BUFSIZE 128

char buf[BUFSIZE]; /* buffer fir ungetch */
char buf[BUFSIZE]; /* buffer for ungetch */
int bufp = 0; /* next free position in buf */


/* getch: get a (possibly pushed-back) character */
int getch(void)
int getch (void)
{
return (bufp > 0) ? buf[--bufp] : getchar();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# define BUFSIZE 128

char buf[BUFSIZE]; /* buffer fir ungetch */
char buf[BUFSIZE]; /* buffer for ungetch */
int bufp = 0; /* next free position in buf */


Expand Down

0 comments on commit 8158578

Please sign in to comment.