Commit 1c772599 authored by Korko's avatar Korko
Browse files

Change solverTest to be cross platform

parent 4b742ecf
......@@ -58,21 +58,26 @@ class SolverTest extends TestCase
public function testOne()
{
srand(1);
$rand1 = rand(0, 10);
srand(1);
$rand2 = rand(0, 10);
if ($rand1 !== $rand2) {
$this->markTestSkipped('srand disabled');
return;
}
$this->assertTrue((function() {
$solutions = [
[0 => 1, 1 => 2, 2 => 0],
[0 => 2, 1 => 0, 2 => 1]
];
$valid = [];
for($i = 0; $i < 100; $i++) {
$solution = Solver::one(['A', 'B', 'C']);
$solution_position = array_search($solution, $solutions);
$valid[$solution_position] = TRUE;
srand(1);
$this->assertEquals([0 => 1, 1 => 2, 2 => 0], Solver::one(['A', 'B', 'C']));
if(count($valid) === count($solutions)) {
return true;
}
}
srand(123);
$this->assertEquals([0 => 2, 1 => 0, 2 => 1], Solver::one(['A', 'B', 'C']));
return false;
})());
}
public function testMass()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment