git.fiddlerwoaroof.com
Browse code

parse-email-address tests

Add tests for the new and old features of parse-email-address.

Change-Id: I775c24ee178886472cefd777f15fda22c11217a6

Kevin Layer authored on 31/10/2013 20:27:16
Showing 1 changed files
... ...
@@ -20,6 +20,7 @@
20 20
 ;; requires smtp module too
21 21
 
22 22
 (eval-when (compile load eval)
23
+  (require :rfc2822)
23 24
   (require :smtp)
24 25
   (require :imap)
25 26
   (require :test))
... ...
@@ -243,6 +244,38 @@
243 244
    (net.post-office:decode-header-text "=?utf-8?q?=5BFranz_Wiki=5D_Update_of_=22Office/EmployeeDirectory=22_by_St?=
244 245
  =?utf-8?q?eveHaflich?="))
245 246
   )
247
+
248
+(defun test-parse-email-address ()
249
+  (dolist (good `(("foo@bar.com" "foo" "bar.com")
250
+		  ("layer@franz.com" "layer" "franz.com")
251
+		  ("
252
+
253
+layer@franz.com" "layer" "franz.com")
254
+		  (,(replace-re "XXlayer@franz.comX  X"
255
+				"X"
256
+				(format nil "~c" #\newline)
257
+				:single-line t)
258
+		   "layer" "franz.com")
259
+		  (,(replace-re "XXlayer@franz.comX  X"
260
+				"X"
261
+				(format nil "~c" #\return)
262
+				:single-line t)
263
+		   "layer" "franz.com")
264
+		  ;; local-part length = 64
265
+		  ("1234567890123456789012345678901234567890123456789012345678901234@foo.com"
266
+		   "1234567890123456789012345678901234567890123456789012345678901234"
267
+		   "foo.com")
268
+		  ))
269
+    (multiple-value-bind (local-part domain)
270
+	(net.mail:parse-email-address (first good))
271
+      (test-equal (second good) local-part)
272
+      (test-equal (third good) domain)))
273
+  (dolist (bad (list "@foo.com"
274
+		     ;; local-part length = 65
275
+		     "12345678901234567890123456789012345678901234567890123456789012345@foo.com"
276
+		     ))
277
+    (test-nil (net.mail:parse-email-address bad)))
278
+  )
246 279
 	  
247 280
     
248 281
 (defun test-imap ()
... ...
@@ -250,13 +283,15 @@
250 283
 		  #'(lambda (con)
251 284
 		      (format t "Got imap condition: ~a~%" con))))
252 285
     (test-mime)
286
+    (test-parse-email-address)
253 287
 ;;;; Only jkf is setup to run the tests.
254 288
     (when (string= "jkf" (sys:getenv "USER"))
255 289
       (test-connect)
256 290
       (test-sends)
257 291
       (test-flags)
258 292
       (test-mailboxes)
259
-      (test-pop))))
293
+      (test-pop)
294
+      )))
260 295
 
261 296
 
262 297
 (if* *do-test* then (do-test :imap #'test-imap))