MCPcopy Create free account
hub / github.com/SuprDewd/CompetitiveProgramming / test

Function test

code/graph/floyd_warshall.test.cpp:1–67  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1void test() {
2 int arr[4][4] = {
3 {0, 5, INF, 30},
4 {6, 0, INF, INF},
5 {INF, INF, 0, 8},
6 {4, 2, 1, 0}
7 };
8
9 int res[4][4] = {
10 {0, 5, 31, 30},
11 {6, 0, 37, 36},
12 {12, 10, 0, 8},
13 {4, 2, 1, 0}
14 };
15
16 int** r = new int*[4];
17 for (int i = 0; i < 4; i++)
18 {
19 r[i] = new int[4];
20 for (int j = 0; j < 4; j++)
21 {
22 r[i][j] = arr[i][j];
23 }
24 }
25
26 floyd_warshall(r, 4);
27
28 for (int i = 0; i < 4; i++)
29 {
30 for (int j = 0; j < 4; j++)
31 {
32 assert_equal(res[i][j], r[i][j]);
33 }
34 }
35
36 int arr2[3][3] = {
37 {0, 2, 10},
38 {INF, 0, 4},
39 {INF, INF, 0}
40 };
41
42 int res2[3][3] = {
43 {0, 2, 6},
44 {INF, 0, 4},
45 {INF, INF, 0}
46 };
47
48 int** r2 = new int*[3];
49 for (int i = 0; i < 3; i++)
50 {
51 r2[i] = new int[3];
52 for (int j = 0; j < 3; j++)
53 {
54 r2[i][j] = arr2[i][j];
55 }
56 }
57
58 floyd_warshall(r2, 3);
59
60 for (int i = 0; i < 3; i++)

Callers

nothing calls this directly

Calls 2

floyd_warshallFunction · 0.85
assert_equalFunction · 0.50

Tested by

no test coverage detected