factor/basis/validators/validators-tests.factor

57 lines
1.5 KiB
Factor
Raw Normal View History

IN: validators.tests
2008-05-26 01:48:02 -04:00
USING: kernel sequences tools.test validators accessors
namespaces assocs ;
[ "" v-one-line ] must-fail
[ "hello world" ] [ "hello world" v-one-line ] unit-test
[ "hello\nworld" v-one-line ] must-fail
[ "" v-one-word ] must-fail
[ "hello" ] [ "hello" v-one-word ] unit-test
[ "hello world" v-one-word ] must-fail
[ "foo" v-number ] must-fail
[ 123 ] [ "123" v-number ] unit-test
2008-05-26 01:48:02 -04:00
[ 123 ] [ "123" v-integer ] unit-test
[ "1.0" v-integer ] [ "must be an integer" = ] must-fail-with
[ "slava@factorcode.org" ] [
"slava@factorcode.org" v-email
] unit-test
[ "slava+foo@factorcode.org" ] [
"slava+foo@factorcode.org" v-email
] unit-test
[ "slava@factorcode.o" v-email ]
[ "invalid e-mail" = ] must-fail-with
[ "sla@@factorcode.o" v-email ]
[ "invalid e-mail" = ] must-fail-with
[ "slava@factorcodeorg" v-email ]
[ "invalid e-mail" = ] must-fail-with
[ "http://www.factorcode.org" ]
[ "http://www.factorcode.org" v-url ] unit-test
[ "http:/www.factorcode.org" v-url ]
[ "invalid URL" = ] must-fail-with
2008-05-27 02:18:38 -04:00
[ 4561261212345467 ] [ "4561261212345467" v-credit-card ] unit-test
[ 4561261212345467 ] [ "4561-2612-1234-5467" v-credit-card ] unit-test
[ 0 ] [ "0000000000000000" v-credit-card ] unit-test
[ "000000000" v-credit-card ] must-fail
[ "0000000000000000000000000" v-credit-card ] must-fail
[ "4561_2612_1234_5467" v-credit-card ] must-fail
[ "4561-2621-1234-5467" v-credit-card ] must-fail
2008-11-18 17:16:24 -05:00
[ t ] [ "http://double.co.nz/w?v=foo" dup v-url = ] unit-test