1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
|
Description: Have a test suite that actually tests
Author: Christoph Biedl <debian.axhn@manchmal.in-ulm.de>
Forwarded: No
Last-Update: 2019-07-18
--- a/test.pl
+++ b/test.pl
@@ -1,17 +1,61 @@
-# Before `make install' is performed this script should be runnable with
-# `make test'. After `make install' it should work as `perl test.pl'
+#!/usr/bin/perl
-#########################
+use Test::More;
-# change 'tests => 1' to 'tests => last_test_to_print';
+BEGIN { use_ok('Date::Holidays::DE') or die; };
-use Test;
-BEGIN { plan tests => 1 };
-use Date::Holidays::DE;
-ok(1); # If we made it this far, we're ok.
+use Date::Holidays::DE qw<holidays>;
-#########################
-
-# Insert your test code below, the Test module is use()ed here so read
-# its man page ( perldoc Test ) for help writing this test script.
+{
+ my $feiertage_ref = holidays(
+ YEAR=>2017,
+ FORMAT=>"%d.%m.%Y",
+ );
+ is (
+ scalar (grep { $_ eq '31.10.2017' } @$feiertage_ref),
+ 1,
+ '2017: refo is a nation-wide holiday',
+ );
+}
+{
+ my $feiertage_ref = holidays(
+ YEAR=>2017,
+ WHERE=>['hh'],
+ FORMAT=>"%d.%m.%Y",
+ );
+ is_deeply ($feiertage_ref, [], '2017: refo is NOT a local holiday in HH');
+}
+{
+ my $feiertage_ref = holidays(
+ YEAR=>2018,
+ WHERE=>['hh'],
+ FORMAT=>"%d.%m.%Y",
+ );
+ is_deeply (
+ $feiertage_ref,
+ [ qw<31.10.2018> ],
+ '2018: refo is a local holiday in HH',
+ );
+}
+{
+ my $feiertage_ref = holidays(
+ YEAR=>2018,
+ WHERE=>['be'],
+ FORMAT=>"%d.%m.%Y",
+ );
+ is_deeply ($feiertage_ref, [], '2018: frau is NOT a local holiday in Berlin');
+}
+{
+ my $feiertage_ref = holidays(
+ YEAR=>2019,
+ WHERE=>['be'],
+ FORMAT=>"%d.%m.%Y",
+ );
+ is (
+ scalar (grep { $_ eq '08.03.2019' } @$feiertage_ref),
+ 1,
+ '2019: frau is a local holiday in Berlin',
+ );
+}
+done_testing;
|