-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.cpp
More file actions
69 lines (55 loc) · 1.53 KB
/
Copy pathtest.cpp
File metadata and controls
69 lines (55 loc) · 1.53 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
#pragma once
#include <iostream>
#include "cube.cpp"
#include "solver.cpp"
class Test {
public:
/**
* Randomly generate a cube and try to solve it.
*/
static bool random(int n = 5) {
Cube cube = Cube();
cube.scramble(n);
CubeSolution sol = CubeSolver::solveBF(cube, n);
return sol.solved;
}
/**
* Test ensures that are moves can be performed in CW and then CCW to reset the cube.
*/
static bool movecwccw() {
Cube cube = Cube();
for (int i = 0; i < 9; i++) {
cube.move(i, CubeMoveDirection::CW);
}
for (int i = 8; i >= 0; i--) {
cube.move(i, CubeMoveDirection::CCW);
}
return cube.solved();
}
/**
* Front move to test face rotation.
*/
static bool rotateFace() {
Cube cube = Cube();
cube.debug();
cube.move(CubeMove::F, CubeMoveDirection::CW);
int f[9] = { 6, 3, 0,
7, 4, 1,
8, 5, 2};
for (int i = 0; i < 9; i++) {
if (f[i] != cube.cube[CubeFace::F][i]) {
return false;
}
}
return true;
}
/**
* Run all tests defined here and print to console.
*/
static void test()
{
std::cout << "Test Cube CW/CCW Moves: " << Test::movecwccw() << std::endl;
std::cout << "Test Cube face rotation: " << Test::rotateFace() << std::endl;
std::cout << "Test Cube random: " << Test::random() << std::endl;
}
};