[test] add ert testing for property "EMAIL" value format regexp matching
This commit is contained in:
parent
7231f8b2b8
commit
2b3a3866aa
1 changed files with 53 additions and 0 deletions
53
test-org-contacts.el
Normal file
53
test-org-contacts.el
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
(require 'ert)
|
||||||
|
|
||||||
|
|
||||||
|
(ert-deftest ert-test-org-contacts-property-email-value-extracting-regexp ()
|
||||||
|
"Testing org-contacts property `EMAIL' value extracting regexp rule."
|
||||||
|
(let ((regexp-rule
|
||||||
|
;; "\\[\\[mailto:\\(.*\\)\\]\\(\\[.*\\]\\)\\]" ; valid
|
||||||
|
"\\[\\[mailto:\\(.*\\)\\]\\(\\[.*\\]\\)\\]\\(,\\ *\\[\\[mailto:\\(.*\\)\\]\\(\\[.*\\]\\)\\]\\)" ; valid
|
||||||
|
))
|
||||||
|
(let ((pvalue "huangtc@outlook.com")) ; normal email
|
||||||
|
(if (string-match regexp-rule pvalue)
|
||||||
|
(should (string-equal (match-string 1 pvalue) "yantar92@posteo.net"))
|
||||||
|
pvalue))
|
||||||
|
|
||||||
|
(let ((pvalue "huangtc@outlook.com,")) ; has comma separator
|
||||||
|
(if (string-match regexp-rule pvalue)
|
||||||
|
(should (string-equal (match-string 1 pvalue) "yantar92@posteo.net"))
|
||||||
|
pvalue))
|
||||||
|
|
||||||
|
(let ((pvalue "huangtc@outlook.com, tristan.j.huang@gmail.com,"))
|
||||||
|
(if (string-match regexp-rule pvalue)
|
||||||
|
(should (string-equal (match-string 1 pvalue) "yantar92@posteo.net"))
|
||||||
|
pvalue))
|
||||||
|
|
||||||
|
(let ((pvalue "[[mailto:yantar92@posteo.net]]"))
|
||||||
|
(if (string-match regexp-rule pvalue)
|
||||||
|
(should (string-equal (match-string 1 pvalue) "yantar92@posteo.net"))
|
||||||
|
pvalue))
|
||||||
|
|
||||||
|
(let ((pvalue "[[mailto:yantar92@posteo.net][yantar92@posteo.net]]"))
|
||||||
|
(if (string-match regexp-rule pvalue)
|
||||||
|
(should (string-equal (match-string 1 pvalue) "yantar92@posteo.net"))
|
||||||
|
pvalue))
|
||||||
|
|
||||||
|
(let ((pvalue "[[mailto:yantar92@posteo.net][yantar92@posteo.net]], [[mailto:yantar92@gmail.com][yantar92@gmail.com]]"))
|
||||||
|
(if (string-match regexp-rule pvalue)
|
||||||
|
(should (string-equal (match-string 1 pvalue) "yantar92@posteo.net"))
|
||||||
|
pvalue))
|
||||||
|
))
|
||||||
|
|
||||||
|
;;; literal testing
|
||||||
|
|
||||||
|
;; (let ((regexp-rule "\\[\\[mailto:\\(.*\\)\\]\\(\\[.*\\]\\)\\]")
|
||||||
|
;; (pvalue "[[mailto:yantar92@posteo.net][yantar92@posteo.net]]"))
|
||||||
|
;; (if (string-match regexp-rule pvalue)
|
||||||
|
;; (match-string 1 pvalue)
|
||||||
|
;; pvalue))
|
||||||
|
|
||||||
|
;; (let ((regexp-rule "\\[\\[mailto:\\(.*\\)\\]\\(\\[.*\\]\\)\\]\\(,\\ *\\[\\[mailto:\\(.*\\)\\]\\(\\[.*\\]\\)\\]\\)")
|
||||||
|
;; (pvalue "[[mailto:yantar92@posteo.net][yantar92@posteo.net]], [[mailto:yantar92@gmail.com][yantar92@gmail.com]]"))
|
||||||
|
;; (if (string-match regexp-rule pvalue)
|
||||||
|
;; (match-string 1 pvalue)
|
||||||
|
;; pvalue))
|
Loading…
Reference in a new issue