summaryrefslogtreecommitdiff
path: root/t/cgi.t
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2015-06-16 06:44:29 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2015-06-16 06:44:29 +0000
commitf9f3ab3056d94292adb4ab2e1451645bee989769 (patch)
treecc5a62954d359d5aad449420bc7ec259b3edb79e /t/cgi.t
downloadCGI-tarball-master.tar.gz
Diffstat (limited to 't/cgi.t')
-rw-r--r--t/cgi.t73
1 files changed, 73 insertions, 0 deletions
diff --git a/t/cgi.t b/t/cgi.t
new file mode 100644
index 0000000..19360b2
--- /dev/null
+++ b/t/cgi.t
@@ -0,0 +1,73 @@
+#!/usr/local/bin/perl
+
+# coverage for testing that doesn't sit elsewhere
+
+use strict;
+use warnings;
+
+use Test::More tests => 25;
+use Test::Deep;
+use Test::Warn;
+
+use CGI ();
+
+# Set up a CGI environment
+$ENV{REQUEST_METHOD} = 'GET';
+$ENV{QUERY_STRING} = 'game=chess&game=checkers&weather=dull';
+
+isa_ok( my $q = CGI->new,'CGI' );
+
+# undocumented ->r method, seems to be a temp store?
+$q->r( 'foo' );
+is( $q->r,'foo','r' );
+
+diag( "cgi-lib.pl routines" );
+
+ok( $q->ReadParse,'ReadParse' );
+is( $q->PrintHeader,$q->header,'PrintHeader' );
+is( $q->HtmlTop,$q->start_html,'HtmlTop' );
+is( $q->HtmlBot,$q->end_html,'HtmlBot' );
+
+cmp_deeply(
+ [ my @params = CGI::SplitParam( "foo\0bar" ) ],
+ [ qw/ foo bar /],
+ 'SplitParam'
+);
+
+ok( $q->MethGet,'MethGet' );
+ok( ! $q->MethPost,'MethPost' );
+ok( ! $q->MethPut,'MethPut' );
+
+note( "TIE methods" );
+ok( ! $q->FIRSTKEY,'FIRSTKEY' );
+ok( ! $q->NEXTKEY,'NEXTKEY' );
+ok( ! $q->CLEAR,'CLEAR' );
+
+is( $q->version,$CGI::VERSION,'version' );
+is( $q->as_string,'<ul></ul>','as_string' );
+
+is( ( $q->_style )[0],'<link rel="stylesheet" type="text/css" href="" />','_style' );
+is( $q->state,'http://localhost','state' );
+
+$CGI::NOSTICKY = 0;
+ok( $q->nosticky( 1 ),'nosticky' );
+is( $CGI::NOSTICKY,1,' ... sets $CGI::NOSTICKY' );
+
+$CGI::NPH = 0;
+ok( $q->nph( 1 ),'nph' );
+is( $CGI::NPH,1,' ... sets $CGI::NPH' );
+
+$CGI::CLOSE_UPLOAD_FILES = 0;
+ok( $q->close_upload_files( 1 ),'close_upload_files' );
+is( $CGI::CLOSE_UPLOAD_FILES,1,' ... sets $CGI::CLOSE_UPLOAD_FILES' );
+
+cmp_deeply(
+ $q->default_dtd,
+ [
+ '-//W3C//DTD HTML 4.01 Transitional//EN',
+ 'http://www.w3.org/TR/html4/loose.dtd'
+ ],
+ 'default_dtd'
+);
+
+ok( ! $q->private_tempfiles,'private_tempfiles' );