File: unicode-key.t

package info (click to toggle)
libipc-sharelite-perl 0.17-5
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 184 kB
  • sloc: ansic: 585; perl: 436; makefile: 13
file content (35 lines) | stat: -rw-r--r-- 712 bytes parent folder | download | duplicates (5)
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
#!perl

use strict;
use warnings;
use Test::More tests => 3;
use IPC::ShareLite;

my $share1 = eval {
  IPC::ShareLite->new(
    '-key'     => "AAA\x{104}",    # in hex it's 41 41 41 c4 84
    '-create'  => 'yes',
    '-destroy' => 'no',
  );
};
like $@, qr/not 8-bit clean/, '8-bit clean error (1)';

my $share2 = eval {
  IPC::ShareLite->new(
    '-key'     => "AAA\x{118}",    # in hex it's 41 41 41 c4 98
    '-create'  => 'yes',
    '-destroy' => 'no',
  );
};
like $@, qr/not 8-bit clean/, '8-bit clean error (2)';

if ( $share1 and $share2 ) {
  $share1->store( 'Hello world' );
  ok !defined $share2->fetch, 'unicode key aliasing';
}
else {
  pass 'unicode keys rejected';
}

# vim:ts=2:sw=2:et:ft=perl