UNB/ CS/ David Bremner/ teaching/ cs2613/ assignments/ CS2613 Assignment 2

Background

What to hand in, and how to hand it in

Marking

Dealing with Dates

    (module+ test
      (require rackunit)
      (check-equal? (rfc2822->date "Tue, 26 Oct 2010 15:11:06 +0200")
                    (date* 6 11 15 26 10 2010 2 298 #f 7200 0 ""))
      (check-equal? (rfc2822->date "Sat, 09 Sep 2017 13:40:18 -0700")
                    (date* 18 40 13 9 9 2017 6 251 #f -25200 0 "")))
    (module+ test
      (check-true (rfc2822<? "Tue, 26 Oct 2010 15:11:06 +0200"  "Sun, 10 Sep 2017 13:16:19 +0200"))
      (check-false (rfc2822<? "Tue, 26 Oct 2010 15:11:06 +0200" "Tue, 26 Oct 2010 15:11:06 +0200"))
      (check-false (rfc2822<? "Sun, 10 Sep 2017 13:16:19 +0200" "Tue, 26 Oct 2010 15:11:06 +0200")))
    (module+ test
      (define test-dates
        '("Sun, 10 Sep 2017 09:48:44 +0200"
          "Wed, 13 Sep 2017 17:51:05 +0000"
          "Sun, 10 Sep 2017 13:16:19 +0200"
          "Tue, 17 Nov 2009 18:21:38 -0500"
          "Wed, 13 Sep 2017 10:40:47 -0700"
          "Thu, 14 Sep 2017 12:03:35 -0700"
          "Wed, 18 Nov 2009 02:22:12 -0800"
          "Sat, 09 Sep 2017 13:40:18 -0700"
          "Tue, 26 Oct 2010 15:11:06 +0200"
          "Tue, 17 Nov 2009 18:04:31 -0800"
          "Mon, 17 Oct 2011 04:15:12 +0000"
          "Sun, 16 Oct 2011 23:12:02 -0500"
          "Mon, 11 Sep 2017 14:41:12 +0100"))
        (define sorted-dates
         '("Tue, 17 Nov 2009 18:21:38 -0500"
           "Tue, 17 Nov 2009 18:04:31 -0800"
           "Wed, 18 Nov 2009 02:22:12 -0800"
           "Tue, 26 Oct 2010 15:11:06 +0200"
           "Sun, 16 Oct 2011 23:12:02 -0500"
           "Mon, 17 Oct 2011 04:15:12 +0000"
           "Sat, 09 Sep 2017 13:40:18 -0700"
           "Sun, 10 Sep 2017 09:48:44 +0200"
           "Sun, 10 Sep 2017 13:16:19 +0200"
           "Mon, 11 Sep 2017 14:41:12 +0100"
           "Wed, 13 Sep 2017 10:40:47 -0700"
           "Wed, 13 Sep 2017 17:51:05 +0000"
           "Thu, 14 Sep 2017 12:03:35 -0700"))
      (check-equal?                                          )
    (module+ test
      (define test-hashes (map (lambda (x) (hasheq 'Date x)) test-dates))
      (define sorted-hashes (map (lambda (x) (hasheq 'Date x)) sorted-dates))
      (check-equal? (sort-mail test-hashes) sorted-hashes))

Summarizing Mail

    (module+ test
      (check-equal?
       (sort-mail(summarize-mail "example1.json" 'Date 'From))
       '(#hasheq((Date . "Tue, 17 Nov 2009 18:21:38 -0500")
                 (From . "Aron Griffis <agriffis@n01se.net>"))
         #hasheq((Date . "Tue, 17 Nov 2009 18:04:31 -0800")
                 (From . "Keith Packard <keithp@keithp.com>"))
         #hasheq((Date . "Wed, 18 Nov 2009 02:22:12 -0800")
                 (From . "Carl Worth <cworth@cworth.org>"))))
      (check-equal?
       (take (list-tail (sort-mail (summarize-mail "example2.json" 'Date 'Subject 'From)) 2) 3)
       '(#hasheq((Subject
                  .
                  "Processed: Re: general: can't stop daemon using /etc/init.d/foo stop when disabled via /etc/default/foo")
                 (Date . "Mon, 17 Oct 2011 04:15:12 +0000")
                 (From . "owner@bugs.debian.org (Debian Bug Tracking System)"))
         #hasheq((Subject
                  .
                  "Bug#601455: Steps towards a patch to document disabling a daemon upon installation")
                 (Date . "Sat, 09 Sep 2017 13:40:18 -0700")
                 (From . "Sean Whitton <spwhitton@spwhitton.name>"))
         #hasheq((Subject
                  .
                  "Bug#601455: Steps towards a patch to document disabling a daemon upon installation")
                 (Date . "Sun, 10 Sep 2017 09:48:44 +0200")
                 (From . "md@Linux.IT (Marco d'Itri)")))))