X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F01-string.t;h=d29ef2b69252b3c91e4225f1e6c4b1833c0cdc7a;hb=559b5d74cde30be92fb26402bf2bc7e69fab16df;hp=083f7830996f2497fcf791ed6be9c517d22d96fa;hpb=3d272255c992add8dec8be7efb1cda4c650d5b6e;p=gitmo%2FMooseX-Types-Common.git diff --git a/t/01-string.t b/t/01-string.t index 083f783..d29ef2b 100644 --- a/t/01-string.t +++ b/t/01-string.t @@ -2,21 +2,37 @@ use strict; use warnings; -use Test::More tests => 14; +use Test::More tests => 25; use Test::Fatal; +use Test::Exception; { package FooTest; use Moose; use MooseX::Types::Common::String ( - qw(SimpleStr NonEmptySimpleStr Password StrongPassword NonEmptyStr), + qw(SimpleStr + NonEmptySimpleStr + LowerCaseSimpleStr + UpperCaseSimpleStr + Password + StrongPassword + NonEmptyStr + LowerCaseStr + UpperCaseStr + NumericCode + ), ); - has simplestr => ( is => 'rw', isa => SimpleStr); - has nestr => ( is => 'rw', isa => NonEmptyStr); - has nesimplestr => ( is => 'rw', isa => NonEmptySimpleStr); - has password => ( is => 'rw', isa => Password); - has strongpassword => ( is => 'rw', isa => StrongPassword); + has simplestr => ( is => 'rw', isa => SimpleStr ); + has nestr => ( is => 'rw', isa => NonEmptyStr ); + has nesimplestr => ( is => 'rw', isa => NonEmptySimpleStr ); + has lcsimplestr => ( is => 'rw', isa => LowerCaseSimpleStr ); + has ucsimplestr => ( is => 'rw', isa => UpperCaseSimpleStr ); + has password => ( is => 'rw', isa => Password ); + has strongpassword => ( is => 'rw', isa => StrongPassword ); + has lowercasestr => ( is => 'rw', isa => LowerCaseStr ); + has uppercasestr => ( is => 'rw', isa => UpperCaseStr ); + has numericcode => ( is => 'rw', isa => NumericCode ); } my $ins = FooTest->new; @@ -39,3 +55,20 @@ is(exception { $ins->password('okay') }, undef, 'Password 2'); isnt(exception { $ins->strongpassword('notokay') }, undef, 'StrongPassword'); is(exception { $ins->strongpassword('83773r_ch01c3') }, undef, 'StrongPassword 2'); + +isnt(exception { $ins->lcsimplestr('NOTOK') }, undef, 'LowerCaseSimpleStr'); +is(exception { $ins->lcsimplestr('ok') }, undef, 'LowerCaseSimpleStr 2'); + +isnt(exception { $ins->ucsimplestr('notok') }, undef, 'UpperCaseSimpleStr'); +is(exception { $ins->ucsimplestr('OK') }, undef, 'UpperCaseSimpleStr 2'); + +isnt(exception { $ins->lowercasestr('NOTOK') }, undef, 'LowerCaseStr'); +is(exception { $ins->lowercasestr('ok') }, undef, 'LowerCaseStr 2'); + +isnt(exception { $ins->uppercasestr('notok') }, undef, 'UpperCaseStr'); +is(exception { $ins->uppercasestr('OK') }, undef, 'UpperCaseStr 2'); + + +is( exception { $ins->numericcode('032') }, undef, 'NumericCode lives'); +isnt( exception { $ins->numericcode('abc') }, undef, 'NumericCode dies' ); +isnt( exception { $ins->numericcode('x18') }, undef, 'mixed NumericCode dies');