// Path: src/test/java/com/github/phantomthief/failover/WeighTestUtils.java
// public static boolean checkRatio(int a, int b, int ratio) {
//     return between((double) a / b, (double) ratio - OFFSET, (double) ratio + OFFSET);
// }


import static com.github.phantomthief.failover.WeighTestUtils.checkRatio;
import static java.util.Collections.singleton;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.Test;
import com.google.common.collect.HashMultiset;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Multiset;
package com.github.phantomthief.failover.util;




/**
 * @author w.vela
 * Created on 2019-01-04.
 */
class WeightTest {

    @Test
    void test() {
        Weight<String> weight = new Weight<String>()
                .add("s1", 1)
                .add("s2", 2)
                .add("s3", 3);
        Multiset<String> result = HashMultiset.create();
        for (int i = 0; i < 10000; i++) {
            result.add(weight.get());
        }
// Path: src/test/java/com/github/phantomthief/failover/WeighTestUtils.java
// public static boolean checkRatio(int a, int b, int ratio) {
//     return between((double) a / b, (double) ratio - OFFSET, (double) ratio + OFFSET);
// }


// Path: src/test/java/com/github/phantomthief/failover/util/WeightTest.java
import static com.github.phantomthief.failover.WeighTestUtils.checkRatio;
import static java.util.Collections.singleton;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.Test;
import com.google.common.collect.HashMultiset;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Multiset;

package com.github.phantomthief.failover.util;




/**
 * @author w.vela
 * Created on 2019-01-04.
 */
class WeightTest {

    @Test
    void test() {
        Weight<String> weight = new Weight<String>()
                .add("s1", 1)
                .add("s2", 2)
                .add("s3", 3);
        Multiset<String> result = HashMultiset.create();
        for (int i = 0; i < 10000; i++) {
            result.add(weight.get());
        }
        assertTrue(checkRatio(result.count("s2"), result.count("s1"), 2));