Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from diasbruno/feature/setup-unit-testing
Setup unit testing
- Loading branch information
Showing
3 changed files
with
96 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
(defpackage #:utf8-input-stream.tests | ||
(:use :cl)) | ||
|
||
(in-package #:utf8-input-stream.tests) | ||
|
||
(5am:def-suite utf8-test-suite) | ||
|
||
(5am:in-suite utf8-test-suite) | ||
|
||
(defmacro with-utf8-input-stream ((var source) &body body) | ||
`(let ((,var (utf8-input-stream:make-utf8-input-stream | ||
(flex:make-in-memory-input-stream | ||
(flex:string-to-octets ,source :external-format | ||
(flex:make-external-format :utf-8)))))) | ||
,@body)) | ||
|
||
(5am:def-test read-a-single-ascii-character-of-a-string () | ||
(with-utf8-input-stream (s "a simple string") | ||
(5am:is (char-equal (read-char s) #\a)))) | ||
|
||
(5am:def-test peek-a-single-ascii-character-of-a-string () | ||
(with-utf8-input-stream (s "a simple string") | ||
(5am:is (char-equal (peek-char t s) (read-char s))))) | ||
|
||
(5am:def-test unread-a-single-ascii-character-of-a-string () | ||
(with-utf8-input-stream (s "a simple string") | ||
(unread-char (read-char s) s) | ||
(5am:is (char-equal (peek-char t s) #\a)))) | ||
|
||
(5am:def-test read-a-single-utf8-character-of-a-string () | ||
(with-utf8-input-stream (s "été") | ||
(5am:is (string-equal (string (read-char s)) "é")))) | ||
|
||
(5am:def-test peek-a-single-utf8-character-of-a-string () | ||
(with-utf8-input-stream (s "été") | ||
(5am:is (string-equal (string (peek-char t s)) | ||
(string (read-char s)))))) | ||
|
||
(5am:def-test unread-a-single-utf8-character-of-a-string () | ||
(with-utf8-input-stream (s "été") | ||
(unread-char (read-char s) s) | ||
(5am:is (string-equal (string (peek-char t s)) "é")))) | ||
|
||
(5am:def-test read-a-single-utf8-wide-character-of-a-string () | ||
(with-utf8-input-stream (s "ก and 𨭎") | ||
(5am:is (string-equal (string (read-char s)) "ก")))) | ||
|
||
(5am:def-test peek-a-single-utf8-wide-character-of-a-string () | ||
(with-utf8-input-stream (s "ก and 𨭎") | ||
(5am:is (string-equal (string (peek-char t s)) | ||
(string (read-char s)))))) | ||
|
||
(5am:def-test unread-a-single-utf8-wide-character-of-a-string () | ||
(with-utf8-input-stream (s "ก and 𨭎") | ||
(unread-char (read-char s) s) | ||
(5am:is (string-equal (string (peek-char t s)) "ก")))) | ||
|
||
(5am:def-test read-a-single-utf8-wide-character-of-a-string2 () | ||
(with-utf8-input-stream (s "𨭎 and ก") | ||
(5am:is (string-equal (string (read-char s)) "𨭎")))) | ||
|
||
(5am:def-test peek-a-single-utf8-wide-character-of-a-string2 () | ||
(with-utf8-input-stream (s "𨭎 and ก") | ||
(5am:is (string-equal (string (peek-char t s)) | ||
(string (read-char s)))))) | ||
|
||
(5am:def-test unread-a-single-utf8-wide-character-of-a-string2 () | ||
(with-utf8-input-stream (s "𨭎 and ก") | ||
(unread-char (read-char s) s) | ||
(5am:is (string-equal (string (peek-char t s)) "𨭎")))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
;;;; rulegen.asd | ||
|
||
(asdf:defsystem #:utf8-input-stream.tests | ||
:description "A UTF-8 string input stream over a binary stream for Common Lisp" | ||
:author "Vee Satayamas <vsatayamas@gmail.com>" | ||
:license "MIT" | ||
:version "0.0.1" | ||
:serial t | ||
:depends-on (#:fiveam | ||
#:flexi-streams | ||
#:utf8-input-stream) | ||
:components ((:file "tests"))) |