-
Notifications
You must be signed in to change notification settings - Fork 0
/
testGraph.c
60 lines (44 loc) · 1.24 KB
/
testGraph.c
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
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include "Graph.h"
#include "Agent.h"
int main(int argc,char *argv[]){
Graph g = newGraph(10);
printf("Testing newGraph\n");
assert(g != NULL);
printf("Test passed!\n");
printf("Testing numV\n");
assert(numV(g) == 10);
printf("Test passed!\n");
printf("Testing mkEdge\n");
Edge e = mkEdge(2,3,10);
assert(e.v == 2);
assert(e.w == 3);
assert(e.weight == 10);
printf("Test passed!\n");
printf("Testing insertE\n");
insertE(g,mkEdge(1,2,10));
insertE(g,mkEdge(2,3,10));
insertE(g,mkEdge(1,3,10));
assert(numV(g) == 10);
assert(numE(g) == 3);
printf("Test passed!\n");
printf("Testing isAdjacent\n");
printf("Testing edges added\n");
assert(isAdjacent(g,1,2) == 1);
assert(isAdjacent(g,1,3) == 1);
printf("Test passed!\n");
printf("Testing graph symmetry\n");
assert(isAdjacent(g,3,2) == 1);
assert(isAdjacent(g,2,3) == 1);
printf("Test passed!\n");
printf("Testing for no edge\n");
assert(isAdjacent(g,1,9) == 0);
assert(isAdjacent(g,8,9) == 0);
printf("Test passed!\n");
printf("All Tests Passed!\n");
destroyGraph(g);
return 0;
}