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

Scala Test类代码示例

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

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



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

示例1: SettingsTest

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

import com.google.appengine.tools.development.testing.LocalDatastoreServiceTestConfig
import com.google.appengine.tools.development.testing.LocalServiceTestHelper
import com.google.gson.JsonObject
import org.junit.{Assert, Test, After, Before}

class SettingsTest {
  val helper = new LocalServiceTestHelper(new LocalDatastoreServiceTestConfig())

  @Before def setUp(): Unit = helper.setUp
  @After def tearDown() = helper.tearDown()

  @Test
  def testSetAndGetSetting = {
    Settings.set("bla", "ble")
    Assert.assertTrue(Settings.get("bla").isDefined)
    Assert.assertEquals("ble", Settings.get("bla").get)
  }

  @Test
  def testFromJson = {
    val json = new JsonObject
    json.addProperty("bla", "ble")
    json.addProperty("ble", "bla")

    Settings.fromJson(json)

    Assert.assertTrue(Settings.get("bla").isDefined)
    Assert.assertEquals("ble", Settings.get("bla").get)

    Assert.assertTrue(Settings.get("ble").isDefined)
    Assert.assertEquals("bla", Settings.get("ble").get)
  }

  @Test
  def asJson = {
    Settings.set("bla", "ble")
    Settings.set("ble", "bla")

    val json = Settings.asJson

    Assert.assertEquals("ble", json.get("bla").getAsString)
    Assert.assertEquals("bla", json.get("ble").getAsString)
  }
} 
开发者ID:erickzanardo,项目名称:spammer,代码行数:47,代码来源:SettingsTest.scala


示例2: es

//设置package包名称以及导入依赖的类
package fr.sysf.sample

import java.time.LocalDate

import fr.sysf.sample.domain.Customer
import fr.sysf.sample.service.CustomerRepository
import org.assertj.core.api.Assertions
import org.assertj.core.api.Assertions.assertThat
import org.junit.Test
import org.junit.runner.RunWith
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner


@RunWith(classOf[SpringJUnit4ClassRunner])
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, classes = Array(classOf[ApplicationConfig]))
//@ContextConfiguration(classes = Array(classOf[ApplicationConfig]))
class CustomerDataTest {

  @Autowired
  private val customerRepository: CustomerRepository = null

  @Test
  def getHello {

    val customer = new Customer()
    customer.firstName = "Anna"
    customer.lastName = "Blum"
    customer.birthDate = LocalDate.of(1965, 2, 7)

    var request = customerRepository.save(customer)

    // getAll before insert
    assertThat(request).isNotNull
    assertThat(request.createdDate).isNotNull
    assertThat(request.updatedDate).isEqualTo(request.createdDate)
    Assertions.assertThat(request.version).isEqualTo(0l)

    request.city = "Paris"
    request = customerRepository.save(request)

    assertThat(request).isNotNull
    Assertions.assertThat(request.createdDate).isNotNull
    Assertions.assertThat(request.city).isEqualTo("Paris")
    Assertions.assertThat(request.version).isEqualTo(1l)


  }
} 
开发者ID:fpeyron,项目名称:sample-scala-mongo-rest,代码行数:52,代码来源:CustomerDataTest.scala


示例3: SampleTest

//设置package包名称以及导入依赖的类
package io.github.nawforce.apexlink

import io.github.nawforce.ApexLink
import org.junit.{Assert, Test}

class SampleTest {

  def sample(path : String) : Unit = {
    Assert.assertEquals(0, ApexLink.run(Array(path)))
  }

  @Test def sample1() : Unit = {
    sample("samples/forcedotcom-enterprise-architecture/src")
  }

  @Test def sample2() : Unit = {
    sample("samples/forcedotcomlabs/chatter-game/src")
  }

  @Test def sample3() : Unit = {
    sample("samples/SalesforceFoundation/Cumulus/src")
  }

  @Test def sample4() : Unit = {
    sample("samples/SalesforceFoundation/HEDAP/src")
  }

  @Test def sample5() : Unit = {
    sample("samples/SalesforceFoundation/CampaignTools/src")
  }

  @Test def sample6() : Unit = {
    sample("samples/SalesforceFoundation/Volunteers-for-Salesforce/src")
  }

  @Test def sample7() : Unit = {
    sample("samples/SalesforceFoundation/Relationships/src")
  }

  @Test def sample8() : Unit = {
    sample("samples/SalesforceFoundation/Households/src")
  }

  @Test def sample9() : Unit = {
    sample("samples/SalesforceFoundation/Recurring_Donations/src")
  }

  @Test def sample10() : Unit = {
    sample("samples/SalesforceFoundation/Contacts_and_Organizations/src")
  }

  @Test def sample11() : Unit = {
    sample("samples/SalesforceFoundation/Affiliations/src")
  }
} 
开发者ID:nawforce,项目名称:ApexLink,代码行数:56,代码来源:SampleTest.scala


示例4: TestCaseClass

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

import org.junit.Test
import shapeless._
import org.fest.assertions.Assertions.assertThat

case class TestCaseClass(f: Float, i: Int)

class UnfixTest {
  @Test def unfixHelperHList(): Unit = {
    val uh = the[UnfixHelper[Int, Any, String :: Int :: HNil]]
    assertThat(uh.functor.map("Hello" :: 4 :: HNil)({ i: Int ? i / 2.0 })).isEqualTo("Hello" :: 2.0 :: HNil)
  }

  @Test def unfixHelperCaseClass(): Unit = {
    val uh = the[UnfixHelper[Float, Any, TestCaseClass]]
    assertThat(uh.functor.map(2f :: 4 :: HNil)(_.toString)).isEqualTo("2.0" :: 4 :: HNil)
  }

  @Test def unfixHelperSealedFamily(): Unit = {
    val uh = the[UnfixHelper[Int, Any, Either[Int, String]] with NonTrivial]
    assertThat(uh.fix(uh.functor.map(uh.unfix(Left(3))) { i: Int ? i + 1 })).isEqualTo(Left(4))
  }
} 
开发者ID:m50d,项目名称:tailchase,代码行数:25,代码来源:UnfixTest.scala


示例5: TailchaseTest

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

import shapeless._
import syntax._
import org.junit.Test
import org.fest.assertions.Assertions.assertThat

class TailchaseTest {
  @Test def cata(): Unit = {
    val l = List(1, 2, 3, 4, 5)
    assertThat(l.cata[Int] {
      case Inl((x: Int) :: (y: Int) :: HNil) ? x + y
      case Inr(_) ? 0
    }).isEqualTo(15)
    assertThat(l.cata[String] {
      case Inl((x: Int) :: (y: String) :: HNil) ? y + x
      case Inr(_) ? ""
    }).isEqualTo("54321")
  }
} 
开发者ID:m50d,项目名称:tailchase,代码行数:21,代码来源:TailchaseTest.scala


示例6: UtilsTest

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

import org.junit.Test
import org.junit.Assert

class UtilsTest {
	@Test
	def testStr2HttpHost1() = {
		val httpHost = HttpTarget("localhost")
		Assert.assertEquals(80, httpHost.port)
		Assert.assertEquals("http", httpHost.scheme)
		Assert.assertEquals("localhost", httpHost.host)
	}
	
	@Test
	def testStr2HttpHost2() = {
		val httpHost = HttpTarget("https://localhost")
		Assert.assertEquals(80, httpHost.port)
		Assert.assertEquals("https", httpHost.scheme)
		Assert.assertEquals("localhost", httpHost.host)
	}
	
	@Test
	def testStr2HttpHost3() = {
		val httpHost = HttpTarget("https://localhost:8443")
		Assert.assertEquals(8443, httpHost.port)
		Assert.assertEquals("https", httpHost.scheme)
		Assert.assertEquals("localhost", httpHost.host)
	}
	
	
	// ignore path
	@Test
	def testStr2HttpHost4() = {
		val httpHost = HttpTarget("https://localhost:8443/")
		Assert.assertEquals(8443, httpHost.port)
		Assert.assertEquals("https", httpHost.scheme)
		Assert.assertEquals("localhost", httpHost.host)
	}
} 
开发者ID:lis0x90,项目名称:httpduplicator,代码行数:41,代码来源:UtilsTest.scala


示例7: Utf8ExtractorTest

//设置package包名称以及导入依赖的类
package sds.classfile.constant_pool

import org.junit.Test
import org.scalatest.Assertions
import sds.classfile.constant_pool.Utf8ValueExtractor.extract

class Utf8ExtractorTest extends Assertions {
    val info: Array[ConstantInfo] = Array(
        new Utf8Info("utf8"), new NumberInfo(ConstantInfo.INTEGER, 0), new NumberInfo(ConstantInfo.FLOAT, 0.0f),
        new NumberInfo(ConstantInfo.LONG, 0L), new NumberInfo(ConstantInfo.DOUBLE, 0.0), new StringInfo(1),
        new HandleInfo(1, 1), new InvokeDynamicInfo(1, 1), new ConstantInfoAdapter(),
        new Utf8Info("java/lang/Object"), new ClassInfo(10), new MemberInfo(ConstantInfo.FIELD, 11, 1),
        new Utf8Info("([[Ljava/util/List;Ljava/lang/System;)V"), new NameAndTypeInfo(1, 13), new TypeInfo(13)
    )

    @Test
    def extractTest(): Unit = {
        assert(extract(info(0), info) === "utf8")
        assert(extract(info(1), info) === "0")
        assert(extract(info(2), info) === "0.0")
        assert(extract(info(3), info) === "0")
        assert(extract(info(4), info) === "0.0")
        assert(extract(info(5), info) === "utf8")
        assert(extract(info(6), info) === "utf8")
        assert(extract(info(7), info) === "utf8")
        intercept[IllegalArgumentException] {
            extract(info(8), info) === ""
        }
        assert(extract(info(10), info) === "Object")
        assert(extract(info(11), info) === "Object.utf8")
        assert(extract(info(13), info) === "utf8|(java.util.List[][],System)void")
        assert(extract(info(14), info) === "(java.util.List[][],System)void")
    }
} 
开发者ID:g1144146,项目名称:sds_for_scala,代码行数:35,代码来源:Utf8ExtractorTest.scala


示例8: AttributeInfoTest

//设置package包名称以及导入依赖的类
package sds.classfile.attribute

import org.junit.Test
import org.scalatest.Assertions
import sds.classfile.constant_pool._

class AttributeInfoTest extends Assertions {
    val info: Array[ConstantInfo] = Array(
        new Utf8Info("utf8"), new NumberInfo(ConstantInfo.INTEGER, 0), new NumberInfo(ConstantInfo.FLOAT, 0.0f),
        new NumberInfo(ConstantInfo.LONG, 0L), new NumberInfo(ConstantInfo.DOUBLE, 0.0), new StringInfo(1),
        new HandleInfo(1, 1), new InvokeDynamicInfo(1, 1), new ConstantInfoAdapter(),
        new Utf8Info("java/lang/Object"), new ClassInfo(10), new MemberInfo(ConstantInfo.FIELD, 11, 1),
        new Utf8Info("([[Ljava/util/List;Ljava/lang/System;)V"), new NameAndTypeInfo(1, 13), new TypeInfo(13)
    )

    @Test
    def constantValueTest(): Unit = {
        val const: ConstantValue = new ConstantValue("Hoge")
        assert(const.toString() === "ConstantValue: Hoge")
    }

    @Test
    def enclosingMethodTest(): Unit = {
        val enc: EnclosingMethod = new EnclosingMethod(11, 13, info)
        val enc2: EnclosingMethod = new EnclosingMethod(11, 0, info)
        assert(enc.toString() === "EnclosingMethod: Object ([[Ljava/util/List;Ljava/lang/System;)V")
        assert(enc2.toString() === "EnclosingMethod: Object ")
    }

    @Test
    def signatureTest(): Unit = {
        val sig: Signature = new Signature("hoge")
        assert(sig.toString() === "Signature: hoge")
    }

    @Test
    def sourceFileTest(): Unit = {
        val source: SourceFile = new SourceFile("Hoge.java")
        assert(source.toString() === "SourceFile: Hoge.java")
    }

    @Test
    def deprecatedTest(): Unit = {
        val dep: Deprecated = new Deprecated();
        assert(dep.toString() === "Deprecated")
    }

    @Test
    def syntheticTest(): Unit = {
        val syn: Synthetic = new Synthetic();
        assert(syn.toString() === "Synthetic")
    }
} 
开发者ID:g1144146,项目名称:sds_for_scala,代码行数:54,代码来源:AttributeInfoTest.scala


示例9: MultiArgsStringBuilderTest

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

import org.junit.Test
import org.scalatest.Assertions
import sds.util.{MultiArgsStringBuilder => Builder}

class MultiArgsStringBuilderTest extends Assertions {
    @Test
    def toStringTest() {
        val b: Builder = new Builder()
        assert(b.toString.equals(""))
        b.append("test")
        assert(b.toString.equals("test"))
        b.append(1)
        assert(b.toString.equals("test1"))
        b.append(1.0)
        assert(b.toString.equals("test11.0"))
        b.append(", ", 1.2, 0.10)
        assert(b.toString.equals("test11.0, 1.20.1"))
    }

    @Test
    def toStringTest2() {
        val b: Builder = new Builder("init")
        assert(b.toString.equals("init"))
    }
} 
开发者ID:g1144146,项目名称:sds_for_scala,代码行数:28,代码来源:MultiArgsStringBuilderTest.scala


示例10: SampleTest

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

import org.junit.Test
import org.schladen.nexus.models.board.{Board, Space, Team}
import org.schladen.nexus.models.game.Game
import org.schladen.nexus.models.player.Player

import play.api.libs.json.Json

class SampleTest extends UnitTest {

  @Test
  def testHello(): Unit = {
    "hello" must include ("lo")
  }

  @Test
  def testGame(): Unit = {
    val spymaster = Player("Alex")
    val guesser = Player("Jasmine")
    val game = Game(spymaster, guesser)

    info(game.toString)

    implicit val playerFormat = Json.format[Player]
    implicit val teamFormat = Json.format[Team]
    implicit val spaceFormat = Json.format[Space]
    implicit val boardFormat = Json.format[Board]
    implicit val gameFormat = Json.format[Game]
    Json.toJson(game)
  }
} 
开发者ID:jtschladen,项目名称:nexus,代码行数:33,代码来源:SampleTest.scala


示例11: StageTest

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

import java.io.File
import java.nio.file.{Files, Paths}

import delorean.FileOps._
import delorean._
import org.apache.commons.io.FileUtils
import org.junit.Assert._
import org.junit.{AfterClass, BeforeClass, Test}

import scala.util.Try

class StageTest {
    @Test
    def stageTest(): Unit = {
        val filesToStage = List("src/test/resources/")
        Stage(filesToStage)
        val tempFile: String = getTempPitstopFileLocation
        assertTrue("_temp file should have been created in Pitstops directory", tempFile.nonEmpty)
    }
}

object StageTest {
    @BeforeClass
    def callToRide(): Unit = {
        // This will make sure it creates all the required files for the test. We are checking for CURRENT_INDICATOR
        // instead of TIME_MACHINE because .tm could be created by config test
        if (!Files.exists(Paths.get(CURRENT_INDICATOR))) new delorean.commands.Ride
    }

    @AfterClass def tearDown(): Unit = {
        Try(FileUtils.deleteDirectory(new File(TIME_MACHINE)))
        Try(Files.delete(Paths.get(getTempPitstopFileLocation)))
    }
} 
开发者ID:durgaswaroop,项目名称:delorean,代码行数:37,代码来源:StageTest.scala


示例12: basicTriangle

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

import org.junit.Test
import org.junit.Assert.assertTrue
import org.junit.Assert.assertEquals


  @Test def basicTriangle(): Unit = {
    assertEquals(Pos(0, 0), t.a)
    assertEquals(Pos(1, 0), t.b)
    assertEquals(Pos(0.5f, (Math.sqrt(3) / 2).toFloat), t.c)
    assertEquals(SColor.White, t.color)
  }

  @Test def siblingsTest(): Unit = {
    assertEquals(List(
      Triangle(Pos(0.25f, 0.4330127f), Pos(0.75f, 0.4330127f), Pos(0.5f, 0.8660254f), SColor(1.0, 1.0, 1.0)),
      Triangle(Pos(0.0f, 0.0f), Pos(0.5f, 0.0f), Pos(0.25f, 0.4330127f), SColor(1.0, 1.0, 1.0)),
      Triangle(Pos(0.5f, 0.0f), Pos(1.0f, 0.0f), Pos(0.75f, 0.4330127f), SColor(1.0, 1.0, 1.0)))
      , t.siblings)
  }

  @Test def allSiblingsAreWhite(): Unit = assertTrue(t.siblings.forall(_.color == SColor.White))

  @Test def centerTriangleIsBlack(): Unit = assertTrue(t.centerT.color == SColor.Black)

  @Test def sierpinski0(): Unit = {
    assertEquals(Sierpinski(List(Triangle(Pos(0.0f, 0.0f), Pos(1.0f, 0.0f), Pos(0.5f, 0.8660254f), SColor(1.0, 1.0, 1.0)))), Sierpinski(Triangle(Pos(0, 0), 1), 0))
  }

  @Test def sierpinski1(): Unit = {
    assertEquals(
      Sierpinski(List(
        Triangle(Pos(0.0f, 0.0f), Pos(1.0f, 0.0f), Pos(0.5f, 0.8660254f), SColor(1.0, 1.0, 1.0)),
        Triangle(Pos(0.5f, 0.0f), Pos(0.75f, 0.4330127f), Pos(0.25f, 0.4330127f), SColor(0.0, 0.0, 0.0)),
        Triangle(Pos(0.25f, 0.4330127f), Pos(0.75f, 0.4330127f), Pos(0.5f, 0.8660254f), SColor(1.0, 1.0, 1.0)),
        Triangle(Pos(0.0f, 0.0f), Pos(0.5f, 0.0f), Pos(0.25f, 0.4330127f), SColor(1.0, 1.0, 1.0)),
        Triangle(Pos(0.5f, 0.0f), Pos(1.0f, 0.0f), Pos(0.75f, 0.4330127f), SColor(1.0, 1.0, 1.0)),
        Triangle(Pos(0.25f, 0.4330127f), Pos(0.75f, 0.4330127f), Pos(0.5f, 0.8660254f), SColor(1.0, 1.0, 1.0)),
        Triangle(Pos(0.0f, 0.0f), Pos(0.5f, 0.0f), Pos(0.25f, 0.4330127f), SColor(1.0, 1.0, 1.0)),
        Triangle(Pos(0.5f, 0.0f), Pos(1.0f, 0.0f), Pos(0.75f, 0.4330127f), SColor(1.0, 1.0, 1.0)))), Sierpinski(Triangle(Pos(0, 0), 1), 1))
  }

  @Test def sierpinski7(): Unit = {
    assertEquals(7652, Sierpinski(Triangle(Pos(0, 0), 1), 7).triangles.length)
  }
} 
开发者ID:rladstaetter,项目名称:sierpinski-assignment,代码行数:48,代码来源:SierpinskiTest.scala


示例13: wordCountTest

//设置package包名称以及导入依赖的类
package com.chapter16.SparkTesting
import org.scalatest.Assertions._
import org.junit.Test
import org.apache.spark.sql.SparkSession

class wordCountTest {
  val spark = SparkSession
    .builder
    .master("local[*]")
    .config("spark.sql.warehouse.dir", "E:/Exp/")
    .appName(s"OneVsRestExample")
    .getOrCreate()
   
    @Test def test() {
      val fileName = "C:/Users/rezkar/Downloads/words.txt"
      val obj = new wordCounterTestDemo()
      assert(obj.myWordCounter(fileName) == 210)
           }
    spark.stop()
} 
开发者ID:PacktPublishing,项目名称:Scala-and-Spark-for-Big-Data-Analytics,代码行数:21,代码来源:wordCountTest.scala


示例14: ScapsServiceIntegrationTest

//设置package包名称以及导入依赖的类
package scaps.eclipse.core.services

import java.io.ByteArrayInputStream

import org.eclipse.core.resources.IResource
import org.eclipse.core.runtime.jobs.IJobChangeListener
import org.eclipse.ui.internal.WorkingSet
import org.junit.Assert._
import org.junit.Test
import org.mockito.Matchers._
import org.mockito.Mockito._
import org.scalaide.core.IScalaProject
import org.scalaide.core.testsetup.TestProjectSetup
import org.junit.Ignore

class ScapsServiceIntegrationTest extends TestProjectSetup("simple-structure-builder") {

  val scapsIndexService = ScapsService.createIndexService
  val scapsSearchService = ScapsService.createSearchService

  @Test
  @Ignore
  def testIndexProject {
    addSourceFile(project)("Calculator.scala", """
      class Home {
        def plus(num1: Int, num2: Int): Int = num1 + num2
      }""")
    val workingSet = new WorkingSet("testing", "testing", Array(project.javaProject))

    // SUT
    val job = scapsIndexService(workingSet)
    job.addJobChangeListener(new IJobChangeListener {
      def aboutToRun(x$1: org.eclipse.core.runtime.jobs.IJobChangeEvent): Unit = {}
      def awake(x$1: org.eclipse.core.runtime.jobs.IJobChangeEvent): Unit = {}
      def done(x$1: org.eclipse.core.runtime.jobs.IJobChangeEvent): Unit = {
        val result = scapsSearchService("Home")
        assertTrue(result.isRight)
      }
      def running(x$1: org.eclipse.core.runtime.jobs.IJobChangeEvent): Unit = {}
      def scheduled(x$1: org.eclipse.core.runtime.jobs.IJobChangeEvent): Unit = {}
      def sleeping(x$1: org.eclipse.core.runtime.jobs.IJobChangeEvent): Unit = {}
    })
  }

  def addSourceFile(project: IScalaProject)(name: String, contents: String) = {
    val folder = project.underlying.getFolder("src")
    if (!folder.exists())
      folder.create(IResource.NONE, true, null)
    val file = folder.getFile(name)
    if (!file.exists()) {
      val source = new ByteArrayInputStream(contents.getBytes())
      file.create(source, IResource.FORCE, null)
    }
  }

} 
开发者ID:scala-search,项目名称:scala-ide-scaps,代码行数:57,代码来源:ScapsServiceIntegrationTest.scala


示例15: ProposicoesServiceTest

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

import com.nakamura.camara.proposicoes.proposicao.ListarProposicoesRequest
import org.apache.spark.sql.{SaveMode, SparkSession}
import org.junit.Test
import org.scalatest.Assertions

class ProposicoesServiceTest extends Assertions {
  private val spark = SparkSession
    .builder()
    .appName("ProposicoesServiceTest")
    .master("local[*]")
    .getOrCreate()
  private val service = new ProposicoesService(spark)

  @Test
  def testListarProposicoes(): Unit = {
    val request = ListarProposicoesRequest(ano = 2017, sigla = "PEC")
    val proposicoesTry = service.listarProposicoes(request)
    assert(proposicoesTry.isSuccess)
    assert(proposicoesTry.get.nonEmpty)
  }

  @Test
  def testListarProposicoesFailure(): Unit = {
    val invalidRequest = ListarProposicoesRequest()
    val proposicoesTry = service.listarProposicoes(invalidRequest)
    assert(proposicoesTry.isFailure)
  }

  @Test
  def testListarSiglasProposicoes(): Unit = {
    val siglasTry = service.listSiglasTipoProposioes()
    assert(siglasTry.isSuccess)
    assert(siglasTry.get.nonEmpty)
  }

  @Test
  def runFetchAndStoreHistoricalData(): Unit = {
    service.fetchAndStoreHistoricalData(2010 to 2017 by 1, SaveMode.Ignore)
  }
} 
开发者ID:akionakamura,项目名称:camara,代码行数:43,代码来源:ProposicoesServiceTest.scala


示例16: MyAdderTreeSuite

//设置package包名称以及导入依赖的类
import org.junit.Assert._
import org.junit.Test
import org.junit.Ignore

import Chisel._
import chiseltemplate.adder.MyAdderTree

class MyAdderTreeSuite extends TestSuite {

  @Test def addTreeTest {
    class MyAdderTreeTests( c : MyAdderTree ) extends Tester(c) {
      poke( c.io.in, (0 until 8).map(BigInt(_)).toArray )
      step(3)
      expect( c.io.out, (0 until 8).reduce(_+_) )
    }
    chiselMainTest(Array("--genHarness", "--compile", "--test", "--backend", "c"), () => {
      Module( new MyAdderTree ) }) { c => new MyAdderTreeTests( c ) }
  }
} 
开发者ID:da-steve101,项目名称:chisel-template,代码行数:20,代码来源:MyAdderTreeSuite.scala


示例17: MyTopLevelModuleSuite

//设置package包名称以及导入依赖的类
// These imports are needed for scala test
import org.junit.Assert._
import org.junit.Test
import org.junit.Ignore

// These are other scala imports
import scala.util.Random
import scala.collection.mutable.ArrayBuffer

// Chisel imports
import Chisel._
import chiseltemplate.MyTopLevelModule


class MyTopLevelModuleSuite extends TestSuite {

  // You can have multiple tests in a test suite
  @Test def topModTest {
    // Put test code here ...
    class MyTopLevelModuleTests( c : MyTopLevelModule ) extends Tester(c) {
      val cycles = 30
      val myRand = new Random
      val inputs = ArrayBuffer.fill( cycles*10 ) { myRand.nextInt(8) }
      var idxInput = 0
      var idxOutput = 0
      poke( c.io.in.valid, true )
      for ( cyc <- 0 until cycles ) {
        poke( c.io.in.bits, inputs.slice(idxInput, idxInput + 10).map(BigInt(_)).toArray )
        if ( peek( c.io.in.ready ) == 1 )
          idxInput = idxInput + 10
        step(1)
        if ( peek( c.io.out.valid ) == 1 ) {
          expect( c.io.out.bits, inputs.slice(idxOutput, idxOutput + 8).reduce(_+_) )
          idxOutput = idxOutput + 8
        }
      }

    }
    chiselMainTest(Array("--genHarness", "--compile", "--test", "--backend", "c"), () => {
      Module( new MyTopLevelModule ) }) { c => new MyTopLevelModuleTests( c ) }
  }
} 
开发者ID:da-steve101,项目名称:chisel-template,代码行数:43,代码来源:MyTopLevelModuleSuite.scala


示例18: VersaillesVariableAnalyzerTest

//设置package包名称以及导入依赖的类
package org.bynar.versailles.xtext.tests

import scala.collection.JavaConversions._
import com.google.inject.Inject
import org.bynar.versailles.xtext.versaillesLang.CompilationUnit
import org.bynar.versailles.xtext.Converter
import org.bynar.versailles.VariableAnalyzer
import org.bynar.versailles.Expression
import org.bynar.versailles.JanusClass
import org.bynar.versailles.Irreversible
import org.junit.Test
import org.junit.runner.RunWith
import org.bynar.versailles.xtext.versaillesLang.BlockStmt
import org.bynar.versailles.Statement
import org.eclipse.xtext.testing.XtextRunner
import org.eclipse.xtext.testing.InjectWith
import org.eclipse.xtext.testing.util.ParseHelper

@RunWith(classOf[XtextRunner])
@InjectWith(classOf[VersaillesLangInjectorProvider])
class VersaillesVariableAnalyzerTest {
	
	@Inject
	val parseHelper: ParseHelper[CompilationUnit] = null
	@Inject
    val converter: Converter = null
    @Inject
    val variableAnalyzer: VariableAnalyzer = null
	
	def doAnalyze(source: String, pattern: Boolean, janusClass: JanusClass, context: variableAnalyzer.Context): (Statement, variableAnalyzer.Context) = {
	    val parsed = parseHelper.parse(source)
	    val converted = converter.fromStatements(parsed.getStatements, parsed)
	    val ctx0 = variableAnalyzer.analyzeDefinitions(converted, context)
	    variableAnalyzer.analyze(converted, pattern, janusClass, ctx0)
	}
	
	@Test
	def testLetLeak() {
	    val (e, ctx) = doAnalyze("let ?z = { let ?x = 1; return 0};", false, Irreversible(), variableAnalyzer.Context(Map.empty))
	    assert(ctx.containsVariable('z))
	    assert(!ctx.containsVariable('x))
	}
	
	@Test
	def testDefLeak() {
	    val (e, ctx) = doAnalyze("def z: T = { let ?x = 1; return 0};", false, Irreversible(), variableAnalyzer.Context(Map.empty))
	    assert(ctx.containsVariable('z))
	    assert(!ctx.containsVariable('x))
	}

	@Test
	def testModuleLeak() {
	    val (e, ctx) = doAnalyze("module M { let ?y = 1; def x: T = y };", false, Irreversible(), variableAnalyzer.Context(Map.empty))
	    assert(ctx.containsVariable('M))
	    assert(!ctx.containsVariable('x))
	    assert(!ctx.containsVariable('y))
	}
} 
开发者ID:stefanbohne,项目名称:bynar,代码行数:59,代码来源:VersaillesVariableAnalyzerTest.scala


示例19: JSDOMNodeJSEnvTest

//设置package包名称以及导入依赖的类
package org.scalajs.jsenv.jsdomnodejs

import org.scalajs.jsenv.test._

import org.junit.Test
import org.junit.Assert._

class JSDOMNodeJSEnvTest extends TimeoutComTests {

  protected def newJSEnv: JSDOMNodeJSEnv = new JSDOMNodeJSEnv()

  @Test
  def historyAPI: Unit = {
    """|console.log(window.location.href);
       |window.history.pushState({}, "", "/foo");
       |console.log(window.location.href);
    """.stripMargin hasOutput
    """|http://localhost/
       |http://localhost/foo
       |""".stripMargin
  }

} 
开发者ID:scala-js,项目名称:scala-js-env-jsdom-nodejs,代码行数:24,代码来源:JSDOMNodeJSEnvTest.scala


示例20: testDefault

//设置package包名称以及导入依赖的类
package io.citrine.theta

import io.citrine.theta.benchmarks.{RandomGenerationBenchmark, StreamBenchmark}
import org.junit.Test
import org.junit.experimental.categories.Category

import scala.util.Random


  @Test
  def testDefault(): Unit = {
    BenchmarkRegistry.getTime("Default")
  }


  @Test
  @Category(Array(classOf[SlowTest]))
  def testConsistencyRandomGeneration(): Unit = {
    (0 until 32).foreach{ i =>
      val theta: Double = Stopwatch.time(RandomGenerationBenchmark.kernel(), benchmark = "RandomGeneration", targetError = 0.01)
      assert(theta < 1.1, s"RandomGeneration benchmark inconsistent (too slow ${theta})")
      assert(theta > 0.9, s"RandomGeneration benchmark inconsistent (too fast ${theta})")
    }
  }

  @Test
  @Category(Array(classOf[SlowTest]))
  def testConsistencyStream(): Unit = {
    val benchmark = new StreamBenchmark()
    benchmark.setup()
    (0 until 8).foreach{ i =>
      val theta: Double = Stopwatch.time(benchmark.kernel(), benchmark = "STREAM", targetError = 0.01)
      assert(theta < 1.1, s"STREAM benchmark inconsistent (too slow on it ${i} (${theta}))")
      assert(theta > 0.9, s"STREAM benchmark inconsistent (too fast on it ${i} (${theta}))")
    }
    benchmark.teardown()
  }
}

object BenchmarkRegistryTest {
  def main(argv: Array[String]): Unit = {
    new BenchmarkRegistryTest().testConsistencyStream()
  }
} 
开发者ID:CitrineInformatics,项目名称:theta,代码行数:45,代码来源:BenchmarkRegistryTest.scala



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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