// Path: commons-ip-math/src/main/java/com/github/jgonian/ipmath/Ipv6Range.java
// public static Ipv6Range parse(String range) {
//     int idx = range.indexOf(DASH);
//     if (idx != -1) {
//         Ipv6 start = Ipv6.parse(range.substring(0, idx));
//         Ipv6 end = Ipv6.parse(range.substring(idx + 1, range.length()));
//         return new Ipv6Range(start, end);
//     } else {
//         return parseCidr(range);
//     }
// }


import org.junit.Test;
import java.util.ArrayList;
import java.util.List;
import static com.github.jgonian.ipmath.Ipv6Range.parse;
import static org.junit.Assert.*;
/**
 * The MIT License (MIT)
 *
 * Copyright (c) 2011-2017, Yannis Gonianakis
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */
package com.github.jgonian.ipmath;




public class ConservativePrefixFinderTest {

    private final ConservativePrefixFinder subject = ConservativePrefixFinder.newInstance();

    @Test
    public void shouldReturnNullIfRequestedPrefixIsTooBig() {
        assertNull(subject.findPrefixOrNull(9, in("::/10, 2::/20, 3::/30")));
    }

    @Test
    public void shouldFindExactMatch() {
// Path: commons-ip-math/src/main/java/com/github/jgonian/ipmath/Ipv6Range.java
// public static Ipv6Range parse(String range) {
//     int idx = range.indexOf(DASH);
//     if (idx != -1) {
//         Ipv6 start = Ipv6.parse(range.substring(0, idx));
//         Ipv6 end = Ipv6.parse(range.substring(idx + 1, range.length()));
//         return new Ipv6Range(start, end);
//     } else {
//         return parseCidr(range);
//     }
// }


// Path: commons-ip-math/src/test/java/com/github/jgonian/ipmath/ConservativePrefixFinderTest.java
import org.junit.Test;
import java.util.ArrayList;
import java.util.List;
import static com.github.jgonian.ipmath.Ipv6Range.parse;
import static org.junit.Assert.*;

/**
 * The MIT License (MIT)
 *
 * Copyright (c) 2011-2017, Yannis Gonianakis
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */
package com.github.jgonian.ipmath;




public class ConservativePrefixFinderTest {

    private final ConservativePrefixFinder subject = ConservativePrefixFinder.newInstance();

    @Test
    public void shouldReturnNullIfRequestedPrefixIsTooBig() {
        assertNull(subject.findPrefixOrNull(9, in("::/10, 2::/20, 3::/30")));
    }

    @Test
    public void shouldFindExactMatch() {
        assertEquals(parse("::/10"), subject.findPrefixOrNull(10, in("::/10, 2::/20, 3::/30")));