• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Scala JUnitRunner类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Scala中org.scalatest.junit.JUnitRunner的典型用法代码示例。如果您正苦于以下问题:Scala JUnitRunner类的具体用法?Scala JUnitRunner怎么用?Scala JUnitRunner使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了JUnitRunner类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Scala代码示例。

示例1: URIUtilsSpec

//设置package包名称以及导入依赖的类
package com.pygmalios.reactiveinflux.impl

import java.net.URI

import org.junit.runner.RunWith
import org.scalatest.FlatSpec
import org.scalatest.junit.JUnitRunner

@RunWith(classOf[JUnitRunner])
class URIUtilsSpec extends FlatSpec {
  behavior of "appendPath"

  it should "strip /" in {
    assert(URIUtils.appendPath(new URI("http://x/"), "/a").toString == "http://x/a")
  }

  behavior of "queryToString"

  it should "create empty query string" in {
    assert(URIUtils.queryToString() == "")
  }

  it should "create query string with single item" in {
    assert(URIUtils.queryToString("a" -> "b") == "?a=b")
  }

  it should "create query string with two items" in {
    assert(URIUtils.queryToString("a" -> "b", "c" -> "d") == "?a=b&c=d")
  }
} 
开发者ID:pygmalios,项目名称:reactiveinflux,代码行数:31,代码来源:URIUtilsSpec.scala


示例2: PascalSuite

//设置package包名称以及导入依赖的类
package recfun

import org.scalatest.FunSuite

import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner

@RunWith(classOf[JUnitRunner])
class PascalSuite extends FunSuite {
  import Main.pascal
  test("pascal: col=0,row=2") {
    assert(pascal(0,2) === 1)
  }

  test("pascal: col=1,row=2") {
    assert(pascal(1,2) === 2)
  }

  test("pascal: col=1,row=3") {
    assert(pascal(1,3) === 3)
  }
} 
开发者ID:vincenzobaz,项目名称:Functional-Programming-in-Scala,代码行数:23,代码来源:PascalSuite.scala


示例3: CountChangeSuite

//设置package包名称以及导入依赖的类
package recfun

import org.scalatest.FunSuite

import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner

@RunWith(classOf[JUnitRunner])
class CountChangeSuite extends FunSuite {
  import Main.countChange
  test("countChange: example given in instructions") {
    assert(countChange(4,List(1,2)) === 3)
  }

  test("countChange: sorted CHF") {
    assert(countChange(300,List(5,10,20,50,100,200,500)) === 1022)
  }

  test("countChange: no pennies") {
    assert(countChange(301,List(5,10,20,50,100,200,500)) === 0)
  }

  test("countChange: unsorted CHF") {
    assert(countChange(300,List(500,5,50,100,20,200,10)) === 1022)
  }
} 
开发者ID:vincenzobaz,项目名称:Functional-Programming-in-Scala,代码行数:27,代码来源:CountChangeSuite.scala


示例4: CountChangeSuite

//设置package包名称以及导入依赖的类
package recfun

import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
import org.scalatest.{FunSuite, ShouldMatchers}

@RunWith(classOf[JUnitRunner])
class CountChangeSuite extends FunSuite with ShouldMatchers {

  import Week1.countChange

  test("countChange: example given in instructions") {
    countChange(4, List(1, 2)) should be(3)
  }

  test("countChange: sorted CHF") {
    countChange(300, List(5, 10, 20, 50, 100, 200, 500)) should be(1022)
  }

  test("countChange: no pennies") {
    countChange(301, List(5, 10, 20, 50, 100, 200, 500)) should be(0)
  }

  test("countChange: unsorted CHF") {
    countChange(300, List(500, 5, 50, 100, 20, 200, 10)) should be(1022)
  }
} 
开发者ID:letalvoj,项目名称:progfun_assignments,代码行数:28,代码来源:CountChangeSuite.scala


示例5: BalanceSuite

//设置package包名称以及导入依赖的类
package functions

import org.scalatest.FunSuite

import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner

@RunWith(classOf[JUnitRunner])
class BalanceSuite extends FunSuite {
  import Main.balance

  test("balance: '(if (zero? x) max (/ 1 x))' is balanced") {
    assert(balance("(if (zero? x) max (/ 1 x))".toList))
  }

  test("balance: 'I told him ...' is balanced") {
    assert(balance("I told him (that it's not (yet) done).\n(But he wasn't listening)".toList))
  }

  test("balance: ':-)' is unbalanced") {
    assert(!balance(":-)".toList))
  }

  test("balance: counting is not enough") {
    assert(!balance("())(".toList))
  }
} 
开发者ID:mumukiller,项目名称:scala-course-one,代码行数:28,代码来源:BalanceSuite.scala


示例6: ChannelCollisionCheckerTest

//设置package包名称以及导入依赖的类
package net.xylophones.frogger

import net.xylophones.frogger.test.FroggerTestSugar
import org.junit.runner.RunWith
import org.scalatest.{BeforeAndAfterEach, FunSuite, Matchers}
import org.scalatest.junit.JUnitRunner

@RunWith(classOf[JUnitRunner])
class ChannelCollisionCheckerTest extends FunSuite with Matchers with FroggerTestSugar with BeforeAndAfterEach {

  test("ChannelCollisionChecker detects when landing on a cell") {
    val tiledImage = createTiledImage(10, 10)
    val sprite = createSprite(5, 5)
    val channel = new Channel(Array(Array(Tile(0, 0, CellType.Landable))), 0, tiledImage)
    val chPosition = Vector(10, 10)
    val sPosition = Vector(10, 10)

    val result = ChannelCollisionChecker.isLanding(channel, chPosition, sprite, sPosition)

    result shouldBe true
  }

  test("ChannelCollisionChecker detects deadly collisions") {
    val tiledImage = createTiledImage(16, 16)
    val sprite = createSprite(8, 8)
    val channel = new Channel(Array(Array(Tile(0, 0, CellType.Deadly))), 0, tiledImage)
    val chPosition = Vector(10, 10)
    val sPosition = Vector(10, 10)

    val result = ChannelCollisionChecker.isDeadlyCollision(channel, chPosition, sprite, sPosition)

    result shouldBe true
  }

} 
开发者ID:wjsrobertson,项目名称:scalajs-frogger,代码行数:36,代码来源:ChannelCollisionCheckerTest.scala


示例7: VisualizationTest

//设置package包名称以及导入依赖的类
package observatory


import org.junit.runner.RunWith
import org.scalatest.FunSuite
import org.scalatest.junit.JUnitRunner
import org.scalatest.prop.Checkers
import observatory.Visualization._
import observatory.Extraction._

@RunWith(classOf[JUnitRunner])
class VisualizationTest extends FunSuite with Checkers {

  test("should interpolate color correctly") {
    val c = interpolateColor(List((0.0, Color(255, 0, 0)), (2.147483647E9, Color(0, 0, 255))), 5.3687091175E8)

    assert(c.red === 191)
    assert(c.green === 0)
    assert(c.blue === 64)
  }

  test("exceeding the greatest value of a color scale should return the color associated with the greatest value") {
    val c = interpolateColor(List((-1.0,Color(255, 0, 0)), (15.39640384017234, Color(0,0,255))), 25.39640384017234)

    assert(c.red === 0)
    assert(c.green === 0)
    assert(c.blue === 255)
  }

  test("should predicate temperature correctly") {
    val t1 = predictTemperature(List((Location(0, 0), 10), (Location(-45, 90), 40)), Location(0, 0.001))
    val t2 = predictTemperature(List((Location(0, 0), 10), (Location(-45, 90), 40)), Location(-45, 90.001))
    val t3 = predictTemperature(List((Location(0, 0), 10), (Location(-45, 90), 40)), Location(-45, 90))

    println(t1)
    println(t2)

    assert(t3 === 40)
  }

  test("should output a image by given year correctly") {
    val colors: List[(Double, Color)] = List((60.0, Color(255, 255, 255)), (32.0, Color(255, 0, 0)), (12.0, Color(255, 255, 0)),
                                             (0, Color(0, 255, 255)), (-15.0, Color(0, 0, 255)), (-27.0, Color(255, 0, 255)),
                                             (-50.0, Color(33, 0, 107)), (-60.0, Color(0, 0, 0)))
    val locations = locationYearlyAverageRecords(locateTemperatures(1986, "/stations.csv", "/1986.csv"))
    //val locations = List((Location(0, 0), 10d), (Location(-45, 90), 40d))
    val img = visualize(locations, colors)
    img.output(new java.io.File("output.png"))
  }
} 
开发者ID:syhan,项目名称:coursera,代码行数:51,代码来源:VisualizationTest.scala


示例8: ExtractionTest

//设置package包名称以及导入依赖的类
package observatory

import org.junit.runner.RunWith
import org.scalatest.FunSuite
import org.scalatest.junit.JUnitRunner

@RunWith(classOf[JUnitRunner])
class ExtractionTest extends FunSuite {

  test("locateTemperature should work with given year") {
    val temp = Extraction.locateTemperatures(1986, "/stations.csv", "/1986.csv")
    assert(temp.size == 2429828)
  }

  test("locationYearlyAverageRecords should work with given year") {
    val temp = Extraction.locateTemperatures(1986, "/stations.csv", "/1986.csv")
    val avg = Extraction.locationYearlyAverageRecords(temp)

    assert(avg.size == 8755)
  }
  
} 
开发者ID:syhan,项目名称:coursera,代码行数:23,代码来源:ExtractionTest.scala


示例9: ParallelParenthesesBalancingSuite

//设置package包名称以及导入依赖的类
package reductions

import java.util.concurrent._
import scala.collection._
import org.scalatest.FunSuite
import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
import common._

import ParallelParenthesesBalancing._

@RunWith(classOf[JUnitRunner])
class ParallelParenthesesBalancingSuite extends FunSuite {

  test("balance should work for empty string") {
    def check(input: String, expected: Boolean) =
      assert(balance(input.toArray) == expected,
        s"balance($input) should be $expected")

    check("", true)
  }

  test("balance should work for string of length 1") {
    def check(input: String, expected: Boolean) =
      assert(balance(input.toArray) == expected,
        s"balance($input) should be $expected")

    check("(", false)
    check(")", false)
    check(".", true)
  }

  test("balance should work for string of length 2") {
    def check(input: String, expected: Boolean) =
      assert(balance(input.toArray) == expected,
        s"balance($input) should be $expected")

    check("()", true)
    check(")(", false)
    check("((", false)
    check("))", false)
    check(".)", false)
    check(".(", false)
    check("(.", false)
    check(").", false)


  }

  test("parallel balance should work for string of any length") {
    assert(!parBalance(")(".toArray, 1))
    assert(parBalance("()".toArray, 1))
    assert(parBalance("((()))".toArray, 1))


  }


} 
开发者ID:syhan,项目名称:coursera,代码行数:60,代码来源:ParallelParenthesesBalancingSuite.scala


示例10: BagSpecs

//设置package包名称以及导入依赖的类
package de.htwg.se.SevenSteps.model.bag.basicImpl

import org.junit.runner.RunWith
import org.scalatest.Matchers._
import org.scalatest._
import org.scalatest.junit.JUnitRunner
import scala.collection.mutable.ListBuffer

@RunWith(classOf[JUnitRunner])
class BagSpecs extends WordSpec {
  def getBag: Bag = Bag(Vector(), Vector("a", "b"))
  "A Bag" should {
    "have a insert function" in {
      val bag = getBag
      bag.insert('a')
      bag.insert('b')
      bag.insert('c')
      bag.bag should be(ListBuffer("a", "b", "c"))
    }
    "have a reset function" in {
      val bag = getBag
      bag.insert('a')
      bag.reset.bag should be(ListBuffer())
    }
    "have a draw function" in {
      val bag = getBag
      bag.insert('a')
      bag.get() should be(Some('a'))
      bag.get() should be(None)
    }
    "can fillUp with the colors" in {
      val bag = getBag
      bag.fillup()
    }
    "can get the stone number" in {
      val bag = getBag
      bag.getStoneNumber should be(0)
      bag.insert('a')
      bag.getStoneNumber should be(1)
    }
    "have a toXML functions" in {
      val bag = getBag
      bag.insert('a')
      bag.insert('b')
      bag.insert('c')
      bag.toXML().toString() should be("<alles a='<blub bag2=\"a\"></blub><blub bag2=\"b\"></blub><blub" +
        " bag2=\"c\"></blub>' b='<bag col=\"a\"></bag><bag col=\"b\"></bag>'></alles>")
    }
  }
} 
开发者ID:GrimmT,项目名称:de.htwg.se.SevenSteps,代码行数:51,代码来源:BagSpecs.scala


示例11: CellSpec

//设置package包名称以及导入依赖的类
package de.htwg.se.SevenSteps.model.grid.basicImpl

import org.junit.runner.RunWith
import org.scalatest.Matchers._
import org.scalatest._
import org.scalatest.junit.JUnitRunner

@RunWith(classOf[JUnitRunner])
class CellSpec extends WordSpec {
  "A Cell" should {
    val cell = Cell('a', 2)
    "have a color" in {
      cell.color should be('a')
    }
    "have a height" in {
      cell.height should be(2)
    }
    "generate a string in the form" in {
      cell.toString should be("a 2")
    }
    "have a toXML function in the form" in {
      cell.toXML().toString() should be("<cell colorCell=\"a\" height=\"2\"></cell>")

    }
  }
} 
开发者ID:GrimmT,项目名称:de.htwg.se.SevenSteps,代码行数:27,代码来源:CellSpec.scala


示例12: RoundCompleteCountdownUpdaterTest

//设置package包名称以及导入依赖的类
package net.xylophones.planetoid.game.logic

import net.xylophones.planetoid.game.logic.ModelTestObjectMother._
import net.xylophones.planetoid.game.model.{GamePhysics, GameEvent, RoundCountdownTimer, GameModel}
import org.junit.runner.RunWith
import org.mockito.Mockito._
import org.scalatest.mock.MockitoSugar
import org.scalatest.{Matchers, FunSuite}
import org.scalatest.junit.JUnitRunner


@RunWith(classOf[JUnitRunner])
class RoundCompleteCountdownUpdaterTest extends FunSuite with Matchers with MockitoSugar {

  val currentTimeSource = mock[CurrentTimeSource]

  val underTest = new RoundCompleteCountdownUpdater(currentTimeSource)

  test("counter gets decremented when exists") {
      // given
      val model = GameModel(createDummyPlanet(), createDummyPlayers(), roundEndTimer = Some(RoundCountdownTimer(0, 1000, 600)))
      when(currentTimeSource.currentTime()).thenReturn(1599)

      // when
      val result = underTest.update(resultFromModel(model), new GamePhysics(), null)

      // then
      result.model.roundEndTimer.get.remainingTimeMs shouldBe 1
    }

} 
开发者ID:wjsrobertson,项目名称:planetoid3d,代码行数:32,代码来源:RoundCompleteCountdownUpdaterTest.scala


示例13: GameCollisionUpdaterTest

//设置package包名称以及导入依赖的类
package net.xylophones.planetoid.game.logic

import net.xylophones.planetoid.game.maths.Vector3D
import net.xylophones.planetoid.game.model._
import net.xylophones.planetoid.game.logic.ModelTestObjectMother._
import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
import org.scalatest.{FunSuite, Matchers}
import net.xylophones.planetoid.game.logic.ModelTestObjectMother._

@RunWith(classOf[JUnitRunner])
class GameCollisionUpdaterTest extends FunSuite with Matchers {

  val underTest = new GameCollisionUpdater(new CollisionCalculator)

  test("collision between player1 and planet is detected") {
    
    val player1 = Player(createRocketAt(Vector3D(1000, 1000, 0)), numLives = 1)
    val player2 = Player(createRocketAt(Vector3D(10, 10, 0)), numLives = 1)
    val physics = new GamePhysics()
    val model = GameModel(createDummyPlanet(), Players(player1, player2))

    // when
    val result = underTest.update(resultFromModel(model), physics, Vector.empty)

    // then
    val newModel = result.model
    val events = result.events

    newModel.players.p1 shouldBe player1
    newModel.players.p2 shouldBe player2
    events should not contain (GameEvent.Player2LoseLife)
    events should not contain (GameEvent.Player1LoseLife)
    events should not contain (GameEvent.PlayerLoseLife)
  }
} 
开发者ID:wjsrobertson,项目名称:planetoid3d,代码行数:37,代码来源:GameCollisionUpdaterTest.scala


示例14: ConfigParserTest

//设置package包名称以及导入依赖的类
package cz.alenkacz.db.postgresscala

import java.util.concurrent.TimeUnit

import com.github.mauricio.async.db.Configuration
import com.github.mauricio.async.db.pool.PoolConfiguration
import com.typesafe.config.ConfigFactory
import cz.alenkacz.db.postgresscala.ConfigParser.PostgresConfiguration
import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
import org.scalatest.{FlatSpec, Matchers}

import scala.concurrent.duration._
import scala.concurrent.duration.Duration

@RunWith(classOf[JUnitRunner])
class ConfigParserTest extends FlatSpec with Matchers {
  private val config = ConfigFactory.load("parser-test.conf")

  "Postgres configuration" should "be loaded from connection string" in {
    val actual = ConfigParser.parse(config.getConfig("connection-string"))
    val expected = PostgresConfiguration(Configuration("admin", "localhost", 5432, Some("admin"), Some("test_db")), Duration(5, TimeUnit.SECONDS), None)

    actual should be(expected)
  }

  it should "throw exception when connection string is missing" in {
    assertThrows[InvalidConfigurationException](ConfigParser.parse(config.getConfig("missing-connection-string")))
  }

  it should "parse full config" in {
    val actual = ConfigParser.parse(config.getConfig("full-config"))
    val expected = PostgresConfiguration(Configuration("admin", "localhost", 5432, Some("admin"), Some("test_db"), maximumMessageSize = 167, connectTimeout = 888 seconds, testTimeout = 777 seconds, queryTimeout = Some(666 seconds)), Duration(5, TimeUnit.SECONDS), Some(PoolConfiguration(3, 5000, 10)))

    actual should be(expected)
  }

  it should "not return pooled connection by default" in {
    val actual = ConfigParser.parse(config.getConfig("without-pooling"))

    actual.poolConfiguration should be(None)
  }
} 
开发者ID:alenkacz,项目名称:postgres-scala,代码行数:44,代码来源:ConfigParserTest.scala


示例15: SqlStringInterpolatorTest

//设置package包名称以及导入依赖的类
package cz.alenkacz.db.postgresscala

import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
import org.scalatest.{FlatSpec, Matchers}
import cz.alenkacz.db.postgresscala._

@RunWith(classOf[JUnitRunner])
class SqlStringInterpolatorTest extends FlatSpec with Matchers  {
  "Interpolated sql string" should "be correcly parsed" in {
    val a = "value"
    val actual = sql"SELECT * FROM table WHERE a=$value"

    actual should be(new SqlQuery("SELECT * FROM table WHERE a=?", Seq(value)))
  }

  it should "interpolate also queries with list as parameter" in {
    val value = List("a", "b")
    val actual = sql"SELECT * FROM table WHERE a IN ($value)"

    actual should be(new SqlQuery("SELECT * FROM table WHERE a IN (?, ?)", Seq("a", "b")))
  }

  it should "interpolate also queries with empty list as parameter" in {
    val value = List.empty
    val actual = sql"INSERT INTO table (a) VALUES ($value)"

    actual should be(new SqlQuery("INSERT INTO table (a) VALUES (?)", Seq("{}")))
  }
} 
开发者ID:alenkacz,项目名称:postgres-scala,代码行数:31,代码来源:SqlStringInterpolatorTest.scala


示例16: ParallelParenthesesBalancingSuite

//设置package包名称以及导入依赖的类
package reductions

import java.util.concurrent._
import scala.collection._
import org.scalatest.FunSuite
import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
import common._

import ParallelParenthesesBalancing._

@RunWith(classOf[JUnitRunner])
class ParallelParenthesesBalancingSuite extends FunSuite {

  test("balance should work for empty string") {
    def check(input: String, expected: Boolean) =
      assert(balance(input.toArray) == expected,
        s"balance($input) should be $expected")

    check("", true)
  }

  test("balance should work for string of length 1") {
    def check(input: String, expected: Boolean) =
      assert(balance(input.toArray) == expected,
        s"balance($input) should be $expected")

    check("(", false)
    check(")", false)
    check(".", true)
  }

  test("balance should work for string of length 2") {
    def check(input: String, expected: Boolean) =
      assert(balance(input.toArray) == expected,
        s"balance($input) should be $expected")

    check("()", true)
    check(")(", false)
    check("((", false)
    check("))", false)
    check(".)", false)
    check(".(", false)
    check("(.", false)
    check(").", false)
    check("(((()()())).", false)
    check("(())))(()()())).", false)
    check("(())(()()()).", true)
    check("(((())()()()())).", true)
    check("(((((()()()())))()())).", true)
  }


} 
开发者ID:federicobozzini,项目名称:coursera-parprog1,代码行数:55,代码来源:ParallelParenthesesBalancingSuite.scala


示例17: CountChangeSuite

//设置package包名称以及导入依赖的类
package recfun

import org.scalatest.FunSuite


import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner

@RunWith(classOf[JUnitRunner])
class CountChangeSuite extends FunSuite {
  import Main.countChange
  test("countChange: example given in instructions") {
    assert(countChange(4,List(1,2)) === 3)
  }

  test("countChange: sorted CHF") {
    assert(countChange(300,List(5,10,20,50,100,200,500)) === 1022)
  }

  test("countChange: no pennies") {
    assert(countChange(301,List(5,10,20,50,100,200,500)) === 0)
  }

  test("countChange: unsorted CHF") {
    assert(countChange(300,List(500,5,50,100,20,200,10)) === 1022)
  }

} 
开发者ID:tklo,项目名称:coursera-scala,代码行数:29,代码来源:CountChangeSuite.scala


示例18: RulesSpec

//设置package包名称以及导入依赖的类
package hanabi

import state._
import org.scalatest.mockito.MockitoSugar
import org.scalatest.BeforeAndAfter
import org.junit.runner.RunWith
import org.scalatest.OneInstancePerTest
import org.scalatest.FlatSpec
import org.scalatest.Matchers
import org.scalatest.junit.JUnitRunner
import hanabi._
import hanabi.ai._
import org.scalatest.prop.PropertyChecks

@RunWith(classOf[JUnitRunner])
class RulesSpec extends FlatSpec with Matchers with MockitoSugar with OneInstancePerTest with BeforeAndAfter
    with PropertyChecks with HanabiDomain {
  import SimpleRules._
  import Cards._

  "simple rules" should "have proper number of cards" in {
    forAll { c: Card =>
      whenever(c.level == 1) {
        count(c) shouldBe 3
      }
    }
    forAll { c: Card =>
      whenever(c.level == 5) {
        count(c) shouldBe 1
      }
    }
    forAll { c: Card =>
      whenever(c.level > 1 && c.level < 5) {
        count(c) shouldBe 2
      }
    }
  }

  implicit override val generatorDrivenConfig = PropertyCheckConfiguration(
    minSuccessful = 100,
    maxDiscardedFactor = 15)
} 
开发者ID:wl-seclin-hashcode,项目名称:hanabi,代码行数:43,代码来源:RulesSpec.scala


示例19: HandSpec

//设置package包名称以及导入依赖的类
package hanabi

import state._

import org.scalatest.mockito.MockitoSugar
import org.scalatest.BeforeAndAfter
import org.junit.runner.RunWith
import org.scalatest.OneInstancePerTest
import org.scalatest.FlatSpec
import org.scalatest.Matchers
import org.scalatest.junit.JUnitRunner
import hanabi._
import hanabi.Card._
import hanabi.ai._
import SimpleRules._
import Cards._

@RunWith(classOf[JUnitRunner])
class HandSpec extends FlatSpec
    with Matchers with MockitoSugar with OneInstancePerTest with BeforeAndAfter {

  "a Hand" should "convert color hints to clues" in {
    val h = Hand(2 R, 2 G, 3 B, 1 Y)
    val (clued, clues) = h.hint(Blue)
    h.clues shouldBe empty
    clued.clues shouldBe (Vector(ColorClue(Blue, 2)))
    clues shouldBe (Vector(ColorClue(Blue, 2)))
  }

  it should "convert level hints to clues" in {
    val h = Hand(2 R, 2 G, 3 B, 1 Y)
    val (clued, clues) = h.hint(2)
    clued.clues shouldBe (Vector(LevelClue(2, 0), LevelClue(2, 1)))
    clues shouldBe (Vector(LevelClue(2, 0), LevelClue(2, 1)))
  }

} 
开发者ID:wl-seclin-hashcode,项目名称:hanabi,代码行数:38,代码来源:HandSpec.scala


示例20: QuickCheckBinomialHeap

//设置package包名称以及导入依赖的类
package quickcheck

import org.scalatest.FunSuite
import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner

import org.scalatest.prop.Checkers
import org.scalacheck.Arbitrary._
import org.scalacheck.Prop
import org.scalacheck.Prop._

import org.scalatest.exceptions.TestFailedException

object QuickCheckBinomialHeap extends QuickCheckHeap with BinomialHeap

@RunWith(classOf[JUnitRunner])
class QuickCheckSuite extends FunSuite with Checkers {
  def checkBogus(p: Prop) {
    var ok = false
    try {
      check(p)
    } catch {
      case e: TestFailedException =>
        ok = true
    }
    assert(ok, "A bogus heap should NOT satisfy all properties. Try to find the bug!")
  }

  test("Binomial heap satisfies properties.") {
    check(new QuickCheckHeap with quickcheck.test.BinomialHeap)
  }

  test("Bogus (1) binomial heap does not satisfy properties.") {
    checkBogus(new QuickCheckHeap with quickcheck.test.Bogus1BinomialHeap)
  }

  test("Bogus (2) binomial heap does not satisfy properties.") {
    checkBogus(new QuickCheckHeap with quickcheck.test.Bogus2BinomialHeap)
  }

  test("Bogus (3) binomial heap does not satisfy properties.") {
    checkBogus(new QuickCheckHeap with quickcheck.test.Bogus3BinomialHeap)
  }

  test("Bogus (4) binomial heap does not satisfy properties.") {
    checkBogus(new QuickCheckHeap with quickcheck.test.Bogus4BinomialHeap)
  }

  test("Bogus (5) binomial heap does not satisfy properties.") {
    checkBogus(new QuickCheckHeap with quickcheck.test.Bogus5BinomialHeap)
  }
} 
开发者ID:alvsanand,项目名称:scala_specialization_coursera,代码行数:53,代码来源:QuickCheckSuite.scala



注:本文中的org.scalatest.junit.JUnitRunner类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Scala Route类代码示例发布时间:2022-05-23
下一篇:
Scala Eventually类代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap