From 3d0850364eb2099ff7f047642ae1c48e82cfb1a7 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Tue, 23 Dec 2008 01:59:35 +0100 Subject: Add test framework and `rss-2' unit tests. * Makefile.am (SUBDIRS): Add `tests'. * configure.ac: Produce `tests/Makefile'. * src/guile/Makefile.am (EXTRA_DIST): Add SRFI-64 files. * tests: New directory. --- tests/.gitignore | 1 + tests/Makefile.am | 8 ++++ tests/readers/rss-2.test | 95 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 104 insertions(+) create mode 100644 tests/.gitignore create mode 100644 tests/Makefile.am create mode 100644 tests/readers/rss-2.test (limited to 'tests') diff --git a/tests/.gitignore b/tests/.gitignore new file mode 100644 index 0000000..50e1322 --- /dev/null +++ b/tests/.gitignore @@ -0,0 +1 @@ +/*.log diff --git a/tests/Makefile.am b/tests/Makefile.am new file mode 100644 index 0000000..50d1381 --- /dev/null +++ b/tests/Makefile.am @@ -0,0 +1,8 @@ +TESTS_ENVIRONMENT = \ + $(GUILE) -L $(top_srcdir)/src/guile -L $(top_builddir)/src/guile + +TESTS = readers/rss-2.test + +EXTRA_DIST = $(TESTS) + +CLEANFILES = rss-2.log diff --git a/tests/readers/rss-2.test b/tests/readers/rss-2.test new file mode 100644 index 0000000..e6014f5 --- /dev/null +++ b/tests/readers/rss-2.test @@ -0,0 +1,95 @@ +;;; Excercise RSS 2.0 reader. -*- Scheme -*- +;;; +;;; Copyright (C) 2008 Ludovic Courtès +;;; +;;; This file is part of Skribilo. +;;; +;;; Skribilo 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 3 of the License, or (at +;;; your option) any later version. +;;; +;;; Skribilo 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 program. If not, see . + +(define-module (tests rss-2) + :use-module (ice-9 match) + :use-module (skribilo reader) + :use-module (srfi srfi-64)) + +(if (or (not (false-if-exception (resolve-interface '(sxml simple)))) + (not (false-if-exception (resolve-interface '(htmlprag))))) + (exit 77)) + +(define %rss2-read #f) + + +(define-macro (test-match name pattern xml) + `(test-equal ,name #t + (match (%rss2-read (open-input-string ,xml)) + (,pattern #t) + (_ #f)))) + +;; Since `match' doesn't support keywords, help it. +(define (kw:title? x) (eq? x #:title)) + + +(test-begin "rss-2") + +(test-eq "make-reader" #t + (begin + (set! %rss2-read (make-reader 'rss-2)) + (procedure? %rss2-read))) + +(test-match "basic" + `(document ,'#:title (list "The Channel") + (chapter ,'#:title (list "Foo Bar") + ,_ + (list "Hello world."))) + +" + + + The Channel + http://example.net/ + Some channel description... + + + Foo Bar + Mon, 06 Jun 2005 23:05:00 +0200 + Hello world. + + + ") + +(test-match "with HTML markup" + `(document ,'#:title (list (emph "The") " Channel") + (chapter ,'#:title (list "Foo " (bold "&") " Bar") + ,_ + (list (p "Hello world.")))) + +" + + + <em>The</em> Channel + http://example.net/ + Some channel description... + + + Foo <b>&</b> Bar + Mon, 06 Jun 2005 23:05:00 +0200 + <P>Hello world.</P> + + + ") + +(test-end "rss-2") + + +(exit (= (test-runner-fail-count (test-runner-current)) 0)) + -- cgit v1.2.3