[otrs-cvs] otrs/scripts/test YAML.t,NONE,1.1
"CVS commits notifications of OTRS.org" <[email protected]>
| Newsgroups | gmane.comp.otrs.cvs |
|---|---|
| Message-ID | <[email protected]> |
Comments:
Update of /home/cvs/otrs/scripts/test
In directory lancelot:/tmp/cvs-serv10027/scripts/test
Added Files:
YAML.t
Log Message:
Initial version.
Author: cr
--- NEW FILE: YAML.t ---
# --
# scripts/test/YAML.t - YAML module testscript
# Copyright (C) 2001-2013 OTRS AG, http://otrs.org/
# --
# $Id: YAML.t,v 1.1 2013/01/17 03:40:14 cr Exp $
# --
# This software comes with ABSOLUTELY NO WARRANTY. For details, see
# the enclosed file COPYING for license information (AGPL). If you
# did not receive this file, see http://www.gnu.org/licenses/agpl.txt.
# --
use strict;
use warnings;
use utf8;
use Kernel::System::YAML;
# declare externally defined variables to avoid errors under 'use strict'
use vars qw( $Self %Param );
my $YAMLObject = Kernel::System::YAML->new( %{$Self} );
# Tests for YAML encode method
my @Tests = (
{
Input => undef,
Result => undef,
Name => 'YAML - undef test',
},
{
Input => '',
Result => "--- ''\n",
Name => 'YAML - empty test',
},
{
Input => 'Some Text',
Result => "--- Some Text\n",
Name => 'YAML - simple',
},
{
Input => 42,
Result => "--- 42\n",
Name => 'YAML - simple',
},
{
Input => [ 1, 2, "3", "Foo", 5 ],
Result => "---\n- 1\n- 2\n- '3'\n- Foo\n- 5\n",
Name => 'YAML - simple',
},
{
Input => {
Key1 => "Value1",
Key2 => 42,
"Key3" => "Another Value"
},
Result => "---\nKey1: Value1\nKey2: 42\nKey3: Another Value\n",
Name => 'YAML - simple',
},
{
Input => [
[ 1, 2, "Foo", "Bar" ],
{
Key1 => 'Something',
Key2 => [ "Foo", "Bar" ],
Key3 => {
Foo => 'Bar',
},
Key4 => {
Bar => [ "f", "o", "o" ]
}
},
],
Result =>
"---\n"
. "- - 1\n"
. " - 2\n"
. " - Foo\n"
. " - Bar\n"
. "- Key1: Something\n"
. " Key2:\n"
. " - Foo\n"
. " - Bar\n"
. " Key3:\n"
. " Foo: Bar\n"
. " Key4:\n"
. " Bar:\n"
. " - f\n"
. " - o\n"
. " - o\n",
Name => 'YAM - complex structure',
},
);
for my $Test (@Tests) {
my $YAML = $YAMLObject->Dump(
Data => $Test->{Input},
);
$Self->IsDeeply(
$YAML,
$Test->{Result},
$Test->{Name},
);
}
# YAML::Load()
@Tests = (
{
Result => undef,
InputLoad => undef,
Name => 'YAML - undef test',
},
{
Result => undef,
InputLoad => "--- Key: malformed\n - 1\n",
Name => 'YAML - malformed data test',
},
{
Result => 'Some Text',
InputLoad => "--- Some Text\n",
Name => 'YAML - simple'
},
{
Result => 42,
InputLoad => "--- 42\n",
Name => 'YAML - simple'
},
{
Result => [ 1, 2, "3", "Foo", 5 ],
InputLoad => "---\n- 1\n- 2\n- '3'\n- Foo\n- 5\n",
Name => 'YAML - simple'
},
{
Result => {
Key1 => "Value1",
Key2 => 42,
"Key3" => "Another Value"
},
InputLoad => "---\nKey1: Value1\nKey2: 42\nKey3: Another Value\n",
Name => 'YAML - simple'
},
{
Result => [
[ 1, 2, "Foo", "Bar" ],
{
Key1 => 'Something',
Key2 => [ "Foo", "Bar" ],
Key3 => {
Foo => 'Bar',
},
Key4 => {
Bar => [ "f", "o", "o" ]
}
},
],
InputLoad =>
"---\n"
. "- - 1\n"
. " - 2\n"
. " - Foo\n"
. " - Bar\n"
. "- Key1: Something\n"
. " Key2:\n"
. " - Foo\n"
. " - Bar\n"
. " Key3:\n"
. " Foo: Bar\n"
. " Key4:\n"
. " Bar:\n"
. " - f\n"
. " - o\n"
. " - o\n",
Name => 'YAML - complex structure'
},
);
for my $Test (@Tests) {
my $Perl = $YAMLObject->Load(
Data => $Test->{InputLoad},
);
$Self->IsDeeply(
scalar $Perl,
scalar $Test->{Result},
$Test->{Name},
);
}
1;
---------------------------------------------------------------------
OTRS mailing list: cvs-log - Webpage: http://otrs.org/
Archive: http://lists.otrs.org/pipermail/cvs-log
To unsubscribe: http://lists.otrs.org/cgi-bin/listinfo/cvs-log