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 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
|
# -*- perl -*-
# Copyright (c) 2000, FundsXpress Financial Network, Inc.
# This library is free software released "AS IS WITH ALL FAULTS"
# and WITHOUT ANY WARRANTIES under the terms of the GNU Lesser
# General Public License, Version 2.1, a copy of which can be
# found in the "COPYING" file of this distribution.
# $Id: error.t,v 1.1.1.2 2003/12/06 19:47:27 hartmans Exp $
use strict;
use Test;
use Data::Dumper;
use PSP::Error;
use PSP::Error::Field;
use PSP::Error::Verify;
my $n_iterations = 1;
plan tests => $n_iterations * 26;
my $error;
for (my $i=0; $i < $n_iterations; $i++) {
ok $error = PSP::Error->new("foo");
ok $error->name() eq "foo";
ok $error->add_error("This is an error message.");
ok $error->add_error("This is an bar error message","bar");
ok $error->add_error("This is an baz error message","baz");
ok $error->add_error("This is another bar error message","bar");
ok $error->add_error("This is yet another bar error message","bar");
ok $error->add_error("This is a bar,buf error message","bar","buf");
ok $error->add_error("This is the 4th bar error message","bar");
ok $error->add_error("This is the 2nd bar,buf error message","bar","buf");
ok $error->as_string() eq
"This is an error message.
This is an bar error message
This is another bar error message
This is yet another bar error message
This is the 4th bar error message
This is a bar,buf error message
This is the 2nd bar,buf error message
This is an baz error message\n";
ok $error->as_bullets() eq
"This is an error message.
<ul>
<li>
This is an bar error message<br>
This is another bar error message<br>
This is yet another bar error message<br>
This is the 4th bar error message
<ul>
<li>
This is a bar,buf error message<br>
This is the 2nd bar,buf error message
</ul>
<li>
This is an baz error message
</ul>\n";
ok $error->as_html() eq
"This is an error message.<br>
This is an bar error message<br>
This is another bar error message<br>
This is yet another bar error message<br>
This is the 4th bar error message<br>
This is a bar,buf error message<br>
This is the 2nd bar,buf error message<br>
This is an baz error message<br>\n";
ok !$error->free();
ok $error = PSP::Error::Field->new("");
ok $error->name() eq "";
ok $error->add_error("a bar error.","bar");
ok $error->add_error("a baz error.","baz");
ok $error->add_error("another bar error.","bar");
ok $error->add_error("an erf within foo error.","foo","erf");
ok $error->add_error("a crunph within foo error.","foo","crunph");
ok $error->add_error("a sigh within foo error.","foo","sigh");
ok $error->as_string() eq
"bar:
a bar error.
another bar error.
baz:
a baz error.
foo:erf:
an erf within foo error.
foo:crunph:
a crunph within foo error.
foo:sigh:
a sigh within foo error.\n";
ok $error->as_html() eq
"bar:
a bar error.<br>
another bar error.<br>
baz:
a baz error.<br>
foo:erf:
an erf within foo error.<br>
foo:crunph:
a crunph within foo error.<br>
foo:sigh:
a sigh within foo error.<br>\n";
ok $error->as_bullets() eq
"<ul>
<li>
bar:
a bar error.<br>
another bar error.
<li>
baz:
a baz error.
<li>
<ul>
<li>
foo:erf:
an erf within foo error.
<li>
foo:crunph:
a crunph within foo error.
<li>
foo:sigh:
a sigh within foo error.
</ul>
</ul>\n";
ok !$error->free();
#print Dumper($error);
}
|