package com.anthonycr.base47;

import org.junit.Assert;
import org.junit.Test;

import java.math.BigInteger;
import java.security.SecureRandom;

/**
 * Sanity test for Base47 encoding.
 * <p>
 * Created by restainoa on 12/21/16.
 */
public class Base47UnitTest {

    private static final int ITERATIONS = 300;

    private final SecureRandom mRandom = new SecureRandom();

    @Test
    public void testEncode_Decode() throws Exception {
        for (int n = 0; n < ITERATIONS; n++) {
            String randomString = randomString(n);
            String encoded = Base47.encode(randomString.getBytes());
            Assert.assertNotNull(randomString);
            Assert.assertNotNull(encoded);
            Assert.assertNotEquals(randomString, encoded);

            byte[] decoded = Base47.decode(encoded);

            Assert.assertEquals(randomString, new String(decoded));
        }
    }

    private String randomString(int number) {
        return new BigInteger(number, mRandom).toString(32);
    }

}

@@ -118,23 +118,13 @@
 ava.
-security.Secure
+util.
 Rand
@@ -313,22 +313,16 @@
 e final 
-Secure
 Random m
@@ -338,14 +338,8 @@
 new 
-Secure
 Rand
@@ -410,16 +410,130 @@
 ption %7B%0A
+        long start = System.currentTimeMillis();%0A%0A        // Make test deterministic%0A        mRandom.setSeed(0);%0A%0A
         
@@ -960,24 +960,24 @@
 (decoded));%0A
-
         %7D%0A  
@@ -974,16 +974,115 @@
       %7D%0A
+        System.out.println(%22Encode/Decode took: %22 + (System.currentTimeMillis() - start) + %22 ms%22);%0A
     %7D%0A%0A 

Make unit test deterministic