Re: [Libguestfs] [PATCH 3/7] perl: Add test for "special" keys and values

Richard W.M. Jones
Mon, 13 Jan 2014 13:18:52 -0000

On Sat, Jan 11, 2014 at 12:12:48AM +0100, Hilko Bengen
wrote:
> ---
>  perl/t/130-special.t | 34 ++++++++++++++++++++++++++++++++++
>  1 file changed, 34 insertions(+)
>  create mode 100644 perl/t/130-special.t
>
> diff --git a/perl/t/130-special.t b/perl/t/130-special.t
> new file mode 100644
> index 0000000..c25af7e
> --- /dev/null
> +++ b/perl/t/130-special.t
> @@ -0,0 +1,34 @@
> +# hivex Perl bindings -*- perl -*-
> +
> +use strict;
> +use warnings;
> +use utf8::all; # so the strings in this file are interpreted correctly.
> +use Test::More;
> +
> +use Win::Hivex;
> +
> +my $srcdir = $ENV{srcdir} || ".";
> +my $h = Win::Hivex->open ("$srcdir/../images/special");
> +ok $h, 'hive opened correctly';
> +my $root = $h->root;
> +ok $root, 'root node found';
> +my ($node, $value);
> +
> +my @nodes = $h->node_children( $root );
> +
> +($node) = grep { $h->node_name($_) eq 'abcd_äöüß' } @nodes;
> +ok $node, q<'abcd_äöüß' (node) has been found>;
> +($value) = grep { $h->value_key($_) eq 'abcd_äöüß' }
$h->node_values($node);
> +ok $value, q<'abcd_äöüß\abcd_äöüß' (value) has been found>;
> +
> +($node) = grep { $h->node_name($_) eq "zero\0key" } @nodes;
> +ok $node, 'key has been found';
> +($value) = grep { $h->value_key($_) eq "zero\0val" }
$h->node_values($node);
> +ok $value, 'value has been found';
> +
> +($node) = grep { $h->node_name($_) eq 'weird™' } @nodes;
> +ok $node, q<'weird™' (node) has been found>;
> +($value) = grep { $h->value_key($_) eq 'symbols $£₤₧€' }
$h->node_values($node);
> +ok $value, q<'weird™\symbols $£₤₧€' (value) has been found>;
> +
> +done_testing;

ACK.

Rich.

--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming blog: http://rwmj.wordpress.com
Fedora now supports 80 OCaml packages (the OPEN alternative to F#)