Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test file for testing Blob.read-int8
Created a new directory for these tests. Also, did not add this to rakudo's spectest.data as it presently still has quite a number of failures.
- Loading branch information
Showing
1 changed file
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
use v6; | ||
use Test; | ||
|
||
my @uintbufs = | ||
Blob.new(1,2,3,4), 'Blob1234', | ||
Blob[uint8].new(1,2,3,4), 'Blobuint1234', | ||
Blob.new((^256).roll(4)), 'Blobrandom', | ||
Blob[uint8].new((^256).roll(4)), 'Blobuintrandom', | ||
Blob[uint8].new((-128..127).roll(4)), 'Blobuintnegrandom', | ||
; | ||
my @intbufs = | ||
Blob[int8].new(1,2,3,4), 'Blobint1234', | ||
Blob[int8].new(-1,-2,-3,-4), 'Blobint-1-2-3-4', | ||
Blob[int8].new((^256).roll(4)), 'Blobintposrandom', | ||
Blob[int8].new((-128..127).roll(4)), 'Blobintnegrandom', | ||
; | ||
|
||
my $uintcells = @uintbufs.map( -> \buf, \name { buf.elems }).sum; | ||
my $intcells = @intbufs.map( -> \buf, \name { buf.elems }).sum; | ||
plan ($uintcells + $intcells) * 4; | ||
|
||
for @uintbufs -> \buffer, $name { | ||
for ^buffer.elems { | ||
is buffer.read-uint8($_), buffer[$_], "is $name $_ correct"; | ||
|
||
# endianness doesn't matter for byte sized reads | ||
for native-endian, little-endian, big-endian -> $endian { | ||
is buffer.read-uint8($_,$endian), buffer[$_], | ||
"is $name $_ $endian correct"; | ||
} | ||
} | ||
} | ||
|
||
for @intbufs -> \buffer, $name { | ||
for ^buffer.elems { | ||
is buffer.read-int8($_), buffer[$_], "is $name $_ correct"; | ||
|
||
# endianness doesn't matter for byte sized reads | ||
for native-endian, little-endian, big-endian -> $endian { | ||
is buffer.read-int8($_,$endian), buffer[$_], | ||
"is $name $_ $endian correct"; | ||
} | ||
} | ||
} | ||
|
||
# vim: ft=perl6 expandtab sw=4 |