Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package edu.ucsb.cs56.W11.syassami.lab05;
- import org.junit.Test;
- import static org.junit.Assert.assertEquals;
- /**
- * The test class Card, to test the CardTest class
- *
- * @author Phill Conrad, and Shayan Yassami
- * @version lab05 for CS56, Winter 2011
- * @see CardTest
- */
- public class Card
- {
- // define a static final (a constant) for error tolerance
- // we'll pass this as the last value of every assertEquals()
- // call that is done on double values to allow for roundoff error
- public static final double TOL = 0.00001;
- @Test public void testNoArgConstructor()
- {
- // the no arg constructor should give us zero for
- // both imaginary and real parts
- CardTest c = new CardTest();
- assertEquals(0.0,c.getReal(),TOL);
- assertEquals(0.0,c.getImag(),TOL);
- }
- @Test public void testTwoArgConstructor()
- {
- // the no arg constructor should give us zero for
- // both imaginary and real parts
- CardTest c = new CardTest( 1.2, -3.4 );
- assertEquals( 1.2, c.getReal(), TOL);
- assertEquals( -3.4, c.getImag(), TOL);
- }
- @Test public void testSetters()
- {
- // the no arg constructor should give us zero for
- // both imaginary and real parts
- CardTest c = new CardTest();
- c.setReal(-3.4);
- c.setImag(1.2);
- assertEquals( -3.4, c.getReal(), TOL);
- assertEquals( 1.2, c.getImag(), TOL);
- }
- @Test public void testToString1()
- {
- CardTest c = new CardTest();
- assertEquals("0.0 + 0.0i",c.toString());
- }
- @Test public void testToString2()
- {
- // the no arg constructor should give us zero for
- // both imaginary and real parts
- CardTest c = new CardTest(1.2, -3.4);
- assertEquals("1.2 + -3.4i",c.toString());
- }
- @Test public void testToString3()
- {
- // the no arg constructor should give us zero for
- // both imaginary and real parts
- CardTest c = new CardTest(2.0, 3.0);
- assertEquals("2.0 + 3.0i",c.toString());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement