File: error.t

package info (click to toggle)
libgd-graph-perl 1.54~ds-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster
  • size: 800 kB
  • sloc: perl: 5,097; makefile: 52; sh: 7
file content (46 lines) | stat: -rw-r--r-- 1,111 bytes parent folder | download | duplicates (8)
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
# $Id: error.t,v 1.1 2005/12/14 04:22:16 ben Exp $
use Test;
use strict;

BEGIN { plan tests => 16 }

use GD::Graph::Error;
ok(1);
# Can't/Shouldn't instantiate a GD::Graph::Error object. Will use
# GD::Graph::Data instead
use GD::Graph::Data;
ok(1);

print "# Check inheritance\n";
my $error = GD::Graph::Data->new();
ok($error);
ok($error->isa("GD::Graph::Error"));
ok($error->isa("GD::Graph::Data"));

print "# Check error and warning level\n";
ok(! $error->has_error);
ok(! $error->has_warning);

print "# Set some warnings and errors\n";
$error->_set_error([2, "One warning"], 
                   [0, "Two warning"], 
                   [1, "Three warning"]);
ok($error->has_warning, 3);
ok($error->has_error, 0);

print "# Set more errors\n";
$error->_set_error([9, "One error"]);
ok($error->has_warning, 3);
ok($error->has_error, 1);

print "# Clear errors\n";
$error->clear_errors;
ok(! $error->has_warning);
ok(! $error->has_error);

print "# Set critical error\n";
eval { $error->_set_error([11, "Critical error"]) };
ok($@, qr/^Critical error/);
ok(! $error->has_warning);
ok($error->has_error, 1);