1 /* Part of a driver used to test dbase */
3 /* Include those modules that export things that are used explicitly here */
11 int main(int argc, char *argv[])
20 /* Initialize all of the LCL-specified modules that were included */
28 printf ("FormatPos: Wrong number of arguments. Given %d needs 0.\n",
33 /* Unit test empset */
34 em1 = empset_create();
36 if (!(empset_size(em1) == 0))
38 printf("Size should be 0.\n");
41 for (i = 0; i < 500; i++)
47 (void) sprintf(na, "S.S. Doe %d", i);
48 employee_setName(&e, na);
49 empset_insert(em1, e);
52 if (!(empset_size(em1) == 500))
54 printf("Size should be 500.\n");
57 for (i = 0; i < 250; i++)
63 (void) sprintf(na, "S.S. Doe %d", i);
64 employee_setName(&e, na);
65 empset_delete(em1, e);
68 if (!(empset_size(em1) == 250))
70 printf("Size should be 250.\n");
73 em2 = empset_create();
75 for (i = 0; i < 100; i++)
81 (void) sprintf(na, "S.S. Doe %d", i);
82 employee_setName(&e, na);
83 empset_insert(em2, e);
86 em3 = empset_union(em1, em2);
88 if (!(empset_size(em3) == 350))
90 printf("Size should be 350.\n");
93 empset_intersect(em3, em3);
95 if (!(empset_size(em3) == 350))
97 printf("Size should be 350.\n");
100 printf("Print two different employees:\n");
102 for (i = 0; i < 2; i++)
104 e = empset_choose(em3);
105 employee_sprint(na, e);
106 printf("%s\n", &(na[0]));
107 empset_delete(em3, e);
112 for (i = 0; i < 20; i++)
116 if (i < 10) e.gen = MALE; else e.gen = FEMALE;
117 if (i < 15) e.j = NONMGR; else e.j = MGR;
118 (void) sprintf(na, "J. Doe %d", i);
119 employee_setName(&e, na);
127 uncheckedHire(e); j = hire(e);
131 printf("Should print 4: %d\n", j);
132 printf("Employees 0 - 19\n");
135 q.g = FEMALE; q.j = job_ANY; q.l = 158; q.h = 185;
136 printf("Employees 0 - 16, 18 - 19\n");
139 i = query(q, em1 = empset_create());
140 sprintResult = empset_sprint(em1);
141 printf("Should get two females: %d\n%s\n", i, sprintResult);
144 q.g = MALE; q.j = NONMGR; q.l = 0; q.h = 185;
145 i = query(q, em2 = empset_create());
146 em3 = empset_disjointUnion(em2, em1);
147 sprintResult = empset_sprint(em3);
148 i = empset_size(em3);
149 printf("Should get two females and ten males: %d\n%s\n", i, sprintResult);
152 empset_intersect(em1, em3);
153 sprintResult = empset_sprint(em1);
154 i = empset_size(em1);
155 printf("Should get two females: %d\n%s\n", i, sprintResult);
158 fire(empset_choose(em3).ssNum);
159 printf("Should get 18 employees\n");