[librsvg] path_parser.rs: format the tests nicely and ask rustfmt to skip them



commit d558202068a64870235c581e90d7a7b67915140d
Author: Federico Mena Quintero <federico gnome org>
Date:   Fri Sep 21 20:17:55 2018 -0500

    path_parser.rs: format the tests nicely and ask rustfmt to skip them

 rsvg_internals/src/path_parser.rs | 269 +++++++++++++++++++++++++++++++-------
 1 file changed, 224 insertions(+), 45 deletions(-)
---
diff --git a/rsvg_internals/src/path_parser.rs b/rsvg_internals/src/path_parser.rs
index 5207f27f..0f0b0654 100644
--- a/rsvg_internals/src/path_parser.rs
+++ b/rsvg_internals/src/path_parser.rs
@@ -933,6 +933,7 @@ pub fn parse_path_into_builder(
 }
 
 #[cfg(test)]
+#[cfg_attr(rustfmt, rustfmt_skip)]
 mod tests {
     use super::*;
 
@@ -1004,25 +1005,75 @@ mod tests {
 
     #[test]
     fn handles_numbers() {
-        test_parser("M 10 20", "", &vec![moveto(10.0, 20.0)], None);
+        test_parser(
+            "M 10 20",
+            "",
+            &vec![moveto(10.0, 20.0)],
+            None,
+        );
 
-        test_parser("M -10 -20", "", &vec![moveto(-10.0, -20.0)], None);
+        test_parser(
+            "M -10 -20",
+            "",
+            &vec![moveto(-10.0, -20.0)],
+            None,
+        );
 
-        test_parser("M .10 0.20", "", &vec![moveto(0.10, 0.20)], None);
+        test_parser(
+            "M .10 0.20",
+            "",
+            &vec![moveto(0.10, 0.20)],
+            None,
+        );
 
-        test_parser("M -.10 -0.20", "", &vec![moveto(-0.10, -0.20)], None);
+        test_parser(
+            "M -.10 -0.20",
+            "",
+            &vec![moveto(-0.10, -0.20)],
+            None,
+        );
 
-        test_parser("M-.10-0.20", "", &vec![moveto(-0.10, -0.20)], None);
+        test_parser(
+            "M-.10-0.20",
+            "",
+            &vec![moveto(-0.10, -0.20)],
+            None,
+        );
 
-        test_parser("M10.5.50", "", &vec![moveto(10.5, 0.50)], None);
+        test_parser(
+            "M10.5.50",
+            "",
+            &vec![moveto(10.5, 0.50)],
+            None,
+        );
 
-        test_parser("M.10.20", "", &vec![moveto(0.10, 0.20)], None);
+        test_parser(
+            "M.10.20",
+            "",
+            &vec![moveto(0.10, 0.20)],
+            None,
+        );
 
-        test_parser("M .10E1 .20e-4", "", &vec![moveto(1.0, 0.000020)], None);
+        test_parser(
+            "M .10E1 .20e-4",
+            "",
+            &vec![moveto(1.0, 0.000020)],
+            None,
+        );
 
-        test_parser("M-.10E1-.20", "", &vec![moveto(-1.0, -0.20)], None);
+        test_parser(
+            "M-.10E1-.20",
+            "",
+            &vec![moveto(-1.0, -0.20)],
+            None,
+        );
 
-        test_parser("M10.10E2 -0.20e3", "", &vec![moveto(1010.0, -200.0)], None);
+        test_parser(
+            "M10.10E2 -0.20e3",
+            "",
+            &vec![moveto(1010.0, -200.0)],
+            None,
+        );
 
         test_parser(
             "M-10.10E2-0.20e-3",
@@ -1034,17 +1085,47 @@ mod tests {
 
     #[test]
     fn detects_bogus_numbers() {
-        test_parser("M+", "  ^", &vec![], Some(ErrorKind::UnexpectedEof));
+        test_parser(
+            "M+",
+            "  ^",
+            &vec![],
+            Some(ErrorKind::UnexpectedEof),
+        );
 
-        test_parser("M-", "  ^", &vec![], Some(ErrorKind::UnexpectedEof));
+        test_parser(
+            "M-",
+            "  ^",
+            &vec![],
+            Some(ErrorKind::UnexpectedEof),
+        );
 
-        test_parser("M+x", "  ^", &vec![], Some(ErrorKind::UnexpectedToken));
+        test_parser(
+            "M+x",
+            "  ^",
+            &vec![],
+            Some(ErrorKind::UnexpectedToken),
+        );
 
-        test_parser("M10e", "    ^", &vec![], Some(ErrorKind::UnexpectedEof));
+        test_parser(
+            "M10e",
+            "    ^",
+            &vec![],
+            Some(ErrorKind::UnexpectedEof),
+        );
 
-        test_parser("M10ex", "    ^", &vec![], Some(ErrorKind::UnexpectedToken));
+        test_parser(
+            "M10ex",
+            "    ^",
+            &vec![],
+            Some(ErrorKind::UnexpectedToken),
+        );
 
-        test_parser("M10e-", "     ^", &vec![], Some(ErrorKind::UnexpectedEof));
+        test_parser(
+            "M10e-",
+            "     ^",
+            &vec![],
+            Some(ErrorKind::UnexpectedEof),
+        );
 
         test_parser(
             "M10e+x",
@@ -1056,23 +1137,68 @@ mod tests {
 
     #[test]
     fn handles_numbers_with_comma() {
-        test_parser("M 10, 20", "", &vec![moveto(10.0, 20.0)], None);
+        test_parser(
+            "M 10, 20",
+            "",
+            &vec![moveto(10.0, 20.0)],
+            None,
+        );
 
-        test_parser("M -10,-20", "", &vec![moveto(-10.0, -20.0)], None);
+        test_parser(
+            "M -10,-20",
+            "",
+            &vec![moveto(-10.0, -20.0)],
+            None,
+        );
 
-        test_parser("M.10    ,    0.20", "", &vec![moveto(0.10, 0.20)], None);
+        test_parser(
+            "M.10    ,    0.20",
+            "",
+            &vec![moveto(0.10, 0.20)],
+            None,
+        );
 
-        test_parser("M -.10, -0.20   ", "", &vec![moveto(-0.10, -0.20)], None);
+        test_parser(
+            "M -.10, -0.20   ",
+            "",
+            &vec![moveto(-0.10, -0.20)],
+            None,
+        );
 
-        test_parser("M-.10-0.20", "", &vec![moveto(-0.10, -0.20)], None);
+        test_parser(
+            "M-.10-0.20",
+            "",
+            &vec![moveto(-0.10, -0.20)],
+            None,
+        );
 
-        test_parser("M.10.20", "", &vec![moveto(0.10, 0.20)], None);
+        test_parser(
+            "M.10.20",
+            "",
+            &vec![moveto(0.10, 0.20)],
+            None,
+        );
 
-        test_parser("M .10E1,.20e-4", "", &vec![moveto(1.0, 0.000020)], None);
+        test_parser(
+            "M .10E1,.20e-4",
+            "",
+            &vec![moveto(1.0, 0.000020)],
+            None,
+        );
 
-        test_parser("M-.10E-2,-.20", "", &vec![moveto(-0.0010, -0.20)], None);
+        test_parser(
+            "M-.10E-2,-.20",
+            "",
+            &vec![moveto(-0.0010, -0.20)],
+            None,
+        );
 
-        test_parser("M10.10E2,-0.20e3", "", &vec![moveto(1010.0, -200.0)], None);
+        test_parser(
+            "M10.10E2,-0.20e3",
+            "",
+            &vec![moveto(1010.0, -200.0)],
+            None,
+        );
 
         test_parser(
             "M-10.10E2,-0.20e-3",
@@ -1084,18 +1210,43 @@ mod tests {
 
     #[test]
     fn handles_single_moveto() {
-        test_parser("M 10 20 ", "", &vec![moveto(10.0, 20.0)], None);
+        test_parser(
+            "M 10 20 ",
+            "",
+            &vec![moveto(10.0, 20.0)],
+            None,
+        );
 
-        test_parser("M10,20  ", "", &vec![moveto(10.0, 20.0)], None);
+        test_parser(
+            "M10,20  ",
+            "",
+            &vec![moveto(10.0, 20.0)],
+            None,
+        );
 
-        test_parser("M10 20   ", "", &vec![moveto(10.0, 20.0)], None);
+        test_parser(
+            "M10 20   ",
+            "",
+            &vec![moveto(10.0, 20.0)],
+            None,
+        );
 
-        test_parser("    M10,20     ", "", &vec![moveto(10.0, 20.0)], None);
+        test_parser(
+            "    M10,20     ",
+            "",
+            &vec![moveto(10.0, 20.0)],
+            None,
+        );
     }
 
     #[test]
     fn handles_relative_moveto() {
-        test_parser("m10 20", "", &vec![moveto(10.0, 20.0)], None);
+        test_parser(
+            "m10 20",
+            "",
+            &vec![moveto(10.0, 20.0)],
+            None,
+        );
     }
 
     #[test]
@@ -1519,28 +1670,59 @@ mod tests {
         );
     }
 
-    // FIXME: we don't have a handles_arc() because
-    // we don't know what segments will be computed by PathBuilder::arc().
-    // Maybe we need to represent arcs as native path builder segments,
-    // and only explode them to Cairo curves at rendering time.
     #[test]
     fn first_command_must_be_moveto() {
-        test_parser("  L10 20", "  ^", &vec![], Some(ErrorKind::UnexpectedToken));
+        test_parser(
+            "  L10 20",
+            "  ^",
+            &vec![],
+            Some(ErrorKind::UnexpectedToken),
+        );
     }
 
     #[test]
     fn moveto_args() {
-        test_parser("M", " ^", &vec![], Some(ErrorKind::UnexpectedEof));
+        test_parser(
+            "M",
+            " ^",
+            &vec![],
+            Some(ErrorKind::UnexpectedEof),
+        );
 
-        test_parser("M,", " ^", &vec![], Some(ErrorKind::UnexpectedToken));
+        test_parser(
+            "M,",
+            " ^",
+            &vec![],
+            Some(ErrorKind::UnexpectedToken),
+        );
 
-        test_parser("M10", "   ^", &vec![], Some(ErrorKind::UnexpectedEof));
+        test_parser(
+            "M10",
+            "   ^",
+            &vec![],
+            Some(ErrorKind::UnexpectedEof),
+        );
 
-        test_parser("M10,", "    ^", &vec![], Some(ErrorKind::UnexpectedEof));
+        test_parser(
+            "M10,",
+            "    ^",
+            &vec![],
+            Some(ErrorKind::UnexpectedEof),
+        );
 
-        test_parser("M10x", "   ^", &vec![], Some(ErrorKind::UnexpectedToken));
+        test_parser(
+            "M10x",
+            "   ^",
+            &vec![],
+            Some(ErrorKind::UnexpectedToken),
+        );
 
-        test_parser("M10,x", "    ^", &vec![], Some(ErrorKind::UnexpectedToken));
+        test_parser(
+            "M10,x",
+            "    ^",
+            &vec![],
+            Some(ErrorKind::UnexpectedToken),
+        );
     }
 
     #[test]
@@ -1992,10 +2174,7 @@ mod tests {
             Some(ErrorKind::UnexpectedEof),
         );
 
-        // FIXME: we don't test the arc results, because
-        // we don't know what segments will be computed by PathBuilder::arc().
-        // Maybe we need to represent arcs as native path builder segments,
-        // and only explode them to Cairo curves at rendering time.
+        // FIXME: we need tests for arcs
         //
         // test_parser("M10-20A1 2 3,1,1,6,7,",
         //             "                     ^",


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