Created
October 2, 2013 20:04
-
-
Save gfodor/6799699 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Tests the Helper Class functions | |
* | |
* @author [email protected] | |
*/ | |
public class Tester { | |
private static final int TEST_ROLLS = 1000; | |
private static final int DIE_SIZE = 6; | |
public static void main(String[] args) { | |
// Test fibonacci() | |
if (Helper.fibonacci(0) != 0) System.out.println("fibonacci(0) failed."); | |
//if (Helper.fibonacci(1) != 1) System.out.println("fibonacci(0) failed."); | |
//if (Helper.fibonacci(2) != 1) System.out.println("fibonacci(0) failed."); | |
//if (Helper.fibonacci(10) != 55) System.out.println("fibonacci(10) failed."); | |
// Test fibonacciSum() | |
//if (Helper.fibonacciSum(0) != 0) System.out.println("fibonacciSum(0) failed."); | |
//if (Helper.fibonacciSum(1) != 1) System.out.println("fibonacciSum(1) failed."); | |
//if (Helper.fibonacciSum(2) != 2) System.out.println("fibonacciSum(2) failed."); | |
//if (Helper.fibonacciSum(10) != 143) System.out.println("fibonacciSum(10) failed."); | |
// Test dice roll() | |
//int[] roll_results = new int[DIE_SIZE]; | |
//for (int i = 0; i < TEST_ROLLS; i++) { | |
// int result = Helper.roll(DIE_SIZE); | |
// roll_results[result-1]++; | |
//} | |
//System.out.println("Tested dice roll with the following results (these should be roughly equal):"); | |
//for (int i = 1; i <= DIE_SIZE; i++) { | |
// System.out.println(" rolled " + i + " " + roll_results[i-1] + " times"); | |
//} | |
// Arithmetic function initializer | |
//int[] nums = { 4, 83, 43, 27, 54, 95, 72, 22, 15, 11, 60, 22, 14, 18, | |
56, 56, 18, 82, 47, 21, 82, 1, 87, 24, 45, 28, 13, 89, | |
85, 69, 91, 31, 32, 99, 33, 14, 90, 23, 47 }; | |
// Test mean() | |
//if (Helper.mean(nums) != 46) System.out.println("mean(nums) failed."); | |
// Test range() | |
//int[] range = Helper.range(nums); | |
//if (range[0] != 1) System.out.println("range(nums) failed."); | |
//if (range[1] != 99) System.out.println("range(nums) failed."); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment