Pull translations from Transifex.
[hivex.git] / perl / t / 570-regedit-import2.t
1 # Win::Hivex::Regedit test -*- perl -*-
2 # Copyright (C) 2010 Red Hat Inc.
3 #
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 use strict;
19 use warnings;
20
21 use Encode qw(from_to);
22 use IO::Scalar;
23
24 use Test::More tests => 6;
25
26 use Win::Hivex;
27 use Win::Hivex::Regedit qw(reg_import reg_export);
28
29 my $srcdir = $ENV{srcdir} || ".";
30
31 my $h = Win::Hivex->open ("$srcdir/../images/minimal", write => 1);
32 ok ($h);
33
34 my $data;
35
36 # Note: These tests are supposed to fail.
37
38 # Need a blank line between sections.
39 $data = '
40 [A]
41 [B]';
42 run_test ($data);
43
44 # Invalid header.
45 $data = '
46 [A]B';
47 run_test ($data);
48
49 # Must create intermediate nodes first.
50 $data = '
51 [A\B\C\D]';
52 run_test ($data);
53
54 # Invalid quoting.
55 $data = '
56 [A]
57 "Quote"it"="Hello"';
58 run_test ($data);
59
60 $data = '
61 [A]
62 "Quote it\"="Hello"';
63 run_test ($data);
64
65 # Invalid hex -- fails, 'pack' processes it anyway.
66 #$data = '
67 #[A]
68 #"Key"=hex(1):xy';
69 #run_test ($data);
70
71 #----------------------------------------------------------------------
72
73 sub run_test {
74     my $data = shift;
75
76     eval {
77         my $fh = new IO::Scalar \$data;
78         reg_import ($h, $fh);
79     };
80     #warn "$@\n";
81     ok ($@);
82 }