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

Scala ShouldMatchers类代码示例

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

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



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

示例1: StackSpec

//设置package包名称以及导入依赖的类
import org.scalatest.FlatSpec
import org.scalatest.matchers.ShouldMatchers

import java.util.Stack
import ppl.dsl.deliszt.datastruct.scala.{Mesh, MeshLoader}

class StackSpec extends FlatSpec with ShouldMatchers {
  "The MeshLoader" should "load succesfully" in {
    val path = System.getProperty("java.library.path")
    println("Path:")
    println(path)

    val cfg = getClass.getResource("/liszt.cfg").getPath()
    println("Liszt CFG")
    println(cfg)

    try {
      MeshLoader.init(cfg)
    }
    catch {
      case e:java.lang.UnsatisfiedLinkError => {println(e); fail}
    }
  }
  
  it should "load a mesh into Mesh" in {
    Mesh.mesh should not be (null)
    Mesh.loader should not be (null)
  }
  
  it should "store itself into Mesh" in {
    Mesh.loader should not be (null)
  }
  
  it should "have a non-empty mesh" in {
    Mesh.mesh.nvertices should be > 0
    Mesh.mesh.nfaces should be > 0
    Mesh.mesh.ncells should be > 0
    Mesh.mesh.nedges should be > 0
  }
} 
开发者ID:leratojeffrey,项目名称:OptiSDR-Compiler,代码行数:41,代码来源:LoaderTest.scala


示例2: CucumberSteps

//设置package包名称以及导入依赖的类
import cucumber.api.scala.{EN, ScalaDsl}
import org.scalatest.matchers.ShouldMatchers

class CucumberSteps extends ScalaDsl with EN with ShouldMatchers {

  private var givenCalled = false
  private var whenCalled = false

  Given("""^A SBT project$""") {
    givenCalled = true
  }

  When("""^I run the cucumber goal$""") {
    whenCalled = true
  }

  Then("""^Cucumber is executed against my features and step definitions$""") {
    givenCalled should be (true)
    whenCalled should be (true)
  }
} 
开发者ID:ralreiroe,项目名称:embarcadero,代码行数:22,代码来源:CucumberSteps.scala


示例3: SortingSpec

//设置package包名称以及导入依赖的类
package org.invisibletech.scalabyexample

import org.scalatest.FunSpec
import org.scalatest.matchers.ShouldMatchers

class SortingSpec extends FunSpec with ShouldMatchers {
  describe ("myInsertionSort") {
    it ("be okay with empty lists") {
        val a = Array[Int]()
        Sorting myInsertionSort a
        a should equal (Array[Int]())
    }

    it ("be okay with crazy lists") {
        val a = Array[Int](2, 300, 1, -10, 444, 2 , 2, 444, 10000, 0 , 30)
        Sorting myInsertionSort a
        a should equal (Array[Int](-10, 0, 1, 2, 2, 2, 30, 300, 444, 444, 10000))
    }

    it ("match output from author's version") {
        val a = Array[Int](2, 300, 1, -10, 444, 2 , 2, 444, 10000, 0 , 30)
        Sorting myInsertionSort a
        val b = Array[Int](2, 300, 1, -10, 444, 2 , 2, 444, 10000, 0 , 30)
        Sorting insertionSort b
        a should equal (b)
    }

    it ("match output of nonidiomatic quick  sort") {
        val a = Array[Int](2, 300, 1, -10, 444, 2 , 2, 444, 10000, 0 , 30)
        Sorting myInsertionSort a
        val b = Array[Int](2, 300, 1, -10, 444, 2 , 2, 444, 10000, 0 , 30)
        Sorting nonidiotmaticQuickSort b
        a should equal (b)
    }
  }

  describe("Idiomatic Quick Sort Works") {
    it ("be okay with empty lists") {
        val a = Array[Int]()
        Sorting idiomaticQuickSort a
        a should equal (Array[Int]())
    }

    it ("be okay with crazy lists") {
        val a = Array[Int](2, 300, 1, -10, 444, 2 , 2, 444, 10000, 0 , 30)
        Sorting idiomaticQuickSort a
        (Sorting idiomaticQuickSort a) should equal (Array[Int](-10, 0, 1, 2, 2, 2, 30, 300, 444, 444, 10000))
    }

  }

} 
开发者ID:InvisibleTech,项目名称:scala-by-example,代码行数:53,代码来源:SortingSpec.scala


示例4: ApplicationIT

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

import org.scalatest._
import org.scalatest.matchers.ShouldMatchers

import play.api.test._
import play.api.test.Helpers._


class ApplicationIT extends FunSpec with ShouldMatchers {

  describe ("Application") {

    it ("should send 404 on a bad request") {
      running(FakeApplication()) {
        route(FakeRequest(GET, "/boum")) should be (None)
      }
    }

    it ("should render the index page") {
      running(FakeApplication()) {
        val home = route(FakeRequest(GET, "/")).get

        status(home) should be (OK)
        contentType(home) should be (Some("text/html"))
        contentAsString(home) should include ("Your new application is ready.")
      }
    }
  }
} 
开发者ID:phosphene,项目名称:test-play-frame-app,代码行数:31,代码来源:ApplicationIT.scala


示例5: QGramsTest

//设置package包名称以及导入依赖的类
package de.fuberlin.wiwiss.silk.execution.methods

import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
import org.scalatest.FlatSpec
import org.scalatest.matchers.ShouldMatchers
import de.fuberlin.wiwiss.silk.entity.Path
import scala._

@RunWith(classOf[JUnitRunner])
class QGramsTest extends FlatSpec with ShouldMatchers {

  "QGrams" should "generate the correct sublists" in {
    subLists("Miller", q = 2, t = 0.8) should equal (millerSubLists4)
    subLists("Miller", q = 2, t = 0.75) should equal (millerSubLists3)
  }

  private def subLists(str: String, q: Int, t: Double) = {
    QGrams(Path("a", Nil), Path("b", Nil), q, t).generateSubLists(str)
  }

  // All sub-lists with minimum length 5
  val millerSubLists5 =
    Set(
      Seq("mi", "il", "ll", "le", "er")
    )

  // All sub-lists with minimum length 4
  val millerSubLists4 = millerSubLists5 ++
    Set(
      Seq("il", "ll", "le", "er"),
      Seq("mi", "ll", "le", "er"),
      Seq("mi", "il", "le", "er"),
      Seq("mi", "il", "ll", "er"),
      Seq("mi", "il", "ll", "le")
    )

  // All sub-lists with minimum length 3
  val millerSubLists3 = millerSubLists4 ++
    Set(
      Seq("ll", "le", "er"),
      Seq("il", "le", "er"),
      Seq("il", "ll", "er"),
      Seq("il", "ll", "le"),
      Seq("mi", "le", "er"),
      Seq("mi", "ll", "er"),
      Seq("mi", "ll", "le"),
      Seq("mi", "il", "er"),
      Seq("mi", "il", "le"),
      Seq("mi", "il", "ll")
    )
} 
开发者ID:petrovskip,项目名称:silk.2.6-GenLinkSA,代码行数:53,代码来源:QGramsTest.scala


示例6: SparqlRestrictionBuilderTest

//设置package包名称以及导入依赖的类
package de.fuberlin.wiwiss.silk.util.convert

import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
import org.scalatest.FlatSpec
import org.scalatest.matchers.ShouldMatchers
import de.fuberlin.wiwiss.silk.entity.{Path, Restriction, SparqlRestriction}
import de.fuberlin.wiwiss.silk.entity.Restriction.Condition
import de.fuberlin.wiwiss.silk.config.Prefixes

@RunWith(classOf[JUnitRunner])
class SparqlRestrictionBuilderTest extends FlatSpec with ShouldMatchers {

  implicit val prefixes: Prefixes = Map(
    "rdf" -> "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
    "dbpedia" -> "http://dbpedia.org/ontology/",
    "lgdo" -> "http://linkedgeodata.org/ontology/"
  )

  val builder = new SparqlRestrictionBuilder("a")

  "SparqlRestrictionBuilder" should "convert single conditions" in {
    val restriction = Restriction(Some(Condition.resolve(Path.parse("?a/rdf:type"), "dbpedia:Settlement")))
    builder(restriction).toSparqlQualified should equal("{?a rdf:type dbpedia:Settlement} .")
  }
} 
开发者ID:petrovskip,项目名称:silk.2.6-GenLinkSA,代码行数:27,代码来源:SparqlRestrictionBuilderTest.scala


示例7: SparqlRestrictionTest

//设置package包名称以及导入依赖的类
package de.fuberlin.wiwiss.silk.util.sparql

import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
import org.scalatest.FlatSpec
import org.scalatest.matchers.ShouldMatchers
import de.fuberlin.wiwiss.silk.entity.SparqlRestriction
import de.fuberlin.wiwiss.silk.config.Prefixes

@RunWith(classOf[JUnitRunner])
class SparqlRestrictionTest extends FlatSpec with ShouldMatchers {

  implicit val prefixes: Prefixes = Map(
    "rdf" -> "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
    "dbpedia" -> "http://dbpedia.org/ontology/",
    "freebase" -> "http://rdf.freebase.com/ns/"
  )

  "SparqlRestriction" should "convert prefixed URIS correctly" in {
    SparqlRestriction.fromSparql("a", "?a rdf:type freebase:musicartist").toSparql should
      equal("?a <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://rdf.freebase.com/ns/musicartist> .")

    SparqlRestriction.fromSparql("a", "?a rdf:type freebase:musicartist . ?a rdf:type freebase:musicartist2").toSparql should
      equal("?a <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://rdf.freebase.com/ns/musicartist> . ?a <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://rdf.freebase.com/ns/musicartist2> .")

    SparqlRestriction.fromSparql("a", "?a rdf:type freebase:music.artist").toSparql should
      equal("?a <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://rdf.freebase.com/ns/music.artist> .")
  }
} 
开发者ID:petrovskip,项目名称:silk.2.6-GenLinkSA,代码行数:30,代码来源:SparqlRestrictionTest.scala


示例8: SparqlPathBuilderTest

//设置package包名称以及导入依赖的类
package de.fuberlin.wiwiss.silk.util.sparql

import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
import org.scalatest.FlatSpec
import org.scalatest.matchers.ShouldMatchers
import de.fuberlin.wiwiss.silk.entity.Path
import de.fuberlin.wiwiss.silk.testutil.equalIgnoringWhitespace

@RunWith(classOf[JUnitRunner])
class SparqlPathBuilderTest extends FlatSpec with ShouldMatchers {

  // Example properties
  val p1 = "<1>"
  val p2 = "<2>"

  "SparqlPathBuilder" should "build SPARQL patterns for simple paths" in {
    build(s"?a/$p1") should be(equalIgnoringWhitespace(s"OPTIONAL { ?s $p1 ?v0 . }"))
    build(s"?a\\$p1") should be(equalIgnoringWhitespace(s"OPTIONAL { ?v0 $p1 ?s . }"))
  }

  "SparqlPathBuilder" should "include Filter statements" in {
    build(s"?a/<1>[<2> = <3>]") should be(equalIgnoringWhitespace("OPTIONAL { ?s <1> ?v0 . ?v0 <2> ?f1 . FILTER(?f1 = <3>). }"))
  }

  def build(path: String) = SparqlPathBuilder(Seq(Path.parse(path)))

} 
开发者ID:petrovskip,项目名称:silk.2.6-GenLinkSA,代码行数:29,代码来源:SparqlPathBuilderTest.scala


示例9: IndexTest

//设置package包名称以及导入依赖的类
package de.fuberlin.wiwiss.silk.entity

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

@RunWith(classOf[JUnitRunner])
class IndexTest extends FlatSpec with ShouldMatchers {

  "Index" should "combine single dimension indices disjunctively by offseting the second index values" in {
    Index.oneDim(Set(0), 10) disjunction Index.oneDim(Set(0), 10) should equal (Index.oneDim(Set(0, 10), 20))
    Index.oneDim(Set(1,4), 5) disjunction Index.oneDim(Set(3,9), 10) should equal (Index.oneDim(Set(1,4,8,14), 15))
    Index.oneDim(Set(0,99), 100) disjunction Index.oneDim(Set(0,9), 10) should equal (Index.oneDim(Set(0,99,100,109), 110))
  }

  "Index" should "combine multi dimensional indices disjunctively by offseting the second index values" in {
    val i1 = Index.multiDim(Set(Seq(0,0)), Seq(10,20))
    val i2 = Index.multiDim(Set(Seq(0,0),Seq(99,199)), Seq(100,200))
    val i3 = Index.multiDim(Set(Seq(0,0),Seq(10,20),Seq(109,219)), Seq(110,220))

    i1 disjunction i2 should equal (i3)
  }

  "Index" should "combine single and multi dimension indices disjunctively by padding the single dimension index" in {
    val i1 = Index.oneDim(Set(0), 10)
    val i2 = Index.multiDim(Set(Seq(0,0)), Seq(20,40))

    val r1 = Index.multiDim(Set(Seq(0,0),Seq(10,1)), Seq(30,41))
    val r2 = Index.multiDim(Set(Seq(0,0),Seq(20,40)), Seq(30,41))

    i1 disjunction i2 should equal (r1)
    i2 disjunction i1 should equal (r2)
  }
} 
开发者ID:petrovskip,项目名称:silk.2.6-GenLinkSA,代码行数:36,代码来源:IndexTest.scala


示例10: ApplicationIT

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

import org.scalatest._
import org.scalatest.matchers.ShouldMatchers

import play.api.test._
import play.api.test.Helpers._


class ApplicationIT extends FunSpec with ShouldMatchers {

  describe ("Application") {

    it ("should send 404 on a bad request") {
      running(FakeApplication()) {
        val bad = route(FakeRequest(GET, "/boum")).get
        status(bad) should be (NOT_FOUND)
      }
    }

    it ("should render the index page") {
      running(FakeApplication()) {
        val home = route(FakeRequest(GET, "/")).get

        status(home) should be (OK)
        contentType(home) should be (Some("text/html"))
        contentAsString(home) should include ("Your new application is ready.")
      }
    }
  }
} 
开发者ID:phosphene,项目名称:play2.4-scalatest-demo,代码行数:32,代码来源:ApplicationIT.scala


示例11: output

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

import org.scalatest._
import org.scalatest.matchers.ShouldMatchers

trait InterceptedIO extends IO {
  var messages: StringBuffer = new StringBuffer()
  def output: String = messages.toString
  
  override def print(message: String) = messages.append(s"${message}")
  override def println(message: String) = print(s"{message}\n")
}

trait QuitCommand extends InterceptedIO {
  val commands = List("Q").toIterator
}

trait NoQuitCommand extends InterceptedIO {
  val commands = List("A", "B", "C").toIterator
}

class UISpec extends FlatSpec with ShouldMatchers {
  "UI" should "quit on command 'Q'" in {
    val ui = new UI with QuitCommand
    ui.run
    ui.output should include ("Welcome; enter command: program finished")
  }

  it should "not quit when there's no 'Q' command" in {
    val ui = new UI with NoQuitCommand
    ui.run
    ui.output should not include ("program finished")
  }
} 
开发者ID:RogerSep,项目名称:huge-drawing-app,代码行数:35,代码来源:UISpec.scala


示例12: ListSuite

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


import org.scalatest.FunSuite
import org.scalatest.matchers.ShouldMatchers

import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
@RunWith(classOf[JUnitRunner])
class ListSuite  extends FunSuite with ShouldMatchers {

  test("An empty list should be empty") {
    List() should be ('empty)
    Nil should be ('empty)
  }

  test("A non-empty list should not be empty") {
    List(1, 2, 3) should not be ('empty)
    List("fee", "fie1", "foe", "fum") should not be ('empty)
  }

  test("A list's length should equal the number of elements it contains") {
    List() should have length (0)
    List(1, 2) should have length (2)
    List("fee", "fie", "foe", "fum") should have length (4)
  }
} 
开发者ID:wjingyao2008,项目名称:firsttry,代码行数:28,代码来源:ListSuite.scala


示例13: PrettyPrinterTest

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

import Pretty._

import org.scalatest.matchers.ShouldMatchers
import org.scalatest.Suite

class PrettyPrinterTest extends Suite with ShouldMatchers {

  def testBool1() {
    val ast : Value[_] = VLit(GBool(true))
    pprint(ast) should be ("true")
  }
  
  def testBool2() {
    val ast : Value[_] = VLit(GBool(false))
    pprint(ast) should be ("false")
  }
} 
开发者ID:janduracz,项目名称:acumen-dev,代码行数:20,代码来源:PrettyPrinterTest.scala


示例14: SpotSelectorTest

//设置package包名称以及导入依赖的类
package org.dbpedia.spotlight.spot

import org.dbpedia.spotlight.exceptions.ConfigurationException
import org.dbpedia.spotlight.model.Factory
import org.scalatest._
import org.scalatest.matchers.ShouldMatchers

class SpotSelectorTest extends FlatSpec with ShouldMatchers {

    "SpotSelector Factory" should "create a simple selector" in {
        Factory.SpotSelector.fromName("ShortSurfaceFormSelector")
    }

    it should "create one selector from a list" in {
        Factory.SpotSelector.fromNameList("AtLeastOneNounSelector").size==1
    }

    it should "create multiple selectors" in {
        Factory.SpotSelector.fromNameList("ShortSurfaceFormSelector,AtLeastOneNounSelector").size==2
    }

    it should "throw an exception when a name does not exist" in {
        evaluating { Factory.SpotSelector.fromName("fff") } should produce [ConfigurationException]
    }

    it should "throw an exception when the name is empty" in {
        evaluating { Factory.SpotSelector.fromName("") } should produce [IllegalArgumentException]
    }

} 
开发者ID:dbpedia-spotlight,项目名称:dbpedia-spotlight-model,代码行数:31,代码来源:SpotSelectorTest.scala


示例15: PigHbaseLinggleSpec

//设置package包名称以及导入依赖的类
import org.scalatest._
import org.scalatest.matchers.ShouldMatchers
import org.apache.pig.data.Tuple
import org.apache.pig.data.TupleFactory

class PigHbaseLinggleSpec extends FlatSpec with ShouldMatchers {
  import udf._
    val vn = new ValidateNgram
    val tuple = TupleFactory.getInstance.newTuple(1)
  "ValidateNgram" should "correctly validate ngrams" in {
    tuple.set(0, "hello world")
    vn.exec(tuple) should be === true
    tuple.set(0, "- hey")
    vn.exec(tuple) should be === true
    tuple.set(0, "hey yo .")
    vn.exec(tuple) should be === true
    tuple.set(0, "$ hello world")
    vn.exec(tuple) should be === false
  }


} 
开发者ID:d2207197,项目名称:linggle-hbase-pig,代码行数:23,代码来源:PigHbaseLinggleSpec.scala



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Scala MqttClient类代码示例发布时间:2022-05-23
下一篇:
Scala RawHeader类代码示例发布时间: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