]> git.proxmox.com Git - rustc.git/blobdiff - src/vendor/regex-syntax/src/properties.rs
New upstream version 1.20.0+dfsg1
[rustc.git] / src / vendor / regex-syntax / src / properties.rs
index 804a90ba12254a120ec18a307158343d0fb2627c..9e75f99a4e81cf789bdf5cd55ceee403f8890cdb 100644 (file)
@@ -59,6 +59,29 @@ fn valid_class_ranges() {
     qc(prop as fn(Vec<(char, char)>) -> bool);
 }
 
+#[test]
+fn intersection() {
+    fn prop(ranges1: Vec<(char, char)>, ranges2: Vec<(char, char)>) -> bool {
+        let class1 = class(&ranges1).canonicalize();
+        let class2 = class(&ranges2).canonicalize();
+
+        let mut expected = CharClass::empty();
+        // This is inefficient but correct.
+        for range1 in &class1 {
+            for range2 in &class2 {
+                if let Some(intersection) = range1.intersection(range2) {
+                    expected.ranges.push(intersection);
+                }
+            }
+        }
+        expected = expected.canonicalize();
+
+        let got = class1.intersection(&class2);
+        expected == got
+    }
+    qc(prop as fn(Vec<(char, char)>, Vec<(char, char)>) -> bool);
+}
+
 /// A wrapper type for generating "regex-like" Unicode strings.
 ///
 /// In particular, this type's `Arbitrary` impl specifically biases toward