Luninariel

EntropyTests

Oct 10th, 2018
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.76 KB | None | 0 0
  1. package edu.missouriwestern.noynaert.csc254;
  2.  
  3. import static org.junit.Assert.*;
  4.  
  5. import org.junit.Test;
  6.  
  7. /**
  8.  * Unit test for simple App.
  9.  */
  10. public class EntropyTest
  11. {
  12.     static final double DELTA = 0.000001;
  13.     static String[] argsA = {"abc.txt"};
  14.     static String[] argsB = {"abc", "def"};
  15.     static String[] argsC = {};
  16.     static String[] argsD = {"123.txt", "abc"};
  17.  
  18.  
  19.  
  20.     @Test
  21.     public void log10() {
  22.         assertEquals(3.0, Entropy.log10(1000.0),DELTA);
  23.         assertEquals(2.0, Entropy.log10(100.0),DELTA);
  24.         assertEquals(1.0, Entropy.log10(10), DELTA);
  25.         assertEquals(0.0, Entropy.log10(1), DELTA);
  26.         assertEquals(-1.0, Entropy.log10(0.1), DELTA);
  27.         assertEquals(-2.0, Entropy.log10(0.01), DELTA);
  28.         assertEquals(-3.0, Entropy.log10(0.001), DELTA);
  29.         assertEquals(.30102999566, Entropy.log10(2.0), DELTA);
  30.         assertEquals(1.3424226808222062, Entropy.log10(22.0), DELTA);
  31.  
  32.         assertEquals(1.50514997, Entropy.log10(32.0),DELTA);
  33.         assertEquals(0.17609125, Entropy.log10(1.5), DELTA);
  34.         assertEquals(-.30102999, Entropy.log10(0.5), DELTA);
  35.         //Note these last 3 tests
  36.         assertEquals(0.497149506, Entropy.log10(Math.PI), DELTA);
  37.         assertEquals(Double.NEGATIVE_INFINITY, Entropy.log10(0), DELTA);
  38.         assertEquals(Double.NaN, Entropy.log10(-10), DELTA);
  39.         assertEquals(Double.NaN , Entropy.log10(-0.100), DELTA);
  40.  
  41.     }
  42.     @Test
  43.     public void getFileNameFromArgs(){
  44.         assertEquals("abc.txt", Entropy.getFileNameFromArgs(argsA));
  45.         assertEquals("abc", Entropy.getFileNameFromArgs(argsB));
  46.         assertEquals("input.txt", Entropy.getFileNameFromArgs(argsC));
  47.         assertEquals("123.txt", Entropy.getFileNameFromArgs(argsD));
  48.  
  49.     }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment