-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.cpp
More file actions
566 lines (440 loc) · 22.8 KB
/
Copy pathtest.cpp
File metadata and controls
566 lines (440 loc) · 22.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
#include "pch.h"
#include <gtest/gtest.h>
#include "Red_Black_Tree.h"
TEST(display, ID) {
taskManagementSystem taskSystem;
// auto assign unique IDs to each Assignee
//First name, Last Name, Address, DOB
taskSystem.addAssignee("Maham", "Khurram", "Dha phase 2", "25/11/2002"); //This should get A001
taskSystem.addAssignee("Laraib", "Fatima", "Dha phase 2", "11/2/2002"); // A002 and so on.
taskSystem.addAssignee("Nuzhat", "ul", "Askari 14", "1/1/2001");
std::stringstream actualOutput;
taskSystem.displaybyID(actualOutput, "A002");
//The expected output
std::string expectedOutput = "Name: Laraib Fatima, Address: Dha phase 2, DOB: 11/2/2002, Assignee ID: A002\n";
// Compare the actual output with the expected output
ASSERT_EQ(actualOutput.str(), expectedOutput);
}
TEST(display, name) {
taskManagementSystem taskSystem;
// auto assign unique IDs to each Assignee
taskSystem.addAssignee("Muhammad", "Ali", "I8", "2/11/2001"); //This should get A001
taskSystem.addAssignee("Muhammad", "Shah", "Dha phase 1", "11/2/2002"); // A002 and so on.
taskSystem.addAssignee("Muhammad", "Ali", "Askari 14", "1/1/2003");
std::stringstream actualOutput;
taskSystem.displaybyname(actualOutput, "Muhammad", "Ali");
//The expected output
std::string expectedOutput =
"Name: Muhammad Ali, Address: I8, DOB: 2/11/2001, Assignee ID: A001\n"
"Name: Muhammad Ali, Address: Askari 14, DOB: 1/1/2003, Assignee ID: A003\n";
// Compare the actual output with the expected output
ASSERT_EQ(actualOutput.str(), expectedOutput);
}
TEST(display, notask) {
taskManagementSystem taskSystem;
// auto assign unique IDs to each Assignee
taskSystem.addAssignee("Muhammad", "Ali", "I8", "2/11/2001"); //This should get A001
taskSystem.addAssignee("Muhammad", "Shah", "Dha phase 1", "11/2/2002"); // A002 and so on.
taskSystem.addAssignee("Muhammad", "Ali", "Askari 14", "1/1/2003");
taskSystem.addTask(102, "Fix Bug in Module B", 2, "A002");
taskSystem.addTask(103, "Write Unit Tests", 1, "A003");
std::stringstream actualOutput;
taskSystem.AssigneeWithNoTask(actualOutput);
//The expected output
std::string expectedOutput = "Name: Muhammad Ali, Address: I8, DOB: 2/11/2001, Assignee ID: A001\n";
// Compare the actual output with the expected output
ASSERT_EQ(actualOutput.str(), expectedOutput);
}
TEST(display, shiftTask) {
taskManagementSystem taskSystem;
// auto assign unique IDs to each Assignee
taskSystem.addAssignee("Mehar", "Azam", "I6", "2/11/2003"); //This should get A001
taskSystem.addAssignee("Muhammad", "Hashim", "Dha phase 5", "11/2/2002"); // A002 and so on.
taskSystem.addAssignee("Hashir", "Ather", "Askari 4", "1/1/2003");
taskSystem.addTask(102, "Fix Bug in Module B", 2, "A002");
taskSystem.addTask(103, "Write Unit Tests", 1, "A003");
taskSystem.ShiftTask("A002", "A003"); //tasks of A002 will be shifted to A003 and A002 will be left with no tasks for the time being.
std::stringstream actualOutput1;
taskSystem.AssigneeWithNoTask(actualOutput1);
//The expected output
std::string expectedOutput1 =
"Name: Mehar Azam, Address: I6, DOB: 2/11/2003, Assignee ID: A001\n"
"Name: Muhammad Hashim, Address: Dha phase 5, DOB: 11/2/2002, Assignee ID: A002\n";
std::stringstream actualOutput2;
taskSystem.printTaskQueue(actualOutput2); //output should be displayed in order of highest to lowest priority
//The expected output
std::string expectedOutput2 =
"Task ID: 103, Description: Write Unit Tests, Priority: 1, Assignee: Hashir (A003)\n"
"Task ID: 102, Description: Fix Bug in Module B, Priority: 2, Assignee: Hashir (A003)\n"
;
// Compare the actual output with the expected output
ASSERT_EQ(actualOutput1.str(), expectedOutput1);
ASSERT_EQ(actualOutput2.str(), expectedOutput2);
}
TEST(display, delete1) {
taskManagementSystem taskSystem;
// auto assign unique IDs to each Assignee
taskSystem.addAssignee("Muhammad", "Ali", "I8", "2/11/2001"); //This should get A001
taskSystem.addAssignee("Muhammad", "Shah", "Dha phase 1", "11/2/2002"); // A002 and so on.
taskSystem.addAssignee("Muhammad", "Ali", "Askari 14", "1/1/2003");
taskSystem.addTask(102, "Fix Bug in Module B", 2, "A002");
taskSystem.addTask(103, "Write Unit Tests", 1, "A003");
taskSystem.DeleteAssignee("A001");
std::stringstream actualOutput;
taskSystem.DisplayAssignee(actualOutput); //Dispay in order of IDs
//The expected output
std::string expectedOutput =
"Name: Muhammad Shah, Address: Dha phase 1, DOB: 11/2/2002, Assignee ID: A002\n"
"Name: Muhammad Ali, Address: Askari 14, DOB: 1/1/2003, Assignee ID: A003\n";
// Compare the actual output with the expected output
ASSERT_EQ(actualOutput.str(), expectedOutput);
}
TEST(display, delete2) {
taskManagementSystem taskSystem;
// auto assign unique IDs to each Assignee
taskSystem.addAssignee("Muhammad", "Ali", "I8", "2/11/2001"); //This should get A001
taskSystem.addAssignee("Muhammad", "Shah", "Dha phase 1", "11/2/2002"); // A002 and so on.
taskSystem.addAssignee("Muhammad", "Ali", "Askari 14", "1/1/2003");
taskSystem.addTask(102, "Fix Bug in Module B", 2, "A002");
taskSystem.addTask(103, "Write Unit Tests", 1, "A003");
taskSystem.DeleteAssignee("A002");
std::stringstream actualOutput;
taskSystem.DisplayAssignee(actualOutput); //Dispay in order of IDs
//The expected output
std::string expectedOutput =
"Name: Muhammad Ali, Address: I8, DOB: 2/11/2001, Assignee ID: A001\n"
"Name: Muhammad Shah, Address: Dha phase 1, DOB: 11/2/2002, Assignee ID: A002\n"
"Name: Muhammad Ali, Address: Askari 14, DOB: 1/1/2003, Assignee ID: A003\n"; //Assignee will not be deleted if they have assigned tasks
// Compare the actual output with the expected output
ASSERT_EQ(actualOutput.str(), expectedOutput);
}
TEST(display, delete3)
{
taskManagementSystem taskSystem;
taskSystem.addAssignee("Muhammad", "Ali", "I8", "2/11/2001"); //This should get A001
taskSystem.addAssignee("Muhammad", "Shah", "Dha phase 1", "11/2/2002"); // A002 and so on.
taskSystem.addAssignee("Muhammad", "Ali", "Askari 14", "1/1/2003");
taskSystem.DeleteAssignee("A003");
taskSystem.addAssignee("Hussain", "Ali", "Lalazar", "20/1/2001"); //This should get A004
std::stringstream actualOutput;
taskSystem.DisplayAssignee(actualOutput); //Dispay in order of IDs
//The expected output
std::string expectedOutput =
"Name: Muhammad Ali, Address: I8, DOB: 2/11/2001, Assignee ID: A001\n"
"Name: Muhammad Shah, Address: Dha phase 1, DOB: 11/2/2002, Assignee ID: A002\n"
"Name: Hussain Ali, Address: Lalazar, DOB: 20/1/2001, Assignee ID: A004\n";
// Compare the actual output with the expected output
ASSERT_EQ(actualOutput.str(), expectedOutput);
}
TEST(display, inorderAssignee) {
taskManagementSystem taskSystem;
// auto assign unique IDs to each Assignee
taskSystem.addAssignee("Muhammad", "Ali", "I8", "2/11/2001"); //This should get A001
taskSystem.addAssignee("Muhammad", "Shah", "Dha phase 1", "11/2/2002"); // A002 and so on.
taskSystem.addAssignee("Muhammad", "Ali", "Askari 14", "1/1/2003");
taskSystem.addAssignee("Zahra", "Rida", "I6", "2/10/2000");
taskSystem.addAssignee("Mukhtar", "Shah", "Dha phase 7", "1/2/2001");
taskSystem.addAssignee("Hammad", "Ali", "Askari 4", "1/10/2002");
taskSystem.DeleteAssignee("A002");
std::stringstream actualOutput;
taskSystem.AssigneeInOrder(actualOutput); //Dispay in order of IDs
//The expected output
std::string expectedOutput =
"A001 (black)\n"
"A003 (red)\n"
"A004 (black)\n"
"A005 (black)\n"
"A006 (red)\n";
// Compare the actual output with the expected output
ASSERT_EQ(actualOutput.str(), expectedOutput);
}
TEST(updating, first) {
taskManagementSystem taskSystem;
// auto assign unique IDs to each Assignee
taskSystem.addAssignee("Muhammad", "Ali", "I8", "2/11/2001"); //This should get A001
taskSystem.addAssignee("Muhammad", "Shah", "Dha phase 1", "11/2/2002"); // A002 and so on.
taskSystem.addAssignee("Muhammad", "Ali", "Askari 14", "1/1/2003");
taskSystem.addTask(101, "Implement Feature A", 3, "A001");
taskSystem.addTask(102, "Fix Bug in Module B", 2, "A002");
taskSystem.addTask(103, "Write Unit Tests", 1, "A003");
// Capture the actual output
std::stringstream actualOutput;
taskSystem.printTaskQueue(actualOutput);
//The expected output
std::string expectedOutput =
"Task ID: 103, Description: Write Unit Tests, Priority: 1, Assignee: Muhammad (A003)\nTask ID: 102, Description: Fix Bug in Module B, Priority: 2, Assignee: Muhammad (A002)\nTask ID: 101, Description: Implement Feature A, Priority: 3, Assignee: Muhammad (A001)\n";
//output should be displayed in order of highest to lowest priority
// Compare the actual output with the expected output
ASSERT_EQ(actualOutput.str(), expectedOutput);
}
TEST(updating, second) {
taskManagementSystem taskSystem;
taskSystem.addAssignee("Aaimlik", "Abbasi", "I6", "2/11/2003"); //This should get A001
taskSystem.addAssignee("Amna", "Hashim", "Dha phase 5", "11/2/2002"); // A002 and so on.
taskSystem.addAssignee("Huma", "Ather", "Askari 4", "1/1/2003");
taskSystem.addTask(101, "Implement Feature A", 3, "A001");
taskSystem.addTask(102, "Fix Bug in Module B", 2, "A002");
taskSystem.addTask(103, "Write Unit Tests", 1, "A003");
taskSystem.completeTask(102);
taskSystem.updateTaskPriority(101, 2);
// Capture the actual output
std::stringstream actualOutput;
taskSystem.printTaskQueue(actualOutput);
// Define the expected output
std::string expectedOutput = "Task ID: 103, Description: Write Unit Tests, Priority: 1, Assignee: Huma (A003)\n"
"Task ID: 101, Description: Implement Feature A, Priority: 2, Assignee: Aaimlik (A001)\n";
// Compare the actual output with the expected output
ASSERT_EQ(actualOutput.str(), expectedOutput);
}
TEST(highestpriority, first) {
taskManagementSystem taskSystem;
taskSystem.addAssignee("Aaimlik", "Abbasi", "I6", "2/11/2003"); //This should get A001
taskSystem.addAssignee("Amna", "Hashim", "Dha phase 5", "11/2/2002"); // A002 and so on.
taskSystem.addAssignee("Huma", "Ather", "Askari 4", "1/1/2003");
taskSystem.addTask(101, "Implement Feature A", 3, "A001");
taskSystem.addTask(102, "Fix Bug in Module B", 2, "A002");
taskSystem.addTask(103, "Write Unit Tests", 1, "A003");
// Capture the actual output
std::stringstream actualOutput;
taskSystem.findHighestPriorityTask(actualOutput);
// Define the expected output
std::string expectedOutput = "Highest Priority Task: Task ID: 103, Description: Write Unit Tests, Priority: 1, Assignee: Huma (A003)\n";
cout << actualOutput.str();
cout << expectedOutput;
}
TEST(findingtasks, wusqa) {
taskManagementSystem taskSystem;
// Add tasks
taskSystem.addAssignee("Wusqa", "Khan", "I6", "2/11/2003"); //This should get A001
taskSystem.addAssignee("Amna", "Hashim", "Dha phase 5", "11/2/2002"); // A002 and so on.
taskSystem.addTask(101, "Implement Feature A", 3, "A001");
taskSystem.addTask(102, "Fix Bug in Module B", 2, "A002");
taskSystem.addTask(103, "Write Unit Tests", 1, "A001");
// Capture the actual output
std::stringstream actualOutput;
taskSystem.findTasksByAssignee("A001", actualOutput);
cout << actualOutput.str() << endl;
// Define the expected output
std::string expectedOutput = "Tasks Assigned to \"Wusqa (A001)\":\n"
"Task ID: 103, Description: Write Unit Tests, Priority: 1, Assignee: Wusqa (A001)\n"
"Task ID: 101, Description: Implement Feature A, Priority: 3, Assignee: Wusqa (A001)\n";
ASSERT_EQ(actualOutput.str(), expectedOutput);
}
TEST(counting, tasks) {
taskManagementSystem taskSystem;
taskSystem.addAssignee("Wusqa", "Khan", "I6", "2/11/2003"); //This should get A001
taskSystem.addAssignee("Amna", "Hashim", "Dha phase 5", "11/2/2002"); // A002 and so on.
taskSystem.addAssignee("Mehdi", "Khan", "I8", "2/11/2003");
taskSystem.addAssignee("Hadi", "Hashim", "Dha phase 5", "14/2/2002");
taskSystem.addAssignee("Haider", "Khan", "H11", "2/11/2002");
taskSystem.addAssignee("Mesum", "Hashim", "Dha phase 1", "1/2/2002");
// Add tasks
taskSystem.addTask(101, "Implement Feature A", 2, "A001");
taskSystem.addTask(102, "Fix Bug in Module B", 3, "A002");
taskSystem.addTask(103, "Write Unit Tests", 1, "A003");
taskSystem.addTask(104, "Dry run of Module D", 5, "A004");
taskSystem.addTask(105, "Fix Bug in Module C", 4, "A005");
taskSystem.addTask(106, "Rewrite the report", 6, "A006");
// Capture the actual output
std::stringstream actualOutput;
taskSystem.countTotalTasks(actualOutput);
// Define the expected output
std::string expectedOutput = "Total Tasks in the System: 6\n";
ASSERT_EQ(actualOutput.str(), expectedOutput);
}
TEST(displaying, completed_tasks) {
taskManagementSystem taskSystem;
taskSystem.addAssignee("Tanzeela", "Khan", "I6", "2/12/2003"); //This should get A001
taskSystem.addAssignee("Farakh", "Hashim", "Dha phase 5", "1/2/2002"); // A002 and so on.
taskSystem.addAssignee("Rodaba", "Khan", "I5", "2/11/2003");
taskSystem.addAssignee("Laila", "Hashim", "Dha phase 2", "11/2/2002");
// Add tasks
taskSystem.addTask(101, "Implement Feature A", 2, "A001");
taskSystem.addTask(102, "Fix Bug in Module B", 3, "A002");
taskSystem.addTask(103, "Implement Feature D", 1, "A003");
taskSystem.addTask(104, "Fix Bug in Module F", 4, "A004");
// Mark a task as completed
taskSystem.completeTask(101);
// Capture the actual output
std::stringstream actualOutput;
taskSystem.displayCompletedTasks(actualOutput);
std::string expectedOutput = "Completed Tasks:\n"
"Task ID: 101, Description: Implement Feature A, Priority: 2, Assignee: Tanzeela (A001)\n";
ASSERT_EQ(actualOutput.str(), expectedOutput);
}
TEST(Searching, priorityrange) {
taskManagementSystem taskSystem;
taskSystem.addAssignee("Waqas", "Khan", "I6", "2/12/2003"); //This should get A001
taskSystem.addAssignee("Hur", "Hashim", "Dha phase 4", "1/1/2002"); // A002 and so on.
taskSystem.addAssignee("Hasan", "Khan", "I9", "2/11/2003");
// Add tasks with various priority levels
taskSystem.addTask(101, "Implement Feature A", 2, "A001");
taskSystem.addTask(102, "Fix Bug in Module B", 3, "A002");
taskSystem.addTask(103, "Write Unit Tests", 1, "A003");
// Capture the actual output
std::stringstream actualOutput;
taskSystem.searchTasksByPriorityRange(1, 2, actualOutput);
// Define the expected output
std::string expectedOutput = "Tasks within Priority Range (1 to 2):\n"
"Task ID: 103, Description: Write Unit Tests, Priority: 1, Assignee: Hasan (A003)\n"
"Task ID: 101, Description: Implement Feature A, Priority: 2, Assignee: Waqas (A001)\n";
// Compare the actual output with the expected output and display "PASS" or "FAIL"
ASSERT_EQ(actualOutput.str(), expectedOutput);
}
TEST(display_tree, insertion)
{
taskManagementSystem taskSystem;
taskSystem.addAssignee("Riaz", "Khan", "I6", "2/12/2003"); //This should get A001
taskSystem.addAssignee("Zulqurnain", "Hashim", "Dha phase 5", "1/2/2002"); // A002 and so on.
taskSystem.addAssignee("Hussain", "Khan", "I5", "2/11/2003");
taskSystem.addAssignee("Laila", "Hashim", "Dha phase 2", "1/2/2002");
taskSystem.addAssignee("Qasim", "Khan", "I6", "2/12/2000");
taskSystem.addAssignee("Mustafa", "Hashim", "Dha phase 3", "1/2/2002");
// Insert tasks
taskSystem.addTask(101, "Task A", 3, "A001");
taskSystem.addTask(102, "Task B", 2, "A002");
taskSystem.addTask(103, "Task C", 1, "A003");
taskSystem.addTask(104, "Task D", 4, "A004");
taskSystem.addTask(105, "Task E", 5, "A005");
taskSystem.addTask(106, "Task F", 6, "A006");
//A tree would be created considering the priorities not the task number.
// Capture the actual output
std::stringstream actualOutput;
taskSystem.PrintTreeInorder(actualOutput); //In Order Traversal with the color of that node
// Define the expected output
std::string expectedOutput =
"103 (black)\n"
"102 (black)\n"
"101 (black)\n"
"104 (red)\n"
"105 (black)\n"
"106 (red)\n";
ASSERT_EQ(actualOutput.str(), expectedOutput);
}
TEST(display_tree, deletion)
{
taskManagementSystem taskSystem;
taskSystem.addAssignee("Riaz", "Khan", "I6", "2/12/2003"); //This should get A001
taskSystem.addAssignee("Zulqurnain", "Hashim", "Dha phase 5", "1/2/2002"); // A002 and so on.
taskSystem.addAssignee("Hussain", "Khan", "I5", "2/11/2003");
taskSystem.addAssignee("Laila", "Hashim", "Dha phase 2", "1/2/2002");
taskSystem.addAssignee("Qasim", "Khan", "I8", "2/12/2000");
taskSystem.addAssignee("Mustafa", "Hashim", "Dha phase 2", "1/2/2002");
taskSystem.addAssignee("Reem", "Khayar", "I6", "2/2/2003");
taskSystem.addAssignee("Badr", "Sheik", "Dha phase 5", "1/2/2002");
taskSystem.addAssignee("Eesha", "Anwar", "I5", "2/1/2003");
taskSystem.addAssignee("Fawad", "Hashim", "Dha phase 2", "1/2/2002");
taskSystem.addAssignee("Khizar", "Khan", "I6", "22/2/2000");
taskSystem.addAssignee("Yahya", "Hashim", "Dha phase 3", "1/2/2002");
// Insert tasks
taskSystem.addTask(101, "Task A", 7, "A001");
taskSystem.addTask(102, "Task B", 6, "A002");
taskSystem.addTask(103, "Task C", 3, "A003");
taskSystem.addTask(104, "Task D", 11, "A004");
taskSystem.addTask(105, "Task E", 12, "A005");
taskSystem.addTask(106, "Task F", 2, "A006");
taskSystem.addTask(107, "Task G", 10, "A007");
taskSystem.addTask(108, "Task H", 4, "A008");
taskSystem.addTask(109, "Task I", 8, "A009");
taskSystem.addTask(110, "Task J", 1, "A010");
taskSystem.addTask(111, "Task K", 9, "A011");
taskSystem.addTask(112, "Task L", 5, "A012");
//A tree would be created considering the priorities not the task number.
// Delete a task
taskSystem.deleteTask(102);
// Capture the actual output
std::stringstream actualOutput;
taskSystem.PrintTreeInorder(actualOutput); //In Order Traversal with the color of that node
// Define the expected output after deleting the task
std::string expectedOutput =
"110 (red)\n"
"106 (black)\n"
"103 (black)\n"
"108 (black)\n"
"112 (black)\n"
"101 (black)\n"
"109 (red)\n"
"111 (red)\n"
"107 (black)\n"
"104 (black)\n"
"105 (black)\n";
ASSERT_EQ(actualOutput.str(), expectedOutput);
}
TEST(display_tree, UpdateTaskPriorities) {
taskManagementSystem taskSystem;
taskSystem.addAssignee("Musa", "Khan", "I6", "2/12/2003"); //This should get A001
taskSystem.addAssignee("Isa", "Hashim", "Dha phase 5", "1/2/2002"); // A002 and so on.
taskSystem.addAssignee("Hussain", "Khan", "I5", "2/11/2003");
taskSystem.addAssignee("Shahzaib", "Hashim", "Dha phase 2", "1/2/2002");
taskSystem.addAssignee("Qasim", "Khan", "I8", "2/12/2000");
taskSystem.addAssignee("Rida", "Hashim", "Dha phase 2", "1/2/2002");
// Add tasks
taskSystem.addTask(101, "Task A", 7, "A001");
taskSystem.addTask(102, "Task B", 6, "A002");
taskSystem.addTask(103, "Task C", 3, "A003");
taskSystem.addTask(104, "Task A", 5, "A004");
taskSystem.addTask(105, "Task B", 4, "A005");
taskSystem.addTask(106, "Task C", 1, "A006");
// Display the initial tree
std::stringstream initialTreeOutput;
taskSystem.PrintTreeInorder(initialTreeOutput); //In Order Traversal with the color of that node
taskSystem.updateTaskPriority(105, 2);
// Display the updated tree
std::stringstream updatedTreeOutput; //In Order Traversal with the color of that node
taskSystem.PrintTreeInorder(updatedTreeOutput);
// Define the expected output
std::string expectedInitialTreeOutput =
"106 (red)\n"
"103 (black)\n"
"105 (red)\n"
"104 (black)\n"
"102 (black)\n"
"101 (black)\n";
std::string expectedUpdatedTreeOutput =
"106 (black)\n"
"105 (red)\n"
"103 (red)\n"
"104 (black)\n"
"102 (black)\n"
"101 (black)\n";
// Check if the initial tree and updated tree match the expected output
ASSERT_EQ(initialTreeOutput.str(), expectedInitialTreeOutput);
ASSERT_EQ(updatedTreeOutput.str(), expectedUpdatedTreeOutput);
}
TEST(display_tree, samepriority) {
taskManagementSystem taskSystem;
taskSystem.addAssignee("Musa", "Khan", "I6", "2/12/2003"); //This should get A001
taskSystem.addAssignee("Isa", "Hashim", "Dha phase 5", "1/2/2002"); // A002 and so on.
taskSystem.addAssignee("Hussain", "Khan", "I5", "2/11/2003");
taskSystem.addAssignee("Shahzaib", "Hashim", "Dha phase 2", "1/2/2002");
taskSystem.addAssignee("Qasim", "Khan", "I8", "2/12/2000");
taskSystem.addAssignee("Rida", "Hashim", "Dha phase 2", "1/2/2002");
taskSystem.addAssignee("Ali", "Shah", "I8", "1/2/2003");
// Add tasks
taskSystem.addTask(101, "Task A", 7, "A001");
taskSystem.addTask(102, "Task B", 6, "A002");
taskSystem.addTask(103, "Task C", 3, "A003");
taskSystem.addTask(104, "Task A", 5, "A004");
taskSystem.addTask(105, "Task B", 4, "A005");
taskSystem.addTask(106, "Task C", 1, "A006");
taskSystem.addTask(107, "Task D", 3, "A007");
// Display the tree
std::stringstream TreeOutput;
taskSystem.PrintTreeInorder(TreeOutput); //In Order Traversal with the color of that node
//in case of same priority tasks, arrange them wrt task id, in ascending order.
// Define the expected output
std::string expectedInitialTreeOutput =
"106 (red)\n"
"103 (black)\n"
"107 (red)\n"
"105 (red)\n"
"104 (black)\n"
"102 (black)\n"
"101 (black)\n";
// Check if the tree match the expected output
ASSERT_EQ(TreeOutput.str(), expectedInitialTreeOutput);
}
int main(int argc, char** argv) {
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}