[librsvg: 21/28] path_parser: Test curveto arguments



commit d10a7a74f23a66ae3f66455bf5ac2a9adfc8f567
Author: Federico Mena Quintero <federico gnome org>
Date:   Tue Jan 23 10:48:45 2018 -0600

    path_parser: Test curveto arguments

 rust/src/path_parser.rs | 66 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 66 insertions(+)
---
diff --git a/rust/src/path_parser.rs b/rust/src/path_parser.rs
index b80c92b..c2fc619 100644
--- a/rust/src/path_parser.rs
+++ b/rust/src/path_parser.rs
@@ -1705,4 +1705,70 @@ mod tests {
                           lineto(10.0, 10.0)],
                     Some(ErrorKind::UnexpectedEof));
     }
+
+    #[test]
+    fn curveto_args() {
+        test_parser("M10-20C1",
+                    "        ^",
+                    &vec![moveto(10.0, -20.0)],
+                    Some(ErrorKind::UnexpectedEof));
+        test_parser("M10-20C1,",
+                    "         ^",
+                    &vec![moveto(10.0, -20.0)],
+                    Some(ErrorKind::UnexpectedEof));
+
+        test_parser("M10-20C1 2",
+                    "          ^",
+                    &vec![moveto(10.0, -20.0)],
+                    Some(ErrorKind::UnexpectedEof));
+        test_parser("M10-20C1,2,",
+                    "           ^",
+                    &vec![moveto(10.0, -20.0)],
+                    Some(ErrorKind::UnexpectedEof));
+
+        test_parser("M10-20C1 2 3",
+                    "            ^",
+                    &vec![moveto(10.0, -20.0)],
+                    Some(ErrorKind::UnexpectedEof));
+        test_parser("M10-20C1,2,3",
+                    "            ^",
+                    &vec![moveto(10.0, -20.0)],
+                    Some(ErrorKind::UnexpectedEof));
+        test_parser("M10-20C1,2,3,",
+                    "             ^",
+                    &vec![moveto(10.0, -20.0)],
+                    Some(ErrorKind::UnexpectedEof));
+
+        test_parser("M10-20C1 2 3 4",
+                    "              ^",
+                    &vec![moveto(10.0, -20.0)],
+                    Some(ErrorKind::UnexpectedEof));
+        test_parser("M10-20C1,2,3,4",
+                    "              ^",
+                    &vec![moveto(10.0, -20.0)],
+                    Some(ErrorKind::UnexpectedEof));
+        test_parser("M10-20C1,2,3,4,",
+                    "               ^",
+                    &vec![moveto(10.0, -20.0)],
+                    Some(ErrorKind::UnexpectedEof));
+
+        test_parser("M10-20C1 2 3 4 5",
+                    "                ^",
+                    &vec![moveto(10.0, -20.0)],
+                    Some(ErrorKind::UnexpectedEof));
+        test_parser("M10-20C1,2,3,4,5",
+                    "                ^",
+                    &vec![moveto(10.0, -20.0)],
+                    Some(ErrorKind::UnexpectedEof));
+        test_parser("M10-20C1,2,3,4,5,",
+                    "                 ^",
+                    &vec![moveto(10.0, -20.0)],
+                    Some(ErrorKind::UnexpectedEof));
+
+        test_parser("M10-20C1,2,3,4,5,6,",
+                    "                   ^",
+                    &vec![moveto(10.0, -20.0),
+                          curveto(1.0, 2.0, 3.0, 4.0, 5.0, 6.0)],
+                    Some(ErrorKind::UnexpectedEof));
+    }
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]