Testable

object Testable

Provides many "given" Testable instances for built-in types.

Provided types include

  • Int, Long, BigInt, Double
  • Boolean, Char, String
  • Option, List, Array
  • Set, Map (from scala.collection.immutable)
  • Tuple2, ..., Tuple6

Other types can be added as needed by declaring an appropriate Testable instance.

Also provides a TestableGrid instance for an array of arrays that displays its data in a grid-like format.

Companion:
class
class Object
trait Matchable
class Any

Type members

Classlikes

object TestableBigInt extends Testable[BigInt]
object TestableBoolean extends Testable[Boolean]
object TestableChar extends Testable[Char]
object TestableDouble extends Testable[Double]
object TestableInt extends Testable[Int]
object TestableLong extends Testable[Long]
object TestableString extends Testable[String]

Value members

Concrete methods

def TestableGrid[A : ClassTag](implicit evidence$2: ClassTag[A], TA: Testable[A]): Testable[Array[Array[A]]]

Provides an easier-to-read display for two-dimensional arrays by formatting them as a grid.

Provides an easier-to-read display for two-dimensional arrays by formatting them as a grid.

For example,

 Array(Array(1, 0, 10), Array(-1592, 3, 7), Array(67, 2, 192))

would be displayed as

 Array(
   Array(    1, 0,  10),
   Array(-1592, 3,   7),
   Array(   67, 2, 192)
 )

If the inner arrays have different lengths, the data will be displayed in the default format, rather than as a grid. For example, if the -1592 were removed, the above array of arrays would display as

 Array(Array(1, 0, 10), Array(3, 7), Array(67, 2, 192))

Warning: Best used with grids that are small enough not to wrap.

To use this as a replacement for Testable[Array[Array[A]]], precede the test with a given, as in

 given hwtest.Testable[Array[Array[Int]]] = hwtest.Testable.TestableGrid[Int]
 test("column", column, "matrix")

However, this can also affect the display of other tests that involve an Array[Array[Int]. If necessary, you can avoid that by surounding the given... and test... with { and }.

Givens

Givens

given TestableArray[A : ClassTag](implicit evidence$1: ClassTag[A], TA: Testable[A]): TestableArray[A]
given TestableList[A](using TA: Testable[A]): TestableList[A]
given TestableMap[K, V](using TK: Testable[K], TV: Testable[V]): TestableMap[K, V]
given TestableOption[A](using TA: Testable[A]): TestableOption[A]
given TestableSet[A](using TA: Testable[A]): TestableSet[A]
given TestableTuple2[A, B](using TA: Testable[A], TB: Testable[B]): TestableTuple2[A, B]
given TestableTuple3[A, B, C](using TA: Testable[A], TB: Testable[B], TC: Testable[C]): TestableTuple3[A, B, C]
given TestableTuple4[A, B, C, D](using TA: Testable[A], TB: Testable[B], TC: Testable[C], TD: Testable[D]): TestableTuple4[A, B, C, D]
given TestableTuple5[A, B, C, D, E](using TA: Testable[A], TB: Testable[B], TC: Testable[C], TD: Testable[D], TE: Testable[E]): TestableTuple5[A, B, C, D, E]
given TestableTuple6[A, B, C, D, E, F](using TA: Testable[A], TB: Testable[B], TC: Testable[C], TD: Testable[D], TE: Testable[E], TF: Testable[F]): TestableTuple6[A, B, C, D, E, F]