#!perl -w
use strict;
use Test::More;
use XS::APItest;
use Config;

plan skip_all => "Tests only apply on MSWin32"
  unless $^O eq "MSWin32";

SKIP:
{
    # [perl #126755] previous the bad drive tests would crash
    $Config{ccflags} =~ /(?:\A|\s)-DPERL_IMPLICIT_SYS\b/
      or skip "need implicit_sys for this test", 1;
    eval "use Encode; 1"
      or skip "Can't load Encode", 1;
    for my $letter ("A" .. "Z", "a" .. "z") {
        my $good_drive = $letter . ":";
        my $result = PerlDir_mapA($good_drive);
        like($result, qr/^$letter:\\/i, "check good drive $letter");

        my $wgood_drive = encode("UTF-16LE", $good_drive . "\0");
        $result = PerlDir_mapW($wgood_drive);
        like(decode("UTF16-LE", $result), qr/^$letter:\\/i,
             "check a good drive (wide)");
    }
    for my $bad ('@', '[', '!', '~', '`', '{') {
        my $bad_drive = "$bad:";
        my $result = PerlDir_mapA($bad_drive);
        is($result, $bad_drive, "check bad drive $bad:");

        my $wbad_drive = encode("UTF-16LE", $bad_drive . "\0");
        $result = PerlDir_mapW($wbad_drive);
        is(decode("UTF16-LE", $result), "$bad_drive\0",
           "check bad drive $bad: (wide)");
    }
}

done_testing();
