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[])
13 /*@globals internalState@*/ /*@modifies internalState@*/
23 /* Initialize all of the LCL-specified modules that were included */
31 printf ("FormatPos: Wrong number of arguments. Given %d needs 0.\n",
36 /* Unit test empset */
37 em1 = empset_create();
39 if (!(empset_size(em1) == 0))
41 printf("Size should be 0.\n");
44 for (i = 0; i < 500; i++)
50 (void) sprintf(na, "S.S. Doe %d", i);
51 check (employee_setName(&e, na));
52 empset_insert(em1, e);
55 if (!(empset_size(em1) == 500))
57 printf("Size should be 500.\n");
60 for (i = 0; i < 250; i++)
66 (void) sprintf(na, "S.S. Doe %d", i);
67 check (employee_setName(&e, na));
68 empset_delete(em1, e);
71 if (!(empset_size(em1) == 250))
73 printf("Size should be 250.\n");
76 em2 = empset_create();
78 for (i = 0; i < 100; i++)
84 (void) sprintf(na, "S.S. Doe %d", i);
85 check (employee_setName(&e, na));
86 empset_insert(em2, e);
89 em3 = empset_union(em1, em2);
91 if (!(empset_size(em3) == 350))
93 printf("Size should be 350.\n");
96 empset_intersect(em3, em3);
98 if (!(empset_size(em3) == 350))
100 printf("Size should be 350.\n");
103 printf("Print two different employees:\n");
105 for (i = 0; i < 2; i++)
107 e = empset_choose(em3);
108 employee_sprint(na, e);
109 printf("%s\n", &(na[0]));
110 empset_delete(em3, e);
115 for (i = 0; i < 20; i++)
138 (void) sprintf(na, "J. Doe %d", i);
139 check (employee_setName(&e, na));
143 check (db_hire(e) == DBS_OK);
147 db_uncheckedHire(e); status = db_hire(e);
151 printf("Should print true: %s\n",
152 bool_unparse (/*@-usedef@*/ status == DBS_DUPLERR /*@=usedef@*/));
154 printf("Employees 0 - 19\n");
157 q.g = FEMALE; q.j = JOB_UNKNOWN; q.l = 158; q.h = 185;
158 printf("Employees 0 - 16, 18 - 19\n");
162 i = db_query(q, em1 = empset_create());
163 sprintResult = empset_sprint(em1);
164 printf("Should get two females: %d\n%s\n", i, sprintResult);
167 q.g = MALE; q.j = NONMGR; q.l = 0; q.h = 185;
169 i = db_query(q, em2 = empset_create());
171 em3 = empset_disjointUnion(em2, em1);
172 sprintResult = empset_sprint(em3);
173 i = empset_size(em3);
174 printf("Should get two females and ten males: %d\n%s\n", i, sprintResult);
177 empset_intersect(em1, em3);
178 sprintResult = empset_sprint(em1);
179 i = empset_size(em1);
180 printf("Should get two females: %d\n%s\n", i, sprintResult);
183 check (db_fire(empset_choose(em3).ssNum));
184 printf("Should get 18 employees\n");