/*
 * ice4j, the OpenSource Java Solution for NAT and Firewall Traversal.
 *
 * Copyright @ 2015 Atlassian Pty Ltd
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.ice4j.ice;

import static org.junit.Assert.*;

import org.junit.*;

public class NetworkUtilsTest
{
    @Test
    public void testIpv6StringToBytes()
    {
        byte[] addr = NetworkUtils.strToIPv6("::12");
        assertNotNull(addr);
        assertEquals(18, addr[15]);

        addr = NetworkUtils.strToIPv6("[::12]");
        assertNotNull(addr);
        assertEquals(18, addr[15]);

        addr = NetworkUtils.strToIPv6("::12%1");
        assertNotNull(addr);
        assertEquals(18, addr[15]);

        addr = NetworkUtils.strToIPv6("[::12%1]");
        assertNotNull(addr);
        assertEquals(18, addr[15]);

        assertNull(NetworkUtils.strToIPv6("[::12]%1"));
    }
}

@@ -782,16 +782,1208 @@
 sTest%0A%7B%0A
+    @Test%0A    public void testIpv4StringToBytes()%0A    %7B%0A        byte%5B%5D addr = NetworkUtils.strToIPv4(%221%22);%0A        assertArrayEquals(new byte%5B%5D%7B0, 0, 0, 1%7D, addr);%0A%0A        addr = NetworkUtils.strToIPv4(%221.2%22);%0A        assertArrayEquals(new byte%5B%5D%7B1, 0, 0, 2%7D, addr);%0A%0A        addr = NetworkUtils.strToIPv4(%221.2.3%22);%0A        assertArrayEquals(new byte%5B%5D%7B1, 2, 0, 3%7D, addr);%0A%0A        addr = NetworkUtils.strToIPv4(%221.2.3.4%22);%0A        assertArrayEquals(new byte%5B%5D%7B1, 2, 3, 4%7D, addr);%0A%0A        assertNull(NetworkUtils.strToIPv4(%22%22));%0A        assertNull(NetworkUtils.strToIPv4(%22-1%22));%0A        assertNull(NetworkUtils.strToIPv4(%221.-2%22));%0A        assertNull(NetworkUtils.strToIPv4(%22-1.2%22));%0A        assertNull(NetworkUtils.strToIPv4(%221.-2.3%22));%0A        assertNull(NetworkUtils.strToIPv4(%221.2.-3%22));%0A        assertNull(NetworkUtils.strToIPv4(%22-1.2.3%22));%0A        assertNull(NetworkUtils.strToIPv4(%221.-2.3.4%22));%0A        assertNull(NetworkUtils.strToIPv4(%221.2.-3.4%22));%0A        assertNull(NetworkUtils.strToIPv4(%221.2.3.-4%22));%0A        assertNull(NetworkUtils.strToIPv4(%22-1.2.3.4%22));%0A        assertNull(NetworkUtils.strToIPv4(%221.2.3.4.5%22));%0A        assertNull(NetworkUtils.strToIPv4(%221.2.3.256%22));%0A    %7D%0A%0A
     @Tes
@@ -2016,32 +2016,32 @@
 StringToBytes()%0A
-
     %7B%0A        by
@@ -2544,16 +2544,403 @@
 v6(%22
-%5B::12%5D%251
+%22));%0A        assertNull(NetworkUtils.strToIPv6(%22:::%22));%0A        assertNull(NetworkUtils.strToIPv6(%22%5B%5E%22));%0A        assertNull(NetworkUtils.strToIPv6(%22%5B%25%22));%0A        assertNull(NetworkUtils.strToIPv6(%22:?0%22));%0A        assertNull(NetworkUtils.strToIPv6(%22%5B::12%5D%251%22));%0A        assertNull(NetworkUtils.strToIPv6(%22%5B::65536%5D%251%22));%0A        assertNull(NetworkUtils.strToIPv6(%221111:222:3333:4444:5555:6666:7
 %22));

Add unit tests for org.ice4j.ice.NetworkUtilsTest