summaryrefslogtreecommitdiffstats
path: root/scripts/t/Dpkg_Source_Format.t
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 09:40:31 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 09:40:31 +0000
commitb86570f63e533abcbcb97c2572e0e5732a96307b (patch)
treecabc83be691530ae685c45a8bc7620ccc0e1ebdf /scripts/t/Dpkg_Source_Format.t
parentInitial commit. (diff)
downloaddpkg-upstream.tar.xz
dpkg-upstream.zip
Adding upstream version 1.20.13.upstream/1.20.13upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'scripts/t/Dpkg_Source_Format.t')
-rw-r--r--scripts/t/Dpkg_Source_Format.t65
1 files changed, 65 insertions, 0 deletions
diff --git a/scripts/t/Dpkg_Source_Format.t b/scripts/t/Dpkg_Source_Format.t
new file mode 100644
index 0000000..5a2785e
--- /dev/null
+++ b/scripts/t/Dpkg_Source_Format.t
@@ -0,0 +1,65 @@
+#!/usr/bin/perl
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+use strict;
+use warnings;
+
+use Test::More tests => 14;
+
+BEGIN {
+ use_ok('Dpkg::Source::Format');
+}
+
+my $format = Dpkg::Source::Format->new();
+my @format_parts;
+my $format_string;
+
+$format->set('4.3 (variant)');
+@format_parts = $format->get();
+is_deeply(\@format_parts, [ qw(4 3 variant) ], 'decomposition of format');
+$format_string = $format->get();
+ok($format_string eq '4.3 (variant)', 'function stringification of format');
+$format_string = "$format";
+ok($format_string eq '4.3 (variant)', 'operator stringification of format');
+
+$format->set('5.5');
+$format_string = $format->get();
+ok($format_string eq '5.5', 'missing variant');
+
+$format->set('6');
+$format_string = $format->get();
+ok($format_string eq '6.0', 'implied minor');
+
+my %format_bogus = (
+ 'a' => 'require numerical major',
+ '7.a'=> 'require numerical minor',
+ '.5' => 'require non-empty major',
+ '7.' => 'require non-empty minor',
+ '7.0 ()' => 'require non-empty variant',
+ '7.0 ( )' => 'require non-space variant',
+ '7.0 (VARIANT)' => 'require lower-case variant',
+ '7.6.5' => 'excess version part',
+);
+
+foreach my $format_bogus (sort keys %format_bogus) {
+ eval {
+ $format->set($format_bogus);
+ };
+ ok($@, $format_bogus{$format_bogus});
+};
+
+# TODO: Add actual test cases.
+
+1;