/* * ScoreHandTest.java * JUnit based test */ package boondock.holdem.Cards; import junit.framework.*; /** * * @author Jonathan O'Keefe * @author Scott Semonian * @author Matt Brinza * @author Hamid R. Tahsildoost * * @author The Boondock Saints * @author No Limit Texas Holdem */ public class ScoreHandTest extends TestCase { public ScoreHandTest( String testName ) { super(testName); } public static Test suite() { TestSuite suite = new TestSuite( ScoreHandTest.class ); return suite; } public static void main( String[] args ) { if (args.length > 0 && args[0].startsWith( "-g") ) { // Graphical junit.swingui.TestRunner.run( ScoreHandTest.class ); } else { // Textual junit.textui.TestRunner runner = new junit.textui.TestRunner(); // get all the tests associated with this class Test test = runner.getTest( ScoreHandTest.class.getName() ); // run the tests TestResult testResult = junit.textui.TestRunner.run( test ); // exit according to whether there were any failures System.exit( testResult.wasSuccessful() ? 0 : 1 ); } } /** Test of getHand method */ public void testGetHand() { System.out.println("testGetHand"); Card test[] = new Card[5]; for(int i = 0; i < 5; i++) { test[i] = new Card(10-i); } ScoreHand s = new ScoreHand(test); assertFalse( test.equals(s.getHand()) ); //False because the hand is ordered in ScoreHand } /** Test of getScore method */ public void testGetScore() { System.out.println("testGetScore"); Card test[] = new Card[5]; int score = 7; for(int i = 0; i < 5; i++) { test[i] = new Card((i*13)%52); } ScoreHand s = new ScoreHand(test); assertEquals( score, (int)s.getScore() ); } /** Test of getHighSet method */ public void testGetHighSet() { System.out.println("testGetHighSet"); Card test[] = new Card[5]; int highSet = 13; for(int i = 0; i < 5; i++) { test[i] = new Card((i*13)%52); } ScoreHand s = new ScoreHand(test); assertEquals( highSet, s.getHighSet() ); } /** Test of getLowSet method */ public void testGetLowSet() { System.out.println("testGetLowSet"); Card test[] = new Card[5]; int lowSet = 0; for(int i = 0; i < 5; i++) { test[i] = new Card((i*13)%52); } ScoreHand s = new ScoreHand(test); assertEquals( lowSet, s.getLowSet() ); } }