source: buchla-68k/orig/GP/TESTCQ.C@ ee49131

Last change on this file since ee49131 was 3ae31e9, checked in by Thomas Lopatic <thomas@…>, 8 years ago

Imported original source code.

  • Property mode set to 100755
File size: 1.9 KB
RevLine 
[3ae31e9]1/*
2 =============================================================================
3 testcq.c -- test the character queue functions
4 Version 1 -- 1988-11-02 -- D.N. Lynx Crowe
5 =============================================================================
6*/
7
8#include "stdio.h"
9#include "stddefs.h"
10#include "charq.h"
11
12#define QSIZE 128 /* queue length (characters) for testing */
13
14#define QLO (QSIZE >> 2) /* lo water mark = 1/4 queue length */
15#define QHI (QSIZE - QLO) /* hi water mark = 3/4 queue length */
16
17/*
18 =============================================================================
19 Test the character queue functions
20 =============================================================================
21*/
22
23struct charq queue1;
24
25char chars[QSIZE];
26
27char rs;
28
29main(argc, argv)
30int argc;
31char *argv[];
32{
33 register struct charq *qp;
34 register unsigned short i, qsiz;
35 register short rc;
36
37 qp = &queue1;
38
39 printf("Initializing queue: size = %u, lo water = %u, hi water = %u\n",
40 QSIZE, QLO, QHI);
41
42 if (QSIZE NE (qsiz = setcq(qp, chars, QSIZE, QHI, QLO))) {
43
44 printf("ERROR -- setcq() returned %u\n", qsiz);
45 exit(1);
46 }
47
48 printf("Filling queue of length %u with %u entries\n",
49 QSIZE, QSIZE + 2);
50
51 for (i = 0; i < QSIZE + 2; i++) { /* fill queue to overflow */
52
53 if (rc = putcq(qp, i))
54 printf("putcq() returned %d on entry %u\n",
55 rc, i);
56 }
57
58 printf("Queue $%08.8lx: size = %u, len = %u, in = %u, out = %u\n",
59 qp, qp->qsize, qp->qlen, qp->qin, qp->qout);
60
61 printf("Emptying queue of length %u for %u entries\n",
62 QSIZE, QSIZE + 2);
63
64 for (i = 0; i < QSIZE + 2; i++) { /* empty queue to underflow */
65
66 if (rc = getcq(qp, &rs))
67 printf("getcq() returned %d on entry %u\n",
68 rc, i);
69
70 if ((rs NE i) AND (i < QSIZE))
71 printf("ERROR -- value %u should have been %u\n",
72 rs, i);
73 }
74
75 exit(0);
76}
Note: See TracBrowser for help on using the repository browser.