trait
Containing[-C] extends AnyRef
Abstract Value Members
-
abstract
def
contains(container: C, element: Any): Boolean
-
abstract
def
containsNoneOf(container: C, elements: Seq[Any]): Boolean
-
abstract
def
containsOneOf(container: C, elements: Seq[Any]): Boolean
Concrete Value Members
-
final
def
!=(arg0: Any): Boolean
-
final
def
##(): Int
-
final
def
==(arg0: Any): Boolean
-
final
def
asInstanceOf[T0]: T0
-
def
clone(): AnyRef
-
final
def
eq(arg0: AnyRef): Boolean
-
def
equals(arg0: Any): Boolean
-
def
finalize(): Unit
-
final
def
getClass(): Class[_]
-
def
hashCode(): Int
-
final
def
isInstanceOf[T0]: Boolean
-
final
def
ne(arg0: AnyRef): Boolean
-
final
def
notify(): Unit
-
final
def
notifyAll(): Unit
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
-
def
toString(): String
-
final
def
wait(): Unit
-
final
def
wait(arg0: Long, arg1: Int): Unit
-
final
def
wait(arg0: Long): Unit
Inherited from AnyRef
Value Members
-
final
def
!=(arg0: Any): Boolean
-
final
def
##(): Int
-
final
def
==(arg0: Any): Boolean
-
def
clone(): AnyRef
-
final
def
eq(arg0: AnyRef): Boolean
-
def
equals(arg0: Any): Boolean
-
def
finalize(): Unit
-
final
def
getClass(): Class[_]
-
def
hashCode(): Int
-
final
def
ne(arg0: AnyRef): Boolean
-
final
def
notify(): Unit
-
final
def
notifyAll(): Unit
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
-
def
toString(): String
-
final
def
wait(): Unit
-
final
def
wait(arg0: Long, arg1: Int): Unit
-
final
def
wait(arg0: Long): Unit
Inherited from Any
Value Members
-
final
def
asInstanceOf[T0]: T0
-
final
def
isInstanceOf[T0]: Boolean
Ungrouped
-
abstract
def
contains(container: C, element: Any): Boolean
-
abstract
def
containsNoneOf(container: C, elements: Seq[Any]): Boolean
-
abstract
def
containsOneOf(container: C, elements: Seq[Any]): Boolean
-
final
def
!=(arg0: Any): Boolean
-
final
def
##(): Int
-
final
def
==(arg0: Any): Boolean
-
final
def
asInstanceOf[T0]: T0
-
def
clone(): AnyRef
-
final
def
eq(arg0: AnyRef): Boolean
-
def
equals(arg0: Any): Boolean
-
def
finalize(): Unit
-
final
def
getClass(): Class[_]
-
def
hashCode(): Int
-
final
def
isInstanceOf[T0]: Boolean
-
final
def
ne(arg0: AnyRef): Boolean
-
final
def
notify(): Unit
-
final
def
notifyAll(): Unit
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
-
def
toString(): String
-
final
def
wait(): Unit
-
final
def
wait(arg0: Long, arg1: Int): Unit
-
final
def
wait(arg0: Long): Unit
Supertrait for typeclasses that enable certain
contain
matcher syntax for containers.A
Containing[C]
provides access to the "containing nature" of typeC
in such a way that relevantcontain
matcher syntax can be used with typeC
. AC
can be any type of "container," a type that in some way can contains one or more other objects. ScalaTest provides implicit implementations for several types. You can enable thecontain
matcher syntax on your own typeU
by defining anContaining[U]
for the type and making it available implicitly.ScalaTest provides implicit
Containing
instances forscala.collection.GenTraversable
,java.util.Collection
,java.util.Map
,String
,Array
, andscala.Option
in theContaining
companion object.Containing
versusAggregating
The difference between
Containing
andAggregating
is thatContaining
enablescontain
matcher syntax that makes sense for "box" types that can contain at most one value (for example,scala.Option
), whereasAggregating
enablescontain
matcher syntax for full-blown collections and other aggregations of potentially more than one object. For example, it makes sense to make assertions like these, which are enabled byContaining
, forscala.Option
:However, given a
scala.Option
can only ever contain at most one object, it doesn't make sense to make assertions like the following, which are enabled viaAggregation
:The above assertion could never succceed, because an option cannot contain more than one value. By default the above statement does not compile, because
contain
allOf
is enabled byAggregating
, and ScalaTest provides no implicitAggregating
instance for typescala.Option
.