Skip to content

Commit

Permalink
unit-testing added
Browse files Browse the repository at this point in the history
  • Loading branch information
sindikat committed Mar 7, 2014
1 parent 55344fe commit 4fa37d3
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 6 deletions.
12 changes: 9 additions & 3 deletions README.org
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
* TODOs

- Optimize unidecode-chars.el, probably the same way, as in Python Unidecode
- In unidecode-unidecode function i can also use (map 'string ...) instead of (apply #'concat (mapcar ...)), but i'm not sure how to require cl-extra.el

* How this package was made

The following is the explanation of the process of converting the
Python package to Emacs Lisp.

The following Python script was used to export Unidecode data to JSON.
The following Python script was run in Unidecode's source directory to
load its data to =final_data= list.

#+BEGIN_SRC python
import os, sys
Expand All @@ -24,7 +30,7 @@ for filename in xs:
final_data.extend(module_data)
#+END_SRC

The following command was used to dump =final_data= to a JSON file.
The following script was used to dump =final_data= to a JSON file.

#+BEGIN_SRC python
import json
Expand All @@ -41,4 +47,4 @@ after installing =json= package in Emacs:
#+END_SRC

After that the resulting vector was just stored verbatim in
"unidecode-chars.el".
=unidecode-chars.el=.
35 changes: 35 additions & 0 deletions unidecode-test.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
;;; unidecode-test.el --- unit tests for Unidecode
;; Copyright (C) 2013 sindikat
;;
;; Author: sindikat <sindikat at mail36 dot net>
;;
;; This file is not part of GNU Emacs.
;;
;; This file is put into public domain to the extend possible by law.
;;
;;; Commentary:

;;

;;; Code:
(require 'ert)

(defun unidecode-test ()
"Unit test Unidecode functions."
(interactive)
(ert "^unidecode-"))

(ert-deftest unidecode-test-unidecode ()
"Check ..."
(let ((s-original "æб¦ ")
(s-decoded "aeb| "))
(let ((result (unidecode-unidecode s-original)))
(should (equal result s-decoded)))))

(ert-deftest unidecode-test-sanitize ()
"..."
(let ((s-original "æб¦ ")
(s-sanitized "aeb-"))
(let ((result (unidecode-sanitize s-sanitized)))
(should (equal result s-sanitized)))))
;;; unidecode-test.el ends here
3 changes: 0 additions & 3 deletions unidecode.el
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@
;; Python Unidecode can be found here:
;; http://pypi.python.org/pypi/Unidecode/
;;
;; * TODO unidecode-chars.el should be heavily optimized, probably the
;; same way, as in Python Unidecode
;;
;; More information in file README.org

;;; Code:
Expand Down

0 comments on commit 4fa37d3

Please sign in to comment.