(define-module (tests test-graphemes-stream) #:use-module (uniseg graphemes stream) #:use-module (srfi srfi-41) #:use-module (srfi srfi-64)) (test-begin "tests-graphemes-stream") ;; silly double-em dash (define stream (string->grapheme-stream "Trans 🏳️‍⚧️ rights are human rights⸺and that's a promise!")) (define* (advance-stream! #:optional (times 1)) (for-each (λ (_) (set! stream (stream-cdr stream))) (make-list times))) (advance-stream! 6) (define trans-flag-grapheme (stream-car stream)) (test-equal "Trans flag stream is correct" "🏳️‍⚧️" (grapheme-string trans-flag-grapheme)) (test-equal "Trans flag is width 2" 2 (grapheme-width trans-flag-grapheme)) (advance-stream! 2) (define r-grapheme (stream-car stream)) (test-equal "r in rights is in correct place" "r" (grapheme-string r-grapheme)) (test-equal "r is width 1" 1 (grapheme-width r-grapheme)) (advance-stream! 23) (define double-em-dash-grapheme (stream-car stream)) (test-equal "double-em-dash is in right place" "⸺" (grapheme-string double-em-dash-grapheme)) (test-equal "double-em-dash is triple-width" 3 (grapheme-width double-em-dash-grapheme)) (advance-stream!) (define a-grapheme (stream-car stream)) (test-equal "advancing one goes to the a" "a" (grapheme-string a-grapheme)) (define empty-stream (string->grapheme-stream "")) (test-equal "a stream of nothing resolves to an empty stream" #t (stream-null? empty-stream)) (test-end "tests-graphemes-stream")