ShouldType

ShouldType is the base type passed between UFCS words in fluent assertions. It stores the left-hand side expression of the phrase, called "got" in errors, as well as the words making up the assertion phrase as template arguments.

Constructors

this
this(G got, ref int refCount)

Manually initialize a new ShouldType value from an existing one's ref count. All ShouldTypes of one phrase must use the same reference counter.

Destructor

A destructor is present on this object, but not explicitly documented in the source.

Postblit

A postblit is present on this object, but not explicitly documented in the source.

Members

Functions

addWord
auto addWord()

Add a word to the phrase. Can be chained.

check
void check(bool condition, lazy string left, lazy string right, string file, size_t line)

Checks a boolean condition for truth, throwing an exception when it fails. The components making up the exception string are passed lazily. The message has the form: "test failed {left} [because reason] {right}" For instance: "test failed: expected got.empty() because there should be nothing in there, but got [5]." In that case, left is ": expected got.empty()" and right is "but got [5]".

empty
auto empty()

Evaluates to true if the given word exists in the current phrase.

terminateChain
void terminateChain()

Mark that the semantic end of this phrase has been reached. If this is not called, the phrase will error on scope exit.

Templates

allowOnlyWords
template allowOnlyWords(allowedWords...)

Allows to check that only a select list of words are permitted before the current word. On failure, an informative error is printed. Usage: should.allowOnlyWords!("word1", "word2").before!"newWord";

requireWord
template requireWord(string requiredWord)

Allows to check that a specified word appeared in the phrase before the current word. On failure, an informative error is printed. Usage: should.requireWord!"word".before!"newWord";

Meta