From 0c0554d767a6cb97c58c3ca7b639f3070e5591f5 Mon Sep 17 00:00:00 2001 From: root Date: Sat, 24 Apr 2021 01:25:37 +0000 Subject: Expand tests --- t/basic.t | 65 ++++++++++++++++++++++++++++++++++++++------------------------- 1 file changed, 39 insertions(+), 26 deletions(-) (limited to 't/basic.t') 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) -less head - -$test = <Test -This is a test page. -END -seek($t, 0, 0); -print $t $test; - -ok GET_BODY('/test.html'), <-less head'; -Test -$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 = ("Test\n", "This is a test page.\n"); +prepare @test; +ok GET_BODY('/test.html'), "${test[0]}$head${test[1]}$foot", + '-less head'; + +@test = ("...\n", "This is a test page.\n"); +prepare @test; +ok GET_BODY('/test.html'), "${test[0]}$head${test[1]}$foot", + '-ful head'; + +@test = ("\n", "This is a test page.\n", "\n"); +prepare @test; +ok GET_BODY('/test.html'), "${test[0]}$head${test[1]}$foot${test[2]}", + '-wrapped document'; + +@test = ("\n", "This is a test page.\n"); +prepare @test; +ok GET_BODY('/test.html'), "${test[0]}$head${test[1]}$foot", + ''; + +@test = ("\n\n", "This is a test page.\n"); +prepare @test; +ok GET_BODY('/test.html'), "${test[0]}$head${test[1]}$foot", + ' with leading newline'; + +unlink 't/htdocs/test.html'; -- cgit v1.2.3