Commits

Sungchul Park committed a0a3830

RationalTest에 expect 적용

Comments (0)

Files changed (1)

test/scala/_homework/fupfin/ch4/RationalTest.scala

 package _homework.fupfin.ch4
 
-import org.junit.Test;
-import org.junit.Assert._;
-import org.hamcrest.CoreMatchers._;
-
-import _homework.fupfin.ch4.Rational;
+import org.junit.Test
+import tools.cmd.Spec
+import org.junit.Assert._
+import org.hamcrest.CoreMatchers._
+import org.scalatest.matchers.ShouldMatchers._
 
 class RationalTest {
 
   def testNewInstance() {
     val rational = Rational(1, 2)
 
-    assert(rational.denominator == 2)
-    assert(rational.numerator == 1)
+    expect(2) { rational.denominator }
+    expect(1) { rational.numerator }
   }
   
-  @Test(expected=classOf[java.lang.IllegalArgumentException])
+  //@Test(expected=classOf[java.lang.IllegalArgumentException])
+  @Test
   def testZeroNumerator() {
-      val rational = Rational(100, 0)
+      intercept[java.lang.IllegalArgumentException] { new Rational(100, 0) }
   }
-  
+
   @Test
   def testEquivalency() {
       assert(Rational(1,1) == Rational(1,1))
     assert(rational == Rational(3, 5))
   }
 
-  @Test
-  def testSimpleAddWithDiffDenominator() {
+  @Test                                                                                              def testSimpleAddWithDiffDenominator() {
     var rational = Rational(1, 3)
     rational = rational + Rational(1, 2)