NixExprs: extract the escape function and test it

This commit is contained in:
Graham Christensen
2021-03-17 11:07:19 -04:00
parent aeb3d2f44c
commit d62a2c1657
3 changed files with 48 additions and 16 deletions

25
t/Helper/escape.t Normal file
View File

@ -0,0 +1,25 @@
use strict;
use Setup;
use Data::Dumper;
use Test2::V0;
use Hydra::Helper::Escape;
subtest "checking individual attribute set elements" => sub {
my %values = (
"" => '""',
"." => '"."',
"foobar" => '"foobar"',
"foo.bar" => '"foo.bar"',
"🌮" => '"🌮"',
'foo"bar' => '"foo\"bar"',
'foo\\bar' => '"foo\\\\bar"',
'$bar' => '"\\$bar"',
);
for my $input (keys %values) {
my $value = $values{$input};
is(escapeString($input), $value, "Escaping the value: " . $input);
}
};
done_testing;