From ad99ea49de2bda94f1f6af1c14b61401c1696f9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Fri, 27 Oct 2023 21:29:47 +0200 Subject: Tests. --- tests/unit/coverage-supplement.scm | 4 ++++ tests/unit/vcomponent/create.scm | 31 +++++++++++++++++++++++++-- tests/unit/vcomponent/geo.scm | 12 +++++++++++ tests/unit/vcomponent/vcomponent-datetime.scm | 16 +++++++------- tests/unit/vcomponent/vcomponent.scm | 11 ++++++++-- tests/unit/vulgar/vulgar.scm | 11 ++++++++++ 6 files changed, 73 insertions(+), 12 deletions(-) create mode 100644 tests/unit/vcomponent/geo.scm diff --git a/tests/unit/coverage-supplement.scm b/tests/unit/coverage-supplement.scm index d7b5a00c..1abc6a22 100644 --- a/tests/unit/coverage-supplement.scm +++ b/tests/unit/coverage-supplement.scm @@ -62,6 +62,10 @@ "b1c58b3beb6f170d3c9f7d603b27231ccf696897736113095b446f437721a9e1" 2) + ("module/vcomponent/config.scm" + "a7d2da32181d6c4013a9994620458ace4da786be68b2b0a5a14890d736bc4bd7" + 2) + ;; get-terminal-size is basically impossible to test ("module/vulgar/info.scm" "f9f30fd2709a5614b986c697e089c36c7d5d8cd3824e6d4e2bac042d5c2c23e6" diff --git a/tests/unit/vcomponent/create.scm b/tests/unit/vcomponent/create.scm index caf2d33c..537ccbe9 100644 --- a/tests/unit/vcomponent/create.scm +++ b/tests/unit/vcomponent/create.scm @@ -2,12 +2,24 @@ :use-module ((srfi srfi-1) :select (every)) :use-module (srfi srfi-64) :use-module (srfi srfi-88) + :use-module ((vcomponent base) :select (vcomponent?)) :use-module ((vcomponent create) :select (vcomponent with-parameters - as-list)) + + as-list + vcalendar + vevent + vtimezone + standard + daylight)) :use-module ((vcomponent) - :select (children properties type prop prop* param vline?))) + :select (children + properties + type + prop prop* + param + vline?))) ;; vevent, vcalendar, vtimezone, standard, and daylight all trivial ;; and therefore not tested @@ -66,4 +78,19 @@ ;; (test-group "Parameters and lists" ) +(test-assert (vcomponent? (vcalendar))) +(test-eq 'VCALENDAR (type (vcalendar))) + +(test-assert (vcomponent? (vevent))) +(test-eq 'VEVENT (type (vevent))) + +(test-assert (vcomponent? (vtimezone))) +(test-eq 'VTIMEZONE (type (vtimezone))) + +(test-assert (vcomponent? (standard))) +(test-eq 'STANDARD (type (standard))) + +(test-assert (vcomponent? (daylight))) +(test-eq 'DAYLIGHT (type (daylight))) + '((vcomponent create)) diff --git a/tests/unit/vcomponent/geo.scm b/tests/unit/vcomponent/geo.scm new file mode 100644 index 00000000..2cc8ab28 --- /dev/null +++ b/tests/unit/vcomponent/geo.scm @@ -0,0 +1,12 @@ +(define-module (test geo) + :use-module (srfi srfi-64) + :use-module (srfi srfi-64 test-error) + :use-module (srfi srfi-71) + :use-module (srfi srfi-88) + :use-module (vcomponent geo)) + +(test-assert (geo? (geo x: 10 y: 20))) +(test-error 'wrong-type-arg + (geo)) + +'((vcomponent geo)) diff --git a/tests/unit/vcomponent/vcomponent-datetime.scm b/tests/unit/vcomponent/vcomponent-datetime.scm index 80fee259..18616bb4 100644 --- a/tests/unit/vcomponent/vcomponent-datetime.scm +++ b/tests/unit/vcomponent/vcomponent-datetime.scm @@ -12,8 +12,8 @@ (define ev (vevent - dtstart: (datetime year: 2020 month: 03 day: 29 hour: 17 minute: 00 second: 00) - dtend: (datetime year: 2020 month: 04 day: 01 hour: 10 minute: 00 second: 00))) + dtstart: (datetime year: 2020 month: 3 day: 29 hour: 17) + dtend: (datetime year: 2020 month: 4 day: 1 hour: 10))) ;; |-----------------| test interval @@ -23,21 +23,21 @@ "Correct clamping" (datetime time: (time hour: 7)) ; 2020-03-29T17:00 - 2020-03-30T00:00 (event-length/clamped - (date year: 2020 month: 03 day: 23) ; a time way before the start of the event - (date year: 2020 month: 03 day: 29) ; a time slightly after the end of the event + (date year: 2020 month: 3 day: 23) ; a time way before the start of the event + (date year: 2020 month: 3 day: 29) ; a time slightly after the end of the event ev)) (define utc-ev (vevent - dtstart: (datetime year: 2020 month: 03 day: 29 hour: 15 minute: 00 second: 00 tz: "UTC") - dtend: (datetime year: 2020 month: 04 day: 01 hour: 08 minute: 00 second: 00 tz: "UTC"))) + dtstart: (datetime year: 2020 month: 3 day: 29 hour: 15 tz: "UTC") + dtend: (datetime year: 2020 month: 4 day: 1 hour: 8 tz: "UTC"))) (test-equal "Correct clamping UTC" (datetime time: (time hour: 7)) (event-length/clamped - (date year: 2020 month: 03 day: 23) - (date year: 2020 month: 03 day: 29) + (date year: 2020 month: 3 day: 23) + (date year: 2020 month: 3 day: 29) ev)) diff --git a/tests/unit/vcomponent/vcomponent.scm b/tests/unit/vcomponent/vcomponent.scm index 7a9ce96a..2f692d19 100644 --- a/tests/unit/vcomponent/vcomponent.scm +++ b/tests/unit/vcomponent/vcomponent.scm @@ -135,7 +135,14 @@ ;; parameters ;; properties -;; x-property? -;; internal-field? +(test-group "x-property?" + (test-assert (x-property? 'X-Extension)) + (test-assert (not (x-property? 'Regular))) + (test-assert (not (x-property? '-internal)))) + +(test-group "internal-field?" + (test-assert (not (internal-field? 'X-Extension))) + (test-assert (not (internal-field? 'Regular))) + (test-assert (internal-field? '-internal))) '((vcomponent base)) diff --git a/tests/unit/vulgar/vulgar.scm b/tests/unit/vulgar/vulgar.scm index 7771724f..e0021fd1 100644 --- a/tests/unit/vulgar/vulgar.scm +++ b/tests/unit/vulgar/vulgar.scm @@ -12,4 +12,15 @@ (with-output-to-string (lambda () (write "\x1b[21;11H"))) (with-output-to-string (lambda () (write (with-output-to-string (lambda () (set-cursor-pos 10 20))))))) +(test-equal "with-vulgar returning its argument" + 'return + (with-vulgar (lambda () 'return))) + +;;; TODO these tests can test the termios flags outside and inside the +;;; vulgar block Checking that they are +;;; - different. +;;; - what's expected. +;;; - properly restored. +;; (test-group "with-vulgar tty attrs") + '((vulgar)) -- cgit v1.2.3