当前位置: 首页>>代码示例>>Scala>>正文


Scala assertEquals类代码示例

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


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

示例1: FlinkPcapShould

//设置package包名称以及导入依赖的类
package berlin.bbdc.inet.flink.pcap

import org.apache.flink.api.common.typeinfo.TypeInformation
import org.apache.flink.api.java.ExecutionEnvironment
import org.apache.flink.api.scala.DataSet
import berlin.bbdc.inet.flink.pcap.analysers.Analyser
import berlin.bbdc.inet.flink.pcap.analysers.ints.ippacketbytes.IpPacketBytesPerDestIpAnalyser
import berlin.bbdc.inet.flink.pcap.analysers.ints.ippacketbytes.IpPacketBytesPerPortsAnalyser
import berlin.bbdc.inet.flink.pcap.analysers.ints.ippacketbytes.IpPacketBytesPerSrcIpAnalyser

import scala.Tuple2
import org.junit.Assert.assertEquals

class FlinkPcapShould {
  implicit val typeInfo1 = TypeInformation.of(classOf[Int])

  @org.junit.Test
  def analyzeBytesPerSrcIpFrom1000PackagesWith258ResultElements() {
    val resultLength: Long = runAnalysis(new IpPacketBytesPerSrcIpAnalyser).count
    assertEquals(258, resultLength)
  }

  @org.junit.Test
  def analyzeBytesPerDestIpFrom1000PackagesWith250ResultElements() {
    val resultLength: Long = runAnalysis(new IpPacketBytesPerDestIpAnalyser).count
    assertEquals(250, resultLength)
  }

  @org.junit.Test
  def analyzeBytesPerPortsFrom1000PackagesWith363ResultElements() {
    val resultLength: Long = runAnalysis(new IpPacketBytesPerPortsAnalyser).count
    assertEquals(363, resultLength)
  }

  private def runAnalysis(analyser: Analyser[Int]): DataSet[(String, Int)] = {
    FlinkPcap.analyseFile("src/test/resources/200610041400_first1000.dump", 1000, KeyValueSetAnalyser(analyser))
  }
} 
开发者ID:jheyd,项目名称:FlinkPcap,代码行数:39,代码来源:FlinkPcapShould.scala

示例2: 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

示例3: testCase

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


	@Test def testCase() = {
		val tondesueService = new TondeuseService
		val pelouse = Pelouse(Coordonnees(5, 5))

		val tendeuse1 = Tondeuse(Coordonnees(1, 2), Direction.N)
		val commands1: Seq[Commande.Value] = Seq(Commande.G, Commande.A, Commande.G, Commande.A, Commande.G, Commande.A, Commande.G, Commande.A, Commande.A)
		val movedTondeuse1 = commands1.foldLeft(tendeuse1)((accumulator, command)  => tondesueService.moveTondeuse(accumulator, pelouse, command))
		assertEquals(1, movedTondeuse1.coordonnees.x)
		assertEquals(3, movedTondeuse1.coordonnees.y)
		assertEquals(Direction.N, movedTondeuse1.direction)

		val tendeuse2 = Tondeuse(Coordonnees(3, 3), Direction.E)
		val commands2: Seq[Commande.Value] = Seq(Commande.A, Commande.A, Commande.D, Commande.A, Commande.A, Commande.D, Commande.A, Commande.D, Commande.D, Commande.A)
		val movedTondeuse2 = commands2.foldLeft(tendeuse2)((accumulator, command)  => tondesueService.moveTondeuse(accumulator, pelouse, command))
		assertEquals(5, movedTondeuse2.coordonnees.x)
		assertEquals(1, movedTondeuse2.coordonnees.y)
		assertEquals(Direction.E, movedTondeuse2.direction)
	}
} 
开发者ID:HimanshuArora1234,项目名称:MowItNow,代码行数:26,代码来源:MowTest.scala

示例4: NilF

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

import cats.~>
import org.junit.Test
import org.junit.Assert.assertEquals

sealed trait ListF[G[_], A]
case class NilF[G[_], A]() extends ListF[G, A]
case class ConsF[G[_], A](head: A, tail: G[A]) extends ListF[G, A]
object ListF {
  implicit object ListFFunctorK extends FunctorK[ListF] {
    def map[G[_], H[_]](f: G ~> H): ListF[G, ?] ~> ListF[H, ?] =
      Lambda[ListF[G, ?] ~> ListF[H, ?]](_ match {
          case NilF() => NilF()
          case ConsF(head, tail) => ConsF(head, f(tail))
        })
    }
}

class FixKTest {
  type List_[A] = FixK[ListF, A] 
  def nil[A]: List_[A] = NilF[List_, A]()
  def cons[A](head: A, tail: List_[A]): List_[A] = ConsF(head, tail)
  val exampleList = cons(2, cons(1, nil))
  
  @Test def cata(): Unit = {
    val list = exampleList.cata[List](Lambda[ListF[List, ?] ~> List](_ match {
      case NilF() => Nil
      case ConsF(head, tail) => head :: tail
    }))
    assertEquals(List(2, 1), list)
  }
} 
开发者ID:m50d,项目名称:tierney,代码行数:34,代码来源:FixKTest.scala

示例5: IntNilF

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

import cats.derived._
import cats.derived.functor._
import cats.derived.functor.legacy._
import org.junit.Test
import org.junit.Assert.assertEquals
import cats.Functor

sealed trait IntListF[A]
case class IntNilF[A]() extends IntListF[A]
case class IntConsF[A](head: Int, tail: A) extends IntListF[A]

class FixTest {
  type IntList = Fix[IntListF]
  val nil: IntList = IntNilF[IntList]()
  def cons(head: Int, tail: IntList): IntList = IntConsF(head, tail)
  val exampleList = cons(2, cons(1, nil))
  
  @Test def cata(): Unit = {
    val printed = exampleList.cata[String] {
      case IntNilF() => ""
      case IntConsF(i, s) => i + ", " + s
    }
    assertEquals("2, 1, ", printed)
  }
} 
开发者ID:m50d,项目名称:tierney,代码行数:28,代码来源:FixTest.scala

示例6: FriendServiceTest

//设置package包名称以及导入依赖的类
package sample.chirper.friend.impl

import java.util.concurrent.TimeUnit.SECONDS

import scala.collection.immutable.Seq
import scala.concurrent.duration.FiniteDuration

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

import com.lightbend.lagom.javadsl.testkit.ServiceTest.defaultSetup
import com.lightbend.lagom.javadsl.testkit.ServiceTest.eventually
import com.lightbend.lagom.javadsl.testkit.ServiceTest.withServer

import akka.NotUsed
import sample.chirper.friend.api.FriendId
import sample.chirper.friend.api.FriendService
import sample.chirper.friend.api.User

class FriendServiceTest {


  @throws(classOf[Exception])
  @Test
  def shouldBeAbleToCreateUsersAndConnectFriends() {
    withServer(defaultSetup, server => {
      val friendService = server.client(classOf[FriendService])
      val usr1 = new User("usr1", "User 1");
      friendService.createUser().invoke(usr1).toCompletableFuture().get(10, SECONDS)
      val usr2 = new User("usr2", "User 2");
      friendService.createUser().invoke(usr2).toCompletableFuture().get(3, SECONDS)
      val usr3 = new User("usr3", "User 3");
      friendService.createUser().invoke(usr3).toCompletableFuture().get(3, SECONDS)

      friendService.addFriend("usr1").invoke(FriendId(usr2.userId)).toCompletableFuture().get(3, SECONDS)
      friendService.addFriend("usr1").invoke(FriendId(usr3.userId)).toCompletableFuture().get(3, SECONDS)

      val fetchedUsr1 = friendService.getUser("usr1").invoke(NotUsed).toCompletableFuture().get(3,
          SECONDS)
      assertEquals(usr1.userId, fetchedUsr1.userId)
      assertEquals(usr1.name, fetchedUsr1.name)
      assertEquals(Seq("usr2", "usr3"), fetchedUsr1.friends)

      eventually(FiniteDuration(10, SECONDS), () => {
        val followers = friendService.getFollowers("usr2").invoke()
            .toCompletableFuture().get(3, SECONDS)
        assertEquals(Seq("usr1"), followers)
      })

    })
  }

} 
开发者ID:yeongwei,项目名称:activator-lagom-scala-chirper,代码行数:54,代码来源:FriendServiceTest.scala

示例7: JsonColumnReaderTest

//设置package包名称以及导入依赖的类
package edu.uchicago.cs.encsel.dataset.column.json

import java.io.File

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

import edu.uchicago.cs.encsel.model.DataType
import edu.uchicago.cs.encsel.dataset.schema.Schema

class JsonColumnReaderTest {

  @Test
  def testReadColumn(): Unit = {


    val sourceFile = new File("src/test/resource/test_json_parser.json").toURI
    val ccr = new JsonColumnReader()
    val schema = Schema.fromParquetFile(new File("src/test/resource/test_json_parser.schema").toURI)
    val cols = ccr.readColumn(sourceFile, schema)

    assertEquals(3, cols.size)
    val arrays = cols.toArray
    
    assertEquals(0, arrays(0).colIndex)
    assertEquals("id", arrays(0).colName)
    assertEquals(DataType.INTEGER, arrays(0).dataType)
    assertEquals(sourceFile, arrays(0).origin)
    
    assertEquals(1, arrays(1).colIndex)
    assertEquals("name", arrays(1).colName)
    assertEquals(DataType.STRING, arrays(1).dataType)
    assertEquals(sourceFile, arrays(1).origin)
    
    assertEquals(2, arrays(2).colIndex)
    assertEquals("gender", arrays(2).colName)
    assertEquals(DataType.STRING, arrays(2).dataType)
    assertEquals(sourceFile, arrays(2).origin)
  }
} 
开发者ID:harperjiang,项目名称:enc-selector,代码行数:41,代码来源:JsonColumnReaderTest.scala

示例8: CSVColumnReaderTest

//设置package包名称以及导入依赖的类
package edu.uchicago.cs.encsel.dataset.column.csv

import java.io.File

import scala.io.Source

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

import edu.uchicago.cs.encsel.model.DataType
import edu.uchicago.cs.encsel.dataset.schema.Schema

class CSVColumnReaderTest {

  @Test
  def testReadColumn(): Unit = {
    val sourceFile = new File("src/test/resource/test_col_reader.csv").toURI
    val ccr = new CSVColumnReader()
    val schema = Schema.fromParquetFile(new File("src/test/resource/test_col_reader.schema").toURI)
    val cols = ccr.readColumn(sourceFile, schema)

    assertEquals(5, cols.size)
    val arrays = cols.toArray

    assertEquals(0, arrays(0).colIndex)
    assertEquals("id", arrays(0).colName)
    assertEquals(DataType.INTEGER, arrays(0).dataType)
    assertEquals(sourceFile, arrays(0).origin)

    assertEquals(1, arrays(1).colIndex)
    assertEquals("c1", arrays(1).colName)
    assertEquals(DataType.BOOLEAN, arrays(1).dataType)
    assertEquals(sourceFile, arrays(1).origin)

    assertEquals(2, arrays(2).colIndex)
    assertEquals("c2", arrays(2).colName)
    assertEquals(DataType.FLOAT, arrays(2).dataType)
    assertEquals(sourceFile, arrays(2).origin)

    assertEquals(3, arrays(3).colIndex)
    assertEquals("c3", arrays(3).colName)
    assertEquals(DataType.STRING, arrays(3).dataType)
    assertEquals(sourceFile, arrays(3).origin)

    assertEquals(4, arrays(4).colIndex)
    assertEquals("c4", arrays(4).colName)
    assertEquals(DataType.INTEGER, arrays(4).dataType)
    assertEquals(sourceFile, arrays(4).origin)

    arrays.foreach { col =>
      {
        assertEquals(1, Source.fromFile(col.colFile).getLines().size)
      }
    }
  }
} 
开发者ID:harperjiang,项目名称:enc-selector,代码行数:57,代码来源:CSVColumnReaderTest.scala

示例9: JsonParserTest

//设置package包名称以及导入依赖的类
package edu.uchicago.cs.encsel.dataset.parser.json

import java.io.File

import org.junit.Assert.assertArrayEquals
import org.junit.Assert.assertEquals
import org.junit.Test

import edu.uchicago.cs.encsel.dataset.schema.Schema

class JsonParserTest {

  @Test
  def testParse: Unit = {
    val parser = new LineJsonParser
    val schema = Schema.fromParquetFile(new File("src/test/resource/test_json_parser.schema").toURI)

    parser.schema = schema
    val data = parser.parseLine("""{"id":32,"name":"WangDaChui","gender":"male","rpg":"Good"}""")
    assertEquals(3, data.length())
  }

  @Test
  def testGuessHeader: Unit = {
    val parser = new LineJsonParser
    val records = parser.parse(new File("src/test/resource/test_json_parser.json").toURI, null).toArray
    assertArrayEquals(Array[Object]("add", "gender", "id", "name"), parser.guessHeaderName.toArray[Object])
    assertEquals(5, records.length)
    assertEquals(4, records(0).length())
    assertEquals("""$$male$$34$${"a":"x","b":"c"}""", records(2).toString())
    assertEquals(",female,35,Lily3", records(3).iterator().mkString(","))
  }
} 
开发者ID:harperjiang,项目名称:enc-selector,代码行数:34,代码来源:JsonParserTest.scala

示例10: TestCipherUtil

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

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

class TestCipherUtil{
  @Test
  def testEncrypt(): Unit = {
    val encrypted = CipherUtil.encrypt("rockie", "password")
    println(encrypted)

    assertEquals("encrypted a sample password shall be ", "v/nMLHnQCeqDobO01j3syw==", encrypted)
  }

  @Test
  def testDecrypt(): Unit = {
    val decrypted = CipherUtil.decrypt("rockie", "v/nMLHnQCeqDobO01j3syw==")
    println(decrypted)

    assertEquals("encrypted a sample password shall be ", "password", decrypted)
  }

  @Test
  def testEncrypt2(): Unit = {
    val encrypted = CipherUtil.encrypt("yang", "password")
    println(encrypted)

    assertEquals("encrypted a sample password shall be ", "VUhy/KQ2nf7DO0NBBRWW8g==", encrypted)
  }

  @Test
  def testDecrypt2(): Unit = {
    val decrypted = CipherUtil.decrypt("yang", "VUhy/KQ2nf7DO0NBBRWW8g==")
    println(decrypted)

    assertEquals("encrypted a sample password shall be ", "password", decrypted)
  }

  @Test
  def testSymmetric(): Unit = {
    val encrypted = CipherUtil.encrypt("yang", "rockie")
    println(encrypted)

    val decrypted = CipherUtil.decrypt("yang", encrypted)
    assertEquals("encrypted a sample password shall be ", "rockie", decrypted)
  }
} 
开发者ID:knockdata,项目名称:spark-highcharts,代码行数:48,代码来源:TestCipherUtil.scala

示例11: VisitorTest

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

import org.junit.Test

import org.junit.Assert.assertEquals

class VisitorTest {
  val leaf10 = LeafNode(1)
  val leaf20 = LeafNode(2)
  val leaf21 = LeafNode(3)
  val node11 = InternalNode(leaf20, leaf21)
  val rootNode = InternalNode(leaf10, node11)
  
  val visitor = new SumVisitor
  @Test
  def testSumVisitor = {
    visitor.apply(rootNode)
    assertEquals(6, visitor.result)
  }
} 
开发者ID:davidblitz,项目名称:visitorPatternExample,代码行数:21,代码来源:VisitorTest.scala

示例12: TestProdSimplification

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

import lift.arithmetic.{Cst, RangeAdd, Var}
import org.junit.Assert.assertEquals
import org.junit.Test

class TestProdSimplification {
  @Test
  def trivialRange(): Unit = {
    val v = Var("v", range = RangeAdd(0, 1, 1))
    assertEquals(Cst(0), v * Cst(16))
  }

  @Test
  def prodOfFractions(): Unit = {
    val v = Var("v")
    assertEquals(v /^ 8, (v /^ 2) /^ 4)
    assertEquals(v /^ 8, (v /^ 2) * (Cst(1) /^ 4))
  }
} 
开发者ID:lift-project,项目名称:arithexpr,代码行数:21,代码来源:TestProdSimplification.scala

示例13: TestDivisionSimplification

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

import lift.arithmetic._
import org.junit.Test
import org.junit.Assert.assertEquals

class TestDivisionSimplification {
  val a = Var("a")
  val b = Var("b")
  val c = Var("c")

  @Test
  def simpleFactorization(): Unit = {
    assertEquals(b, (Cst(42) * b + a * b) /^ (Cst(42) + a))
    assertEquals(a, (Cst(42) * a + b * a) /^ (Cst(42) + b))
  }
  
  @Test
  def factorizationInAffineExpr(): Unit = {
    assertEquals(
      c + a /^ (Cst(42) + b),
      (a + Cst(42) * c + b * c) /^ (Cst(42) + b)
    )
  }
  
  @Test def issueNumber4(): Unit = {
    val v_O = Var("v_O", StartFromRange(1))
    val gl_id = Var("gl_id", ContinuousRange(0, Var("gl_size", ContinuousRange(1, PosInf))))
    val inSize  = Cst(3)
    val i = (4 + (2 * v_O)) / (2 + v_O) + (3 * gl_id)

    assertEquals(gl_id, i/inSize)
  }
} 
开发者ID:lift-project,项目名称:arithexpr,代码行数:35,代码来源:TestDivisionSimplification.scala

示例14: MetricFormatterTest

//设置package包名称以及导入依赖的类
package org.kongo.kafka.metrics

import com.yammer.metrics.core.MetricName
import org.junit.Assert.assertEquals
import org.junit.Test

class MetricFormatterTest {

  @Test
  def yammerMetricFormatting(): Unit = {
    val metric = new MetricName("group", "type", "name")
    val formatted = MetricFormatter.format(metric)

    assertEquals("group.type.name", formatted)
  }

  @Test
  def yammerMetricWithScopeFormatting(): Unit = {
    val metric = new MetricName("group", "type", "name", "scope")
    val formatted = MetricFormatter.format(metric)

    assertEquals("group.type.scope.name", formatted)
  }

  @Test
  def kafkaMetricFormatting(): Unit = {
    val metric = TestUtils.dummyKafkaMetric
    val formatted = MetricFormatter.format(metric)

    assertEquals("kafka.group.name", formatted)
  }

} 
开发者ID:kongo2002,项目名称:kafka-statsd-reporter,代码行数:34,代码来源:MetricFormatterTest.scala

示例15: Exercise01

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

import forimpatient.chapter06.Exercise02.{GallonsToLiters, InchesToCentimeters, MilesToKilometers}
import org.scalatest.junit.AssertionsForJUnit
import org.junit.Assert.{assertEquals, assertNotNull}
import org.junit.Test


class Exercise01 extends AssertionsForJUnit {
  val delta = 0.00001

  @Test def testNotNull() = {
    val actual = "10"
    assertNotNull(actual)
  }

  @Test def testInchesToCentimeters() = {
    val actual = InchesToCentimeters.convert(10)
    val expected = 25.4
    assertEquals(expected, actual, delta)
  }

  @Test def testGallonsToLiters() = {
    val actual = GallonsToLiters.convert(10)
    val expected = 37.8541178
    assertEquals(expected, actual, delta)
  }

  @Test def testMilesToKilometers() = {
    val actual = MilesToKilometers.convert(10)
    val expected = 16.09344
    assertEquals(expected, actual, delta)
  }
} 
开发者ID:Kiryna,项目名称:Scala-for-the-Impatient,代码行数:35,代码来源:Exercise01.scala


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