File: 1.t

package info (click to toggle)
libbit-vector-minimal-perl 1.3-2
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 64 kB
  • ctags: 7
  • sloc: perl: 44; makefile: 38
file content (36 lines) | stat: -rw-r--r-- 779 bytes parent folder | download | duplicates (6)
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
# vim:ft=perl

use Test::More tests => 10;

use_ok("Bit::Vector::Minimal");

{
	my $vec = Bit::Vector::Minimal->new;
	isa_ok $vec => "Bit::Vector::Minimal";

	$vec->set(2);
	is $vec->display(), "00000100", "pattern set correctly for default LE";
	is $vec->get(2), 1, "Bit two set";
	is $vec->get(3), 0, "Bit three not set";
}

{
	my $vec = Bit::Vector::Minimal->new(
		size       => 32,
		width      => 2,
		endianness => "big"
	);
	isa_ok $vec => "Bit::Vector::Minimal";
	$vec->set(2, 0b10);
	is $vec->display(), "00001000000000000000000000000000",
		"pattern set correctly for BE";
}

{
	for (19 .. 21) {
		my $vec = Bit::Vector::Minimal->new(size => $_);
		is $vec->display(), "000000000000000000000000",
			"pattern initialized correctly when size not divisible by 8";
	}
}