| 1 | #!/usr/bin/perl | ||
| 2 | |||
| 3 | 2 | ▶ | use utf8; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | |||
| 5 | package KiokuDB::Test::Fixture::Binary; | ||
| 6 | 2 | ▶ | use Moose; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | |||
| 8 | 2 | ▶ | use Encode; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 9 | 2 | ▶ | use Test::More; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 10 | |||
| 11 | 2 | ▶ | use KiokuDB::Test::Person; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 12 | 2 | ▶ | use KiokuDB::Test::Employee; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 13 | 2 | ▶ | use KiokuDB::Test::Company; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 14 | |||
| 15 | 2 | ▶ | use namespace::clean -except => 'meta'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 16 | |||
| 17 | 2 | ▶ | use constant required_backend_roles => qw(BinarySafe); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 18 | |||
| 19 | 2 | with qw(KiokuDB::Test::Fixture) => { excludes => 'required_backend_roles' }; | |
| 20 | |||
| 21 | 2 | my $utf8 = "חיים"; | |
| 22 | |||
| 23 | 2 | utf8::encode($utf8); | |
| 24 | |||
| 25 | 2 | my $bytes = pack("C*", 39, 233, 120, 20, 40, 150, 0, 0, 0, 0, 0, 210, 211, 222, 1 ); | |
| 26 | |||
| 27 | sub create { | ||
| 28 | |||
| 29 | return ( | ||
| 30 | 17 | ▶ | KiokuDB::Test::Person->new( |
|
Subroutine
create: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 31 | binary => $utf8, | ||
| 32 | ), | ||
| 33 | KiokuDB::Test::Person->new( | ||
| 34 | binary => $bytes, | ||
| 35 | ), | ||
| 36 | ); | ||
| 37 | } | ||
| 38 | |||
| 39 | sub verify { | ||
| 40 | 17 | ▶ | my $self = shift; |
|
Subroutine
verify: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 41 | |||
| 42 | $self->txn_lives(sub { | ||
| 43 | 17 | ▶ | my ( $enc, $bin ) = $self->lookup_ok( @{ $self->populate_ids } ); |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 44 | |||
| 45 | 17 | isa_ok( $enc, "KiokuDB::Test::Person" ); | |
| 46 | 17 | isa_ok( $bin, "KiokuDB::Test::Person" ); | |
| 47 | |||
| 48 | 17 | ok( !Encode::is_utf8($enc->binary), "preserved utf8 bytes" ); | |
| 49 | 17 | my $enc_decoded = Encode::decode( utf8 => $enc->binary ); | |
| 50 | 17 | ok( Encode::is_utf8($enc_decoded), "decoded cleanly" ); | |
| 51 | 17 | is( $enc_decoded, "חיים", "decoded to correct value" ); | |
| 52 | |||
| 53 | 17 | ok( !Encode::is_utf8($bin->binary), "preserved arbitrary bytes" ); | |
| 54 | 17 | is( length($bin->binary), length($bytes), "bytes not truncated" ); | |
| 55 | 17 | is( unpack("H*", $bin->binary), unpack("H*", $bytes), "bytes equal" ); | |
| 56 | 17 | }); | |
| 57 | } | ||
| 58 | |||
| 59 | 2 | __PACKAGE__ | |
| 60 | |||
| 61 | __END__ | ||