package com.qmth.boot.test.tools.matcher;

import com.qmth.boot.tools.matcher.IPMatcher;
import org.junit.Test;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

/**
 * Unit test for IPMatcher.
 */
public class IPMatcherTest {

    @Test
    public void testIPMatch() {
        assertTrue(IPMatcher.match("192.168.0.10", "192.168.0.10"));
        assertFalse(IPMatcher.match("192.168.0.10", "192.168.0.100"));
        assertTrue(IPMatcher.match("192.168.0.*", "192.168.0.101"));
        assertFalse(IPMatcher.match("192.168.0.*", "192.168.2.10"));
        assertTrue(IPMatcher.match("192.168.*.10", "192.168.100.10"));
        assertFalse(IPMatcher.match("192.168.*.10", "192.168.100.11"));
        assertTrue(IPMatcher.match("192.168.*.*", "192.168.10.200"));
        assertFalse(IPMatcher.match("192.168.*.*", "192.169.0.10"));
        assertTrue(IPMatcher.match("192.*.*.*", "192.168.10.200"));
        assertFalse(IPMatcher.match("192.*.10.*", "192.169.11.10"));
    }
}
