Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.11 KB | None | 0 0
  1. package edu.ucsb.cs56.W11.syassami.lab05;
  2. import org.junit.Test;
  3. import static org.junit.Assert.assertEquals;
  4.  
  5. /**
  6.  * The test class Card, to test the CardTest class
  7.  *
  8.  * @author Phill Conrad, and Shayan Yassami
  9.  * @version lab05 for CS56, Winter 2011
  10.  * @see CardTest
  11.  */
  12. public class Card
  13. {
  14.     // define a static final (a constant) for error tolerance
  15.     // we'll pass this as the last value of every assertEquals()
  16.     // call that is done on double values to allow for roundoff error
  17.    
  18.    public static final double TOL = 0.00001;
  19.    
  20.    @Test public void testNoArgConstructor()
  21.     {
  22.         // the no arg constructor should give us zero for
  23.         // both imaginary and real parts
  24.         CardTest c = new CardTest();
  25.         assertEquals(0.0,c.getReal(),TOL);
  26.         assertEquals(0.0,c.getImag(),TOL);
  27.    
  28.     }
  29.    
  30.    @Test public void testTwoArgConstructor()
  31.    {
  32.         // the no arg constructor should give us zero for
  33.         // both imaginary and real parts
  34.         CardTest c = new CardTest( 1.2, -3.4 );
  35.         assertEquals( 1.2, c.getReal(), TOL);
  36.         assertEquals( -3.4, c.getImag(), TOL);
  37.     }
  38.  
  39.    @Test public void testSetters()
  40.    {
  41.        // the no arg constructor should give us zero for
  42.        // both imaginary and real parts
  43.        CardTest c = new CardTest();
  44.        c.setReal(-3.4);
  45.        c.setImag(1.2);
  46.        assertEquals( -3.4, c.getReal(), TOL);
  47.        assertEquals( 1.2, c.getImag(), TOL);
  48.    }
  49.    
  50.    
  51.    @Test public void testToString1()
  52.     {
  53.         CardTest c = new CardTest();
  54.         assertEquals("0.0 + 0.0i",c.toString());
  55.     }
  56.    
  57.    @Test public void testToString2()
  58.    {
  59.        // the no arg constructor should give us zero for
  60.        // both imaginary and real parts
  61.        CardTest c = new CardTest(1.2, -3.4);
  62.        assertEquals("1.2 + -3.4i",c.toString());
  63.    }
  64.    
  65.    @Test public void testToString3()
  66.     {
  67.         // the no arg constructor should give us zero for
  68.         // both imaginary and real parts
  69.         CardTest c = new CardTest(2.0, 3.0);
  70.         assertEquals("2.0 + 3.0i",c.toString());
  71.     }
  72.    
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement