1 /* Part of a driver used to test dbase */
3 /* Include those modules that export things that are used explicitly here */
12 int main (int argc, /*@unused@*/ char *argv[])
21 /* Initialize all of the LCL-specified modules that were included */
29 printf ("FormatPos: Wrong number of arguments. Given %d needs 0.\n",
34 /* Unit test empset */
35 em1 = empset_create();
37 if (!(empset_size(em1) == 0))
39 printf("Size should be 0.\n");
42 for (i = 0; i < 500; i++)
48 (void) sprintf(na, "S.S. Doe %d", i);
49 check (employee_setName(&e, na));
50 empset_insert(em1, e);
53 if (!(empset_size(em1) == 500))
55 printf("Size should be 500.\n");
58 for (i = 0; i < 250; i++)
64 (void) sprintf(na, "S.S. Doe %d", i);
65 check (employee_setName(&e, na));
66 empset_delete(em1, e);
69 if (!(empset_size(em1) == 250))
71 printf("Size should be 250.\n");
74 em2 = empset_create();
76 for (i = 0; i < 100; i++)
82 (void) sprintf(na, "S.S. Doe %d", i);
83 check (employee_setName(&e, na));
84 empset_insert(em2, e);
87 em3 = empset_union(em1, em2);
89 if (!(empset_size(em3) == 350))
91 printf("Size should be 350.\n");
94 empset_intersect(em3, em3);
96 if (!(empset_size(em3) == 350))
98 printf("Size should be 350.\n");
101 printf("Print two different employees:\n");
103 for (i = 0; i < 2; i++)
105 e = empset_choose(em3);
106 employee_sprint(na, e);
107 printf("%s\n", &(na[0]));
108 empset_delete(em3, e);
113 for (i = 0; i < 20; i++)
117 if (i < 10) e.gen = MALE; else e.gen = FEMALE;
118 if (i < 15) e.j = NONMGR; else e.j = MGR;
119 (void) sprintf(na, "J. Doe %d", i);
120 check (employee_setName(&e, na));
124 check (hire(e) == db_OK);
128 uncheckedHire(e); j = hire(e);
132 printf("Should print 4: %d\n", /*@-usedef@*/ j /*@=usedef@*/);
133 printf("Employees 0 - 19\n");
136 q.g = FEMALE; q.j = job_ANY; q.l = 158; q.h = 185;
137 printf("Employees 0 - 16, 18 - 19\n");
140 i = query(q, em1 = empset_create());
141 sprintResult = empset_sprint(em1);
142 printf("Should get two females: %d\n%s\n", i, sprintResult);
145 q.g = MALE; q.j = NONMGR; q.l = 0; q.h = 185;
146 i = query(q, em2 = empset_create());
147 em3 = empset_disjointUnion(em2, em1);
148 sprintResult = empset_sprint(em3);
149 i = empset_size(em3);
150 printf("Should get two females and ten males: %d\n%s\n", i, sprintResult);
153 empset_intersect(em1, em3);
154 sprintResult = empset_sprint(em1);
155 i = empset_size(em1);
156 printf("Should get two females: %d\n%s\n", i, sprintResult);
159 check (fire(empset_choose(em3).ssNum));
160 printf("Should get 18 employees\n");