From 59c9347beaae7abde4a6132a9aa478b3fd5ef7bc Mon Sep 17 00:00:00 2001 From: Vivianne Langdon Date: Sun, 3 Mar 2024 21:17:15 -0500 Subject: [PATCH] Unit tests! --- hall.scm | 3 ++- tests/test-uniseg.scm | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 tests/test-uniseg.scm diff --git a/hall.scm b/hall.scm index ac8a64b..b366452 100644 --- a/hall.scm +++ b/hall.scm @@ -30,7 +30,8 @@ (scheme-file "internal"))))) (tests ((directory "tests" - ((scheme-file "test-eastasian-locale"))))) + ((scheme-file "test-eastasian-locale") + (scheme-file "test-uniseg"))))) (programs ((directory "scripts" diff --git a/tests/test-uniseg.scm b/tests/test-uniseg.scm new file mode 100644 index 0000000..d37b1f2 --- /dev/null +++ b/tests/test-uniseg.scm @@ -0,0 +1,38 @@ +(define-module (tests test-uniseg) + #:use-module (uniseg) + #:use-module (srfi srfi-64)) + +(test-begin "test-uniseg") + +(test-equal "linefeed" + 'line-feed (char->grapheme-property #\x000a) ) + +(test-equal "zerowidth joiner" + 'zero-width-joiner (char->grapheme-property #\x200d)) + +(test-equal "doublewidth" + 2 (char-width #\〈)) + +(test-equal "japanese widths" + 36 (string-width "トランスジェンダーの権利は人権です!")) + +(test-equal "korean/hangul" + 27 (string-width "트랜스젠더 권리는 인권이다!")) + +(test-equal "ascii" + 30 (string-width "Trans rights are human rights!")) + +(test-equal "emoji" + 33 (string-width "Trans 🏳️‍⚧️ rights are human rights!")) + +(test-equal "cjk tone mark" + 0 (char-width #\x302B)) + +;; TODO: get practical sentences, sorry to native speakers +(test-equal "cjk with tone mark" + 2 (string-width "⺏〫")) + +(test-equal "cjk tone mark property" + 'extend (char->grapheme-property #\x302B)) + +(test-end "test-uniseg")