testing1/drumb_test7.scala
changeset 281 87b9e3e2c1a7
parent 248 1616d06a0893
--- a/testing1/drumb_test7.scala	Tue Oct 29 11:11:44 2019 +0000
+++ b/testing1/drumb_test7.scala	Tue Oct 29 14:12:24 2019 +0000
@@ -1,9 +1,24 @@
+/*
+def myassert(cond : => Boolean) = {
+  try {
+    assert(cond)
+  } catch { 
+    case _ : Throwable => System.exit(1)
+  }
+}
+*/
 
-assert(investment(List("GOOG", "AAPL", "BIDU"), 2000 to 2000, 100) == 100)
-assert(investment(List("GOOG", "AAPL", "BIDU"), 2000 to 2001, 100) == 27)
-assert(investment(List("GOOG", "AAPL", "BIDU"), 2000 to 2002, 100) == 42)
-assert(investment(List("GOOG", "AAPL", "BIDU"), 2000 to 2003, 100) == 27)
-assert(investment(List("GOOG", "AAPL", "BIDU"), 2000 to 2004, 100) == 38)
-assert(investment(List("GOOG", "AAPL", "BIDU"), 2000 to 2005, 100) == 113)
-assert(investment(List("GOOG", "AAPL", "BIDU"), 2000 to 2006, 100) == 254)
-assert(investment(List("GOOG", "AAPL", "BIDU"), 2000 to 2007, 100) == 349)
+assert(CW6b.investment(List("GOOG", "AAPL", "BIDU"), 2000 to 2000, 100) == 100)
+assert(CW6b.investment(List("GOOG", "AAPL", "BIDU"), 2000 to 2001, 100) == 27)
+assert(CW6b.investment(List("GOOG", "AAPL", "BIDU"), 2000 to 2002, 100) == 42)
+assert(CW6b.investment(List("GOOG", "AAPL", "BIDU"), 2000 to 2003, 100) == 27)
+assert(CW6b.investment(List("GOOG", "AAPL", "BIDU"), 2000 to 2004, 100) == 38)
+
+// 113
+assert((112 to 114).contains(CW6b.investment(List("GOOG", "AAPL", "BIDU"), 2000 to 2005, 100)))
+// 254
+assert((252 to 256).contains(CW6b.investment(List("GOOG", "AAPL", "BIDU"), 2000 to 2006, 100)))
+// 349
+assert((346 to 352).contains(CW6b.investment(List("GOOG", "AAPL", "BIDU"), 2000 to 2007, 100)))
+//11504
+assert((11389 to 11619).contains(CW6b.investment(List("GOOG", "AAPL", "BIDU"), 1990 to 2017, 100)))