fix: Test 코드 변경

This commit is contained in:
2023-03-01 12:38:33 +09:00
parent 4fcafe88a7
commit 294897df54
3 changed files with 67 additions and 23 deletions
+10
View File
@@ -94,12 +94,18 @@ class RandUtil
public function choice(array $items)
{
$keys = array_keys($items);
if(!$keys){
throw new \InvalidArgumentException();
}
$keyIdx = $this->rng->nextInt(count($keys) - 1);
return $items[$keys[$keyIdx]];
}
public function choiceUsingWeight(array $items)
{
if(!$items){
throw new \InvalidArgumentException();
}
$sum = 0;
foreach ($items as $value) {
if ($value <= 0) {
@@ -126,6 +132,10 @@ class RandUtil
public function choiceUsingWeightPair(array $items)
{
if(!$items){
throw new \InvalidArgumentException();
}
$sum = 0;
foreach ($items as [$item, $value]) {
if ($value <= 0) {