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
|
use Test2::V0 -no_srand => 1;
use FFI::Platypus::Lang::Win32;
{
require FFI::Platypus::Type::WideString;
my($encoding,$width) = eval { FFI::Platypus::Type::WideString->_compute_wide_string_encoding() };
if(my $error = $@)
{
$error =~ s/ at .*$//;
skip_all "Unable to detect wide string details: $error\n";
}
note "encoding = $encoding";
note "width = $width";
}
subtest 'native type map diagnostic' => sub {
my $map = FFI::Platypus::Lang::Win32->native_type_map;
foreach my $alias (sort keys %$map)
{
my $type = $map->{$alias};
note sprintf("%-30s %s", $alias, $type);
}
pass 'good';
};
my $ffi = FFI::Platypus->new( api => 1, lib => [undef] );
subtest 'load' => sub {
local $@ = "";
eval { $ffi->lang('Win32') };
is "$@", "";
};
my @strings = (
[ "trivial" => "" ],
[ "simple" => "abcde" ],
[ "fancy" => "abcd\x{E9}" ],
[ "complex" => "I \x{2764} Platypus" ],
);
subtest 'LPCWSTR' => sub {
skip_all 'Test only works on Windows' unless $^O eq 'MSWin32';
my $lstrlenW = $ffi->function( lstrlenW => [ 'LPCWSTR' ] => 'int' );
foreach my $test (@strings)
{
my($name, $string) = @$test;
is($lstrlenW->call($string), length($string), $name);
}
};
subtest 'LPWSTR' => sub {
skip_all 'Test only works on Windows' unless $^O eq 'MSWin32';
my $GetCurrentDirectoryW = $ffi->function( GetCurrentDirectoryW => ['DWORD','LPWSTR'] => 'DWORD' );
my $size = $GetCurrentDirectoryW->call(0, undef);
cmp_ok $size, '>', 0;
my $buf = "\0" x ($size*2);
$GetCurrentDirectoryW->call($size, \$buf);
note "buf = $buf";
ok( -d $buf, "returned directory exists");
};
done_testing;
|