;;; address.lisp --- tests for the e-mail address parser ;;; Copyright (C) 2007, 2009 by Walter C. Pelissero ;;; Copyright (C) 2022 by The TVL Authors ;;; Author: Walter C. Pelissero ;;; Project: mime4cl ;;; This library is free software; you can redistribute it and/or ;;; modify it under the terms of the GNU Lesser General Public License ;;; as published by the Free Software Foundation; either version 2.1 ;;; of the License, or (at your option) any later version. ;;; This library is distributed in the hope that it will be useful, ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;;; Lesser General Public License for more details. ;;; You should have received a copy of the GNU Lesser General Public ;;; License along with this library; if not, write to the Free ;;; Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA ;;; 02111-1307 USA (in-package :mime4cl-tests) (defun test-parsing (string) (format nil "~{~A~^, ~}" (parse-addresses string))) (deftest address-parse-simple.1 (test-parsing "foo@bar") "foo@bar") (deftest address-parse-simple.2 (test-parsing "foo@bar.com") "foo@bar.com") (deftest address-parse-simple.3 (test-parsing "foo@bar.baz.com") "foo@bar.baz.com") (deftest address-parse-simple.4 (test-parsing "foo.ooo@bar.baz.com") "foo.ooo@bar.baz.com") ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (deftest address-parse-simple-commented.1 (test-parsing "foo@bar (Some Comment)") "\"Some Comment\" ") (deftest address-parse-simple-commented.2 (test-parsing "foo@bar (Some, Comment)") "\"Some, Comment\" ") (deftest address-parse-simple-commented.3 (test-parsing "foo@bar (Some Comment (yes, indeed))") "\"Some Comment (yes, indeed)\" ") (deftest address-parse-simple-commented.4 (test-parsing "foo.bar@host.complicated.domain.net (Some Comment (yes, indeed))") "\"Some Comment (yes, indeed)\" ") ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (deftest address-parse-angle.1 (test-parsing "") "foo@bar.baz.net") (deftest address-parse-angle.2 (test-parsing "My far far friend ") "\"My far far friend\" ") (deftest address-parse-angle.3 (test-parsing "\"someone, I don't like\" ") "\"someone, I don't like\" ") (deftest address-parse-angle.4 (test-parsing "\"this could (be a comment)\" ") "\"this could (be a comment)\" ") (deftest address-parse-angle.5 (test-parsing "don't be fooled ") "\"don't be fooled\" ") (deftest address-parse-angle.6 (test-parsing "") "foo@bar") ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (deftest address-parse-domain-literal.1 (test-parsing "") "foo@[bar]") (deftest address-parse-domain-literal.2 (test-parsing "") "foo@[bar.net]") (deftest address-parse-domain-literal.3 (test-parsing "") "foo@[10.0.0.2]") (deftest address-parse-domain-literal.4 (test-parsing "") "foo.bar@[10.0.0.2]") (deftest address-parse-domain-literal.5 (test-parsing "somewhere unkown ") "\"somewhere unkown\" ") (deftest address-parse-domain-literal.6 (test-parsing "\"Some--One\" ") "\"Some--One\" ") ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (deftest address-parse-group.1 (test-parsing "friends:john@bar.in.soho, jack@pub.round.the.corner, jim@[10.0.1.2];") "friends: john@bar.in.soho, jack@pub.round.the.corner, jim@[10.0.1.2];") ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (deftest address-parse-mixed.1 (test-parsing "Foo BAR , \"John, Smith (that one!)\" , friends:john@bar,jack@pub;, foo.bar.baz@wow.mail.mine, dont.bark@me (Fierce Dog)") "\"Foo BAR\" , \"John, Smith (that one!)\" , friends: john@bar, jack@pub;, foo.bar.baz@wow.mail.mine, \"Fierce Dog\" ")