create changelog entry
[debian/openrocket] / core / test / net / sf / openrocket / util / Base64Test.java
1 package net.sf.openrocket.util;
2
3 import java.util.Arrays;
4 import java.util.Random;
5
6 import static org.junit.Assert.*;
7
8 import org.junit.Test;
9
10 public class Base64Test {
11
12         @Test
13         public void oldMainTest() throws Exception {
14
15                 // TODO - this test case should probably be less random and more targeted to
16                 // special cases such as:
17                 // null input
18                 // empty input
19                 // decoding bad string
20                 
21                 Random rnd = new Random();
22
23                 for (int round=0; round < 1000; round++) {
24                         int n = rnd.nextInt(1000);
25                         n = 100000;
26
27                         byte[] array = new byte[n];
28                         rnd.nextBytes(array);
29
30                         String encoded = Base64.encode(array);
31
32                         byte[] decoded = null;
33                         decoded = Base64.decode(encoded);
34
35                         if (!Arrays.equals(array, decoded)) {
36                                 fail("Data differs!  n="+n);
37                         }
38                         System.out.println("n="+n+" ok!");
39
40                 }
41         }
42 }