Implements contain <value> syntax for containers of type C.
Implements contain <value> syntax for containers of type C.
a container about which an assertion is being made
an element that should be contained in the passed container
true if the passed container contains the passed element
Implements contain noneOf syntax for containers of type C.
Implements contain noneOf syntax for containers of type C.
a container about which an assertion is being made
elements none of which should be contained in the passed container
true if the passed container contains none of the passed elements
Implements contain oneOf syntax for containers of type C.
Implements contain oneOf syntax for containers of type C.
a container about which an assertion is being made
elements exactly one (i.e., one and only one) of which should be contained in the passed container
true if the passed container contains exactly one of the passed elements
Supertrait for typeclasses that enable certain
containmatcher syntax for containers.A
Containing[C]provides access to the "containing nature" of typeCin such a way that relevantcontainmatcher syntax can be used with typeC. ACcan 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 thecontainmatcher syntax on your own typeUby defining anContaining[U]for the type and making it available implicitly.ScalaTest provides implicit
Containinginstances forscala.collection.GenTraversable,java.util.Collection,java.util.Map,String,Array, andscala.Optionin theContainingcompanion object.ContainingversusAggregatingThe difference between
ContainingandAggregatingis thatContainingenablescontainmatcher syntax that makes sense for "box" types that can contain at most one value (for example,scala.Option), whereasAggregatingenablescontainmatcher 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.Optioncan 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
containallOfis enabled byAggregating, and ScalaTest provides no implicitAggregatinginstance for typescala.Option.