Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Korko
SecretSanta.fr
Commits
1c772599
Commit
1c772599
authored
Jan 03, 2017
by
Korko
Browse files
Change solverTest to be cross platform
parent
4b742ecf
Changes
1
Hide whitespace changes
Inline
Side-by-side
tests/SolverTest.php
View file @
1c772599
...
...
@@ -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
()
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment