-
Notifications
You must be signed in to change notification settings - Fork 38
Expand file tree
/
Copy pathTestPartitionTask.c
More file actions
46 lines (36 loc) · 991 Bytes
/
Copy pathTestPartitionTask.c
File metadata and controls
46 lines (36 loc) · 991 Bytes
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
#include "TestPartitionTask.h"
int checkTask(task t, int expectedNum1, int expectedNum2) {
return t.partitionNum1 == expectedNum1 && t.partitionNum2 == expectedNum2;
}
int testParseTaskArg() {
// arrange
int numPartition = 4;
const char* arg = "3-6";
// act
TaskSet *ts = parseTaskArg(arg, 4);
// assert
int failed = 0;
if (checkTask(ts->tasks[0], 1, 3) && checkTask(ts->tasks[1], 1, 4) && checkTask(ts->tasks[2], 2, 2) && checkTask(ts->tasks[3], 2, 3)) {
printf("Passed: testParseTaskArg\n");
} else {
failed++;
printf("Failed: testParseTaskArg\n");
}
freeTaskSet(ts);
return failed;
}
int testGetTaskNum() {
// arrange
int p1 = 2;
int p2 = 3;
int numPartition = 4;
// act
int taskNum = getTaskNum(2,3,4);
// assert
if (taskNum == 6) {
printf("Passed: testGetTaskNum\n");
return 0;
}
printf("Failed: testGetTaskNum\n");
return 1;
}