testSingleFieldOperator

A helper for SingleFieldOperator unit tests.

testSingleFieldOperator takes a set of split file values, a field index, a header suffix, and a set of expected values. The expected values array contains the initial value (zero entries) and the expected values after each line. (One more expected value than input lines.) The zero entry case is what is generated for an empty file. An example testing the 'min' operator against a file with 2 columns, 3 rows, using field index 1:

testSingleFieldOperator!MinOperator( [["10", "100"], // The split file. 3 lines by 2 rows. ["5", "50"], ["20", "200"]], 1, // Field index (zero-based, so "100", "50", "200") "min", // The header suffix, normally the operator name. ["nan", "100", "50", "50"]); // Min value after processing each line.

A typical operator unit test uses three "files", one each of 1x3, 2x3, and 3x3. Then run the operator is tested against each column, a total of six calls. Headers are automatically checked. Additional entries can be used to extend coverage.

A non-default MissingFieldPolicy can be provide as an optional last argument. Operator tests should include exclusion and replacement variations. See operator unit tests for details.

The testSingleFieldOperatorBase adds an additional capability - Custom operator init arguments. Currently this is used only by the quantile operator.

These tests do not check unique key behavior (group-by). Operators don't have info about unique keys, and interact with them only indirectly, via Calculators.

version(unittest)
void
testSingleFieldOperator
(
OperatorClass : SingleFieldOperator
)

Meta