aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorroot <root@rbsd.ankarstrom.se>2021-04-24 01:25:37 +0000
committerroot <root@rbsd.ankarstrom.se>2021-04-24 01:25:37 +0000
commit0c0554d767a6cb97c58c3ca7b639f3070e5591f5 (patch)
tree65ee59fcb49060ffd59b407a55e5671450d71691
parente4f920da810a263e8bae849b3c36c47caf4cdd40 (diff)
downloadApache-Inject-0c0554d767a6cb97c58c3ca7b639f3070e5591f5.tar.gz
Expand tests
-rwxr-xr-xt/SMOKE2
-rw-r--r--t/basic.t65
2 files changed, 40 insertions, 27 deletions
diff --git a/t/SMOKE b/t/SMOKE
index 7b1d937..5bb18f1 100755
--- a/t/SMOKE
+++ b/t/SMOKE
@@ -1,6 +1,6 @@
#!/usr/local/bin/perl
# WARNING: this file is generated, do not edit
-# generated on Sat Apr 24 00:40:18 2021
+# generated on Sat Apr 24 01:01:16 2021
# 01: /usr/local/lib/perl5/site_perl/mach/5.32/Apache/TestConfig.pm:1003
# 02: /usr/local/lib/perl5/site_perl/mach/5.32/Apache/TestConfig.pm:1095
# 03: /usr/local/lib/perl5/site_perl/mach/5.32/Apache/TestSmoke.pm:775
diff --git a/t/basic.t b/t/basic.t
index 0494ff0..4833d68 100644
--- a/t/basic.t
+++ b/t/basic.t
@@ -5,35 +5,48 @@ use Apache::Test;
use Apache::TestUtil;
use Apache::TestRequest qw/GET_BODY/;
-plan tests => 1;
+plan tests => 5;
-# (0) Prepare environment
+# Prepare environment
-# - Read contents of header and footer
open my $h, '<', 't/htdocs/head.html' or die;
open my $f, '<', 't/htdocs/foot.html' or die;
-chomp(my $head = do { local $/; <$h> });
-chomp(my $foot = do { local $/; <$f> });
+my $head = do { local $/; <$h> };
+my $foot = do { local $/; <$f> };
close $h; close $f;
-# - Open test file for writing
-open my $t, '>', 't/htdocs/test.html' or die;
-my $test;
-
-# (1) <head>-less head
-
-$test = <<END;
-<title>Test</title>
-This is a test page.
-END
-seek($t, 0, 0);
-print $t $test;
-
-ok GET_BODY('/test.html'), <<END, '<head>-less head';
-<title>Test</title>
-$head
-This is a test page.
-$foot
-END
-
-close $t;
+my @test;
+sub prepare {
+ open my $t, '>', 't/htdocs/test.html' or die;
+ print $t join('', @_);
+ close $t;
+}
+
+# Run tests
+
+@test = ("<title>Test</title>\n", "This is a test page.\n");
+prepare @test;
+ok GET_BODY('/test.html'), "${test[0]}$head${test[1]}$foot",
+ '<head>-less head';
+
+@test = ("<head>...</head>\n", "This is a test page.\n");
+prepare @test;
+ok GET_BODY('/test.html'), "${test[0]}$head${test[1]}$foot",
+ '<head>-ful head';
+
+@test = ("<html>\n", "This is a test page.\n", "</html>\n");
+prepare @test;
+ok GET_BODY('/test.html'), "${test[0]}$head${test[1]}$foot${test[2]}",
+ '<html>-wrapped document';
+
+@test = ("<!doctype html>\n", "This is a test page.\n");
+prepare @test;
+ok GET_BODY('/test.html'), "${test[0]}$head${test[1]}$foot",
+ '<!doctype>';
+
+@test = ("\n<!doctype html>\n", "This is a test page.\n");
+prepare @test;
+ok GET_BODY('/test.html'), "${test[0]}$head${test[1]}$foot",
+ '<!doctype> with leading newline';
+
+unlink 't/htdocs/test.html';