File: 04___functions.t

package info (click to toggle)
libbit-vector-perl 7.4-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,008 kB
  • sloc: perl: 6,703; ansic: 3,654; makefile: 9
file content (133 lines) | stat: -rw-r--r-- 2,507 bytes parent folder | download | duplicates (12)
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
#!perl -w

use strict;
no strict "vars";

use Bit::Vector;

# ======================================================================
#   $set->Norm();
#   $set->Min();
#   $set->Max();
# ======================================================================

print "1..21\n";

$lim = 997;

$set = new Bit::Vector($lim);

$norm = $set->Norm();
$min = $set->Min();
$max = $set->Max();

$n = 1;
if ($norm == 0)
{print "ok $n\n";} else {print "not ok $n\n";}
$n++;
if ($min > $lim)
{print "ok $n\n";} else {print "not ok $n\n";}
$n++;
if ($max < -$lim)
{print "ok $n\n";} else {print "not ok $n\n";}
$n++;

$set->Fill();
$norm = $set->Norm();
$min = $set->Min();
$max = $set->Max();

if ($norm == $lim)
{print "ok $n\n";} else {print "not ok $n\n";}
$n++;
if ($min == 0)
{print "ok $n\n";} else {print "not ok $n\n";}
$n++;
if ($max == $lim-1)
{print "ok $n\n";} else {print "not ok $n\n";}
$n++;

$set->Empty();
$set->Bit_On(0);
$set->Bit_On($lim-1);
$norm = $set->Norm();
$min = $set->Min();
$max = $set->Max();

if ($norm == 2)
{print "ok $n\n";} else {print "not ok $n\n";}
$n++;
if ($min == 0)
{print "ok $n\n";} else {print "not ok $n\n";}
$n++;
if ($max == $lim-1)
{print "ok $n\n";} else {print "not ok $n\n";}
$n++;

$set->Empty();
$set->Bit_On(0);
$norm = $set->Norm();
$min = $set->Min();
$max = $set->Max();

if ($norm == 1)
{print "ok $n\n";} else {print "not ok $n\n";}
$n++;
if ($min == 0)
{print "ok $n\n";} else {print "not ok $n\n";}
$n++;
if ($max == 0)
{print "ok $n\n";} else {print "not ok $n\n";}
$n++;

$set->Empty();
$set->Bit_On($lim-1);
$norm = $set->Norm();
$min = $set->Min();
$max = $set->Max();

if ($norm == 1)
{print "ok $n\n";} else {print "not ok $n\n";}
$n++;
if ($min == $lim-1)
{print "ok $n\n";} else {print "not ok $n\n";}
$n++;
if ($max == $lim-1)
{print "ok $n\n";} else {print "not ok $n\n";}
$n++;

$set->Empty();
$set->Bit_On(1);
$set->Bit_On($lim-2);
$norm = $set->Norm();
$min = $set->Min();
$max = $set->Max();

if ($norm == 2)
{print "ok $n\n";} else {print "not ok $n\n";}
$n++;
if ($min == 1)
{print "ok $n\n";} else {print "not ok $n\n";}
$n++;
if ($max == $lim-2)
{print "ok $n\n";} else {print "not ok $n\n";}
$n++;

$set->Empty();
$set->Bit_On(int($lim/2));
$norm = $set->Norm();
$min = $set->Min();
$max = $set->Max();

if ($norm == 1)
{print "ok $n\n";} else {print "not ok $n\n";}
$n++;
if ($min == int($lim/2))
{print "ok $n\n";} else {print "not ok $n\n";}
$n++;
if ($max == int($lim/2))
{print "ok $n\n";} else {print "not ok $n\n";}
$n++;

__END__