]> git.ipfire.org Git - thirdparty/automake.git/commitdiff
t: Test the flatten method
authorMatthias Paulmier <matthias.paulmier@etu.u-bordeaux.fr>
Fri, 8 Jun 2018 09:42:23 +0000 (11:42 +0200)
committerMatthias Paulmier <matthias.paulmier@etu.u-bordeaux.fr>
Fri, 22 Jun 2018 12:18:47 +0000 (14:18 +0200)
Checks if the output string is a flattened version of the input string.  It
should remove trailing and leading whitespaces, multiple whitespaces (and
replace it with single ones) and line breaks in a given string.

* t/pm/Utils.pl: add check_flatten to the test-suite.

t/pm/Utils.pl

index 86ef2957700013e8f1b5d837e801e3c87c0da7c9..2ccb3635f65779d2bed457799e710e75b25106ed 100644 (file)
@@ -29,4 +29,25 @@ sub check_subst
   return 0;
 }
 
-exit check_subst;
+sub check_flatten
+{
+  my $test_str = "\
+
+  Aliquam posuere.  Nunc aliquet, augue nec adipiscing interdum, lacus tellus
+malesuada massa, quis varius mi purus     non odio.  Pellentesque condimentum,
+
+magna ut suscipit hendrerit, ipsum augue ornare nulla,  non luctus diam neque
+
+sit amet urna.  Curabitur vulputate vestibulum lorem.  Fusce sagittis, libero
+  non molestie mollis, magna orci ultrices dolor, at vulputate neque nulla
+lacinia eros.
+";
+
+  my $expected_res = "Aliquam posuere. Nunc aliquet, augue nec adipiscing interdum, lacus tellus malesuada massa, quis varius mi purus non odio. Pellentesque condimentum, magna ut suscipit hendrerit, ipsum augue ornare nulla, non luctus diam neque sit amet urna. Curabitur vulputate vestibulum lorem. Fusce sagittis, libero non molestie mollis, magna orci ultrices dolor, at vulputate neque nulla lacinia eros.";
+
+  return 1 if (flatten $test_str) ne $expected_res;
+  return 0;
+
+}
+
+exit (check_subst || check_flatten);