-
Notifications
You must be signed in to change notification settings - Fork 17
Classifier
A Classifier collects statistical information over a set of test cases, namely the number of trivial test cases and the distribution of categories. A category is a set of tags (represented as strings).
Note: although it is a general concept, [[check]]
accepts only the standard classifier
due to issues with template deduction.
concept Classifier {
template <typename... Args>
void check(const std::tuple<Args...>& args);
size_t trivial() const;
distribution distro() const;
};
template <typename... Args>
class classifier {
public:
classifier& trivial(bool predicate(const Args&...));
classifier& classify(bool predicate(const Args&...), const std::string& label);
template <typename T>
classifier& collect(T tagger(const Args&...));
template <typename... Args>
void check(const std::tuple<Args...>& args);
size_t trivial() const;
distribution distro() const;
};
-
classifier& trivial(bool predicate(const Args&...));
Sets the
predicate
that returnstrue
for trivial test cases. Returns*this
for chaining. This function can be called multiple times, but only the last predicate will be kept. -
classifier& classify(bool predicate(const Args&...), const std::string& tag);
Adds a classifier for a single tag. If the
predicate
returnstrue
, thetag
is included in the test case's category. -
template <typename T> classifier& collect(T tagger(const Args&...));
Adds a classifier. The
tagger
should generate a value based on the test case. If the value is not a string, it will be converted to one using the output stream operator.