doc / ch.tutteli.atrium.api.fluent.en_GB / butAtMost

# butAtMost

`fun <T : CharSequence, S : CharSequenceContains.SearchBehaviour> AtLeastCheckerStep<T, S>.butAtMost(times: Int): ButAtMostCheckerStep<T, S>`

(source)
Restricts a `contains at least`

assertion by specifying that the number of occurrences of the value which we
are looking for occurs `at most`

number of times within the search input.

The resulting restriction will be a `contains at least but at most`

assertion.

### Parameters

`times`

- The number which the check will compare against the actual number of times an expected value is
found in the input of the search.

### Exceptions

`IllegalArgumentException`

- In case times is smaller than zero.

`IllegalArgumentException`

- In case times is zero; use notToContain instead.

`IllegalArgumentException`

- In case times of this `at most`

restriction equals to the number of the
`at least`

restriction; use the exactly restriction instead.

**Return**

The newly created builder.

`fun <E, T, S : InAnyOrderSearchBehaviour> AtLeastCheckerStep<E, T, S>.butAtMost(times: Int): ButAtMostCheckerStep<E, T, S>`

(source)
Restricts a `contains at least`

assertion by specifying that the number of occurrences of the entry which we
are looking for occurs `at most`

number of times within the IterableLike.

The resulting restriction will be a `contains at least but at most`

assertion.

### Parameters

`times`

- The number which the check will compare against the actual number of times an expected entry is
found in the IterableLike.

### Exceptions

`IllegalArgumentException`

- In case times is smaller than zero.

`IllegalArgumentException`

- In case times is zero; use notToContain instead.

`IllegalArgumentException`

- In case times of this `at most`

restriction equals to the number of the
`at least`

restriction; use the exactly restriction instead.

**Return**

The newly created builder.

**Since**

0.14.0 -- API existed for Iterable but not for IterableLike.