]> Dogcows Code - chaz/p5-CGI-Ex/blobdiff - t/1_validate_00_base.t
add PSGI handler
[chaz/p5-CGI-Ex] / t / 1_validate_00_base.t
index d8ea8df2bc7eb3a2dbcb7d89806273301f2e56fa..e91428ba69b5d737565379952a3f231d980388f8 100644 (file)
@@ -1,8 +1,50 @@
+# -*- Mode: Perl; -*-
 
-BEGIN {
-       print "1..1\n";
-}
+=head1 NAME
 
-use CGI::Ex::Validate;
+1_validate_00_base.t - Test CGI::Ex::Validate's ability to compile and execute
 
-BEGIN { print "ok 1\n"; }
+=cut
+
+use strict;
+use Test::More tests => 5;
+
+use_ok('CGI::Ex::Validate');
+
+my $form = {
+  user => 'abc',
+  pass => '123',
+};
+my $val = {
+  user => {
+    required => 1,
+  },
+  pass => {
+    required => 1,
+  },
+};
+
+my $err_obj = CGI::Ex::Validate::validate($form, $val);
+ok(! $err_obj, "Basic function works");
+
+###----------------------------------------------------------------###
+
+$form = {
+  user => 'abc',
+#  pass => '123',
+};
+
+$err_obj = CGI::Ex::Validate::validate($form,$val);
+
+ok($err_obj, "Successfully failed");
+
+###----------------------------------------------------------------###
+
+eval { CGI::Ex::Validate::validate($form,undef) };
+ok($@, "Needs to have a hashref");
+
+###----------------------------------------------------------------###
+
+$err_obj = CGI::Ex::Validate::validate($form,{});
+
+ok(!$err_obj, "OK with empty hash");
This page took 0.021894 seconds and 4 git commands to generate.