From c5fd2f5c51ffe6359df4fafc21116313cc73d2d7 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Wed, 4 Mar 2009 12:32:19 -0800 Subject: [PATCH] classifier: Add tests for classifier_count(), classifier_count_exact(). --- tests/test-classifier.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/test-classifier.c b/tests/test-classifier.c index 20fd7c23..869cfd98 100644 --- a/tests/test-classifier.c +++ b/tests/test-classifier.c @@ -90,6 +90,19 @@ tcls_destroy(struct tcls *tcls) } } +static int +tcls_count_exact(const struct tcls *tcls) +{ + int n_exact; + size_t i; + + n_exact = 0; + for (i = 0; i < tcls->n_rules; i++) { + n_exact += tcls->rules[i]->cls_rule.wc.wildcards == 0; + } + return n_exact; +} + static bool tcls_is_empty(const struct tcls *tcls) { @@ -318,6 +331,8 @@ compare_classifiers(struct classifier *cls, struct tcls *tcls) { unsigned int i; + assert(classifier_count(cls) == tcls->n_rules); + assert(classifier_count_exact(cls) == tcls_count_exact(tcls)); for (i = 0; i < N_FLOW_VALUES; i++) { struct cls_rule *cr0, *cr1; flow_t flow; -- 2.30.2