;; Basic test
;;
;; This file is part of Beastie <https://purl.org/nxg/dist/beastie>
;; SPDX-FileCopyrightText: 2023 Norman Gray <https://nxg.me.uk>
;; SPDX-License-Identifier: BSD-2-Clause

(check
 (assert-equal (map entry->list/debug (sort! (map cdr DB) entry<?))
               '((book T1-2:UPPERCASE
                       (author . #"Another Author")
                       (month . #"jan")
                       (publisher . #"Someone")
                       (title . #"Book title")
                       (year . #"2000"))
                 (article t1-1
                          (author . #"Sample {Author} and Last, First")
                          (journal . #"Irreproducible Results")
                          (note . #"Final note")
                          (title . #"Article title")
                          (uri1 . #"http://example.org/%30")
                          (uri2 . #"http://example.org/%31")
                          (year . #"1999"))
                 (article t3)
                 (article t4)))
 #;(assert-equal (map entry->list/debug (sort! (map cdr DB) entry<?))
               `((book T1-2:UPPERCASE
                       (author . ,(T "Another Author"))
                       (month . jan) ;symbol/string reference
                       (publisher . ,(T "Someone"))
                       (title . ,(T "Book title"))
                       (year . ,(T "2000")))
                 (article t1-1
                          (author . ,(T "Sample {Author} and Last, First"))
                          (journal . ,(T "Irreproducible Results"))
                          (note . ,(T "Final note"))
                          (title . ,(T "Article title"))
                          (uri1 . ,(T "http://example.org/%30"))
                          (uri2 . ,(T "http://example.org/%31"))
                          (year . ,(T "1999")))
                 (article t3)
                 (article t4)))
 (let ((e1 (DB 'T1-2:UPPERCASE)))
   (assert-true (entry? e1))
   (assert-equal (entry-field e1 'author) #"Another Author")))

% comment hides @article{invisible-entries}

Also add some interesting whitespace (CR, FF and VT).

@  Article 	{  t1-1 ,
  author =       {Sample {Author} and Last, First},  % comment
  title =        "Article title",                  % vertical tab

  journal =      {Irreproducible Results},
         % CR


  year =         1999,                             % form-feed


      % comment

      % comment
      % comment

  note = "Final note",
  uri1 = {http://example.org/%30},  % <-- that isn't a comment
  uri2 = "http://example.org/%31",  % <-- and nor is that
}

We preserve the case of citation keys, but nothing else.

Add some different line-endings, CRLF, CR, NEL, LINE SEPARATOR and PARAGRAPH SEPARATOR
@Book{T1-2:UPPERCASE,
  Author =       {Another Author},
  TITLE =        {Book title},  PuBlIsHeR =    {Someone},   YEAR =         2000,   MONTH =        JAN                   % string references are case-insensitive
}

An empty entry
@article{t3}

Another, with a trailing comma
@article{t4 , }
