Skip to content

Instantly share code, notes, and snippets.

@tomoyamkung
Last active December 16, 2015 10:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomoyamkung/5417856 to your computer and use it in GitHub Desktop.
Save tomoyamkung/5417856 to your computer and use it in GitHub Desktop.
[Ruby]文字列削除の動作確認スニペット
# encoding: utf-8
class StringDelete
def delete(str, del)
str.delete(del)
end
end
if __FILE__ == $0
require 'test/unit'
class StringDeleteTest < Test::Unit::TestCase
def setup
@obj = StringDelete.new
end
def test_delete_hankaku
str = 'abced'
del = 'bce'
assert_equal('ad', @obj.delete(str, del))
end
def test_delete_zenkaku
str = 'あいうえお'
del = 'いうえ'
assert_equal('あお', @obj.delete(str, del))
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment