From: Ken Youens-Clark Date: Wed, 7 May 2003 20:37:33 +0000 (+0000) Subject: Updated tests to match new code. X-Git-Tag: v0.02~136 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=9c62867ae8fa016a8257c9a844c5d48d55711c95;p=dbsrgits%2FSQL-Translator.git Updated tests to match new code. --- diff --git a/t/06xsv.t b/t/06xsv.t index 10aa09a..ed8107c 100644 --- a/t/06xsv.t +++ b/t/06xsv.t @@ -1,21 +1,21 @@ #!/usr/bin/perl # vim: set ft=perl: + # +# Tests for xSV parser # - use strict; use SQL::Translator; use SQL::Translator::Parser::xSV qw(parse); -use Test::More; - -plan tests => 10; +use Test::More tests => 13; my $tr = SQL::Translator->new; -my $data = q|One, Two, Three, Four, Five -I, Am, Some, Data, Yo -And, So, am, I, "you crazy, crazy bastard" -);|; +my $data = q|One, Two, Three, Four, Five, Six, Seven +I, Am, Some, Data, Yo, -10, .04 +And, So, am, I, "you crazy, crazy bastard", 500982, 1.1 +|; +$tr->parser_args( trim_fields => 1, scan_fields => 1 ); my $val = parse($tr, $data); # $val holds the processed data structure. @@ -36,17 +36,26 @@ is($indices->[0]->{'fields'}->[0], 'One', "correct index name"); # $val->{'table1'} should have two fields, id and a_sessionn my $fields = $val->{'table1'}->{'fields'}; -is(scalar keys %{$fields} => 5 => "5 fields in %fields"); +is(scalar keys %{$fields} => 7 => "7 fields in %fields"); is($fields->{'One'}->{'data_type'}, 'char', "\$fields->{'One'}->{'data_type'} == 'char'"); +my $size = join(',', @{ $fields->{'One'}{'size'} } ); +is( $size, 3, "\$fields->{'One'}->{'size'} == 3"); + is($fields->{'One'}->{'is_primary_key'} => 1, "\$fields->{'One'}->{'is_primary_key'} == 1"); ok(! defined $fields->{'Two'}->{'is_primary_key'}, "\$fields->{'Two'}->{'is_primary_key'} == 0"); +is($fields->{'Six'}->{'data_type'}, 'integer', + "\$fields->{'Six'}->{'data_type'} == 'integer'"); + +is($fields->{'Seven'}->{'data_type'}, 'float', + "\$fields->{'Seven'}->{'data_type'} == 'float'"); + # Test that the order is being maintained by the internal order # data element my @order = sort { $fields->{$a}->{'order'}