]> git.ipfire.org Git - thirdparty/vectorscan.git/commitdiff
unit: better output from expr_info unit tests
authorJustin Viiret <justin.viiret@intel.com>
Thu, 23 Mar 2017 23:41:16 +0000 (10:41 +1100)
committerMatthew Barr <matthew.barr@intel.com>
Wed, 26 Apr 2017 05:18:25 +0000 (15:18 +1000)
unit/hyperscan/expr_info.cpp

index d238347974d72d204b61f6994eda83eb4d9ed389..7cc6abd7ff19d1452b643cd6d8e7be5e064c39f7 100644 (file)
@@ -51,6 +51,53 @@ struct expected_info {
     char matches_only_at_eod;
 };
 
+ostream& operator<<(ostream &os, const hs_expr_ext &ext) {
+    if (!ext.flags) {
+        return os;
+    }
+    bool first = true;
+    if (ext.flags & HS_EXT_FLAG_MIN_OFFSET) {
+        if (!first) {
+            os << ", ";
+        }
+        os << "min_offset=" << ext.min_offset;
+        first = false;
+    }
+    if (ext.flags & HS_EXT_FLAG_MAX_OFFSET) {
+        if (!first) {
+            os << ", ";
+        }
+        os << "max_offset=" << ext.max_offset;
+        first = false;
+    }
+    if (ext.flags & HS_EXT_FLAG_MIN_LENGTH) {
+        if (!first) {
+            os << ", ";
+        }
+        os << "min_length=" << ext.min_length;
+        first = false;
+    }
+    if (ext.flags & HS_EXT_FLAG_EDIT_DISTANCE) {
+        if (!first) {
+            os << ", ";
+        }
+        os << "edit_distance=" << ext.edit_distance;
+        first = false;
+    }
+    return os;
+}
+
+// For Google Test.
+void PrintTo(const expected_info &ei, ostream *os) {
+    *os << "expected_info: "
+        << "pattern=\"" << ei.pattern << "\""
+        << ", ext={" << ei.ext << "}"
+        << ", min=" << ei.min << ", max=" << ei.max
+        << ", unordered_matches=" << (ei.unordered_matches ? 1 : 0)
+        << ", matches_at_eod=" << (ei.matches_at_eod ? 1 : 0)
+        << ", matches_only_at_eod=" << (ei.matches_only_at_eod ? 1 : 0);
+}
+
 class ExprInfop : public TestWithParam<expected_info> {
 };