emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/pyim a195116: 更新 pyim-tests.el


From: ELPA Syncer
Subject: [elpa] externals/pyim a195116: 更新 pyim-tests.el
Date: Wed, 8 Dec 2021 08:57:25 -0500 (EST)

branch: externals/pyim
commit a19511679ae5e94e1dfea60fb59fbc0b78c45f1c
Author: Feng Shu <tumashu@163.com>
Commit: Feng Shu <tumashu@163.com>

    更新 pyim-tests.el
---
 pyim-pymap.el       |  4 ++--
 tests/pyim-tests.el | 31 +++++++++++++++++++++++++++++++
 2 files changed, 33 insertions(+), 2 deletions(-)

diff --git a/pyim-pymap.el b/pyim-pymap.el
index 587e622..7b0db60 100644
--- a/pyim-pymap.el
+++ b/pyim-pymap.el
@@ -787,10 +787,10 @@
                    (gethash pinyin pyim-pymap-py2cchar-cache2)
                  (gethash pinyin pyim-pymap-py2cchar-cache1))
              (gethash pinyin pyim-pymap-py2cchar-cache3))))
-      (delete "" output)
+      (setq output (remove "" output))
       (if include-seperator
           output
-        (delete "|" output)))))
+        (remove "|" output)))))
 
 (defun pyim-pymap-cchar2py-get (char-or-str)
   "获取字符或者字符串 CHAR-OR-STR 对应的拼音 code.
diff --git a/tests/pyim-tests.el b/tests/pyim-tests.el
index 688c27b..b638b76 100644
--- a/tests/pyim-tests.el
+++ b/tests/pyim-tests.el
@@ -33,6 +33,7 @@
 (require 'pyim)
 (require 'pyim-dregcache)
 
+;; ** 单元测试前的准备工作
 (defun pyim-test-get-dicts ()
   "当前目录下的词库."
   (let* ((files (directory-files-recursively default-directory "\.pyim$")))
@@ -44,6 +45,7 @@
 (setq pyim-dicts (pyim-test-get-dicts))
 (pyim-dcache-init-variables)
 
+;; ** pyim-common 相关单元测试
 (ert-deftest pyim-test-pyim-permutate-list ()
   (should (equal (pyim-permutate-list '((a b) (c d e) (f)))
                  '((a c f)
@@ -67,6 +69,34 @@
                  '("a-b-c-d" "a-b-c" "a-b")))
   (should (equal (pyim-subconcat nil) nil)))
 
+;; ** pyim-pymap 相关单元测试
+(ert-deftest pyim-test-pyim-pymap ()
+  (should (equal (pyim-pymap-cchar< "的" "成") t))
+  (should (equal (pyim-pymap-cchar2py-get "阿")
+                 '("e" "a")))
+  (should (equal (pyim-pymap-cchar2py-get ?阿)
+                 '("e" "a")))
+  (should (equal (pyim-pymap-cchar2py-get "你")
+                 '("ni")))
+  (should (equal (pyim-pymap-cchar2py-get "作")
+                 '("zuo")))
+  (should (equal (pyim-pymap-py2cchar-get "a" t)
+                 '("阿啊呵腌|嗄吖锕||錒")))
+  (should (equal (pyim-pymap-py2cchar-get "a" t t)
+                 '("阿" "啊" "呵" "腌" "嗄" "吖" "锕" "錒")))
+  (should (equal (pyim-pymap-py2cchar-get "a" t t t)
+                 '("阿" "啊" "呵" "腌" "|" "嗄" "吖" "锕" "|" "|" "錒")))
+  (should (equal (pyim-pymap-py2cchar-get "zhua" t)
+                 '("抓挝爪||髽|膼撾檛簻")))
+  (should (equal (mapcar (lambda (x)
+                           (concat (substring x 0 1)
+                                   (substring x -1)))
+                         (pyim-pymap-py2cchar-get "a"))
+                 '("阿錒" "爱溾" "厂馣" "昂䇦" "奥泑")))
+  (should (equal (length (pyim-pymap-py2cchar-get "a")) 5))
+  (should (equal (length (pyim-pymap-py2cchar-get "z")) 36)))
+
+;; ** pyim-cstring 相关单元测试
 (ert-deftest pyim-test-pyim-cstring-partition ()
   (should (equal (pyim-cstring-partition "你好 hello 你好")
                  '("你好" " hello " "你好")))
@@ -203,6 +233,7 @@
       (should (equal (pyim-cstring-words-at-point)
                      '(("天安门" 3 0) ("安门" 2 0)))))))
 
+;; ** pyim-dregcache 相关单元测试
 (ert-deftest pyim-test-pyim-general ()
   (let ((pyim-dcache-backend 'pyim-dregcache))
     (with-temp-buffer



reply via email to

[Prev in Thread] Current Thread [Next in Thread]