You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
777 B

6 years ago
#!/usr/bin/env ruby
require "test/unit"
require_relative '../lib/ruby_email'
class TestRubyEmail < Test::Unit::TestCase
def test_simple_true
assert "toto@toto".match RubyEmail::REGEXP
assert "toto@toto.toto".match RubyEmail::REGEXP
assert "toto@toto.toto.toto".match RubyEmail::REGEXP
assert "toto@toto.toto.toto.toto".match RubyEmail::REGEXP
end
def test_simple_false
assert_nil "t".match RubyEmail::REGEXP
assert_nil "t@".match RubyEmail::REGEXP
assert_nil "@t".match RubyEmail::REGEXP
end
def test_deep
m = "toto@toto.toto.toto.toto".match RubyEmail::REGEXP
#require 'pry';binding.pry
assert m.names & %w(local domain)
assert_equal "toto", m["local"]
assert_equal "toto.toto.toto.toto", m["domain"]
end
end