1 # Copyright (c) 2005-2008 Zmanda Inc. All Rights Reserved.
3 # This program is free software; you can redistribute it and/or modify it
4 # under the terms of the GNU General Public License version 2 as published
5 # by the Free Software Foundation.
7 # This program is distributed in the hope that it will be useful, but
8 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
9 # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 # You should have received a copy of the GNU General Public License along
13 # with this program; if not, write to the Free Software Foundation, Inc.,
14 # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 # Contact information: Zmanda Inc, 465 S Mathlida Ave, Suite 300
17 # Sunnyvale, CA 94086, USA, or: http://www.zmanda.com
19 use Test::More tests => 28;
21 use lib "@amperldir@";
25 # Data::Dumper is used to output strings with control characters
27 $Data::Dumper::Useqq = 1; # quote strings
28 $Data::Dumper::Terse = 1; # no $VAR1 = ..
29 $Data::Dumper::Indent = 0; # no newlines
31 # most of Amanda::Util is tested via running applications that use it
33 # Tests for quote_string and unquote string. First, some fuzzing of the
34 # quote + unquote round-trip.
41 "\t", "\r", "\n", "\f",
42 '\\\\\\\\', # memory overflow?
46 "line\nanother", # real newline
53 for my $fuzzstr (@fuzzstrs) {
54 is(Amanda::Util::unquote_string(Amanda::Util::quote_string($fuzzstr)), $fuzzstr,
55 "fuzz " . Dumper($fuzzstr));
58 # since users often provide quoted strings (e.g., in config files), test that chosen
59 # quoted strings are correctly unquoted. The need to quote the quoted strings for perl
60 # makes this a little hard to read..
61 my %unquote_checks = (
70 '"\\\\n"' => '\n', # literal \
75 while (my ($qstr, $uqstr) = each %unquote_checks) {
76 is(Amanda::Util::unquote_string($qstr), $uqstr,
77 "unquote " . Dumper($qstr));