View Javadoc
1   package emissary.util;
2   
3   import emissary.test.core.junit5.UnitTest;
4   
5   import org.junit.jupiter.api.Test;
6   
7   import static org.junit.jupiter.api.Assertions.assertFalse;
8   import static org.junit.jupiter.api.Assertions.assertTrue;
9   
10  class EntropyTest extends UnitTest {
11  
12      @Test
13      void testEntropy() {
14          assertTrue(
15                  Entropy.checkText(
16                          "Now is the time for all good men to come to the aid of their countries. This is the time of greatest need and we have nothing to fear but a day which will live in Infamy."
17                                  .getBytes()),
18                  "Text check");
19      }
20  
21      @Test
22      void testNonText() {
23          byte[] b = new byte[256];
24          for (int i = 0; i < b.length; i++) {
25              b[i] = (byte) i;
26          }
27          assertFalse(Entropy.checkText(b), "Sequence of bytes is not text");
28      }
29  
30  }