-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmainTest.cpp
More file actions
66 lines (59 loc) · 1.54 KB
/
Copy pathmainTest.cpp
File metadata and controls
66 lines (59 loc) · 1.54 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
#include "Maze.cpp"
#include <iostream>
#include <fstream>
#include <vector>
#include <bits/stdc++.h>
using namespace std;
int main()
{
ifstream cin("mazeTest.txt");
int cases;
cin >> cases;
for (int i = 0; i < cases; i++)
{
int length, width;
cin >> length >> width;
// cout << length << width << endl;
int **matrix = (int **)calloc(length, sizeof(int *));
for (int i = 0; i < length; ++i)
{
matrix[i] = (int *)calloc(width, sizeof(int));
for (int j = 0; j < width; ++j)
{
cin >> matrix[i][j];
//cout << matrix[i][j] << " ";
}
//cout << "" << endl;
}
int start[2];
int end[2];
cin >> start[1] >> start[0];
cin >> end[1] >> end[0];
cout << endl;
Maze *k = new Maze(matrix, length, width);
vector<int *> *coordinates = k->solve(start, end);
int expectedsize;
cin >> expectedsize;
int x, y;
bool failed = false;
if (expectedsize != coordinates->size())
{
failed = true;
}
for (int i = 0; i < expectedsize; i++)
{
cin >> x >> y;
if (x != coordinates->at(i)[1] || y != coordinates->at(i)[0])
{
cout << "Test Failed" << endl;
failed = true;
break;
}
}
if (!failed)
{
cout << "Test Successful" << endl;
}
}
return 0;
}