From 7f20965b622abc1487382125814edd23ff343335 Mon Sep 17 00:00:00 2001 From: Matthias Paulmier Date: Fri, 8 Jun 2018 11:42:23 +0200 Subject: t: Test the flatten method 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 | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/t/pm/Utils.pl b/t/pm/Utils.pl index 86ef29577..2ccb3635f 100644 --- a/t/pm/Utils.pl +++ b/t/pm/Utils.pl @@ -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); -- cgit v1.2.1