package com.m4gik.util;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.notNullValue;

import java.util.Arrays;
import java.util.Collection;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;

/**
 * 
 * This class contains JUnit tests for class {@link Util}.
 * 
 * @author Michał Szczygieł <michal.szczygiel@wp.pl>
 * 
 */
@RunWith(Parameterized.class)
public class UtilTest {

    @Parameterized.Parameters
    public static Collection<Object[]> data() {
        return Arrays
                .asList(new Object[][] {
                        { new String("713502673d67e5fa557629a71d331945")
                                .getBytes() },
                        { new String("6eece560a2e8d6b919e81fe91b0e7156")
                                .getBytes() }, });
    }

    private final Object input;

    public UtilTest(Object input) {
        this.input = input;
    }

    @Test
    public void testInputIsNotNull() {
        assertThat(input, is(notNullValue()));
    }

    @Test(
            expected = NumberFormatException.class)
    public void testThrowIfGivenStingIsNotHexValue() {
        Util.toString((byte[]) input);
    }
}

@@ -71,16 +71,61 @@
 rtThat;%0A
+import static org.hamcrest.Matchers.equalTo;%0A
 import s
@@ -156,16 +156,16 @@
 ers.is;%0A
-
 import s
@@ -359,16 +359,75 @@
 rized;%0A%0A
+import com.m4gik.Haval;%0Aimport com.m4gik.HavalAttributes;%0A%0A
 /**%0A * %0A
@@ -605,16 +605,99 @@
 Test %7B%0A%0A
+    private final static String HASH_RESULT = %22713502673d67e5fa557629a71d331945%22;%0A%0A
     @Par
@@ -1145,24 +1145,24 @@
 ct input) %7B%0A
-
         this
@@ -1176,32 +1176,448 @@
 = input;%0A    %7D%0A%0A
+    @Test%0A    public void testCheckHavalWithUtilStringConversion() %7B%0A        // What%0A        Haval haval = new Haval(%0A                %22The quick brown fox jumps over the lazy dog%22.getBytes(),%0A                HavalAttributes.HAVAL_128_BIT, HavalAttributes.HAVAL_3_ROUND);%0A        // When%0A        String hash = Util.toString(haval.digest());%0A        // Then%0A        assertThat(hash, is(equalTo(HASH_RESULT)));%0A%0A    %7D%0A%0A
     @Test%0A    pu

Add test for parsing hexadecimal value to string.