Created
September 25, 2012 12:36
-
-
Save miyohide/3781517 to your computer and use it in GitHub Desktop.
正規表現のサンプル
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# pass_check.rb | |
# coding: utf-8 | |
def pass_check(password) | |
password =~ /[[:alnum:]!\"#\$%&\'\(\)]/ | |
end | |
# test_pass_check.rb | |
# coding: utf-8 | |
require 'test/unit' | |
require './pass_check' | |
class TestPassCheck < Test::Unit::TestCase | |
def test_pass_check | |
%w(a b c 0 1 2 ! " # $ % & ' \( \)).each do |i| | |
assert_equal(0, pass_check(i)) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment