File modified: lisp/nterm/nterm-ut.el
Change339 at Sat Aug 14 11:07:33 2010 +0200 by Ivan Kanis <ivan@tao>
diff -r 8cc9c31c79d8 -r 790a43ca7c99 lisp/nterm/nterm-ut.el --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lisp/nterm/nterm-ut.el Sat Aug 14 11:07:33 2010 +0200 @@ -0,0 +1,198 @@ +;;; nterm-ut.el --- nterm unit testing + +;;; Commentary: + +;;; THANKS: + +;;; BUGS: + +;;; INSTALLATION: + +;;; Code: +(require 'ert-ui) +(require 'nterm) + +(defun nterm-ut-checksum () + "Display screen and memory checksum. +It places the result in the kill ring." + (interactive) + (let ((string (format "\"%s\" \"%s\"" + (md5 (get-buffer nterm-buffer-name)) + (nterm-mem-checksum)))) + (kill-new string) + (message string))) + +(defun nterm-ut-init () + "Init nterm for unit testing" + (if (get-buffer nterm-buffer-name) + (kill-buffer nterm-buffer-name)) + (setq nterm-unit-testing t) + (nterm-mode)) + + +(defun nterm-ut (md5-buf md5-mem record) + "Emulate sequence RECORD then checksum screen and memory." + (nterm-ut-init) + (nterm-emulate nil record) + (setq nterm-unit-testing nil) + (and + (string= (md5 (get-buffer nterm-buffer-name)) md5-buf) + (string= (nterm-mem-checksum) md5-mem))) + +(ert-deftest nterm-vttest-1-1 () + (should (nterm-ut +"8752c42bb037e167ca4d0b5c1eaa3806" "2601cc448dbfd675b3a32619b3791995" + (concat +" [2J[?3l#8[9;10H[1J" +"[18;60H[0J[1K[9;71H[0K[10;10H[1K[10;71H[0K[11;10H" +"[1K[11;71H[0K[12;10H[1K[12;71H[0K[13;10H[1K[13;71H" +"[0K[14;10H[1K[14;71H[0K[15;10H[1K[15;71H[0K[16;10H" +"[1K[16;71H[0K[17;30H[2K[24;1f*[1;1f*[24;2f*[1;2f*[2" +"4;3f*[1;3f*[24;4f*[1;4f*[24;5f*[1;5f*[24;6f*[1;6f*[2" +"4;7f*[1;7f*[24;8f*[1;8f*[24;9f*[1;9f*[24;10f*[1;10f*" +"[24;11f*[1;11f*[24;12f*[1;12f*[24;13f*[1;13f*[24;14f*" +"[1;14f*[24;15f*[1;15f*[24;16f*[1;16f*[24;17f*[1;17f*[" +"24;18f*[1;18f*[24;19f*[1;19f*[24;20f*[1;20f*[24;21f*[" +"1;21f*[24;22f*[1;22f*[24;23f*[1;23f*[24;24f*[1;24f*[2" +"4;25f*[1;25f*[24;26f*[1;26f*[24;27f*[1;27f*[24;28f*[1" +";28f*[24;29f*[1;29f*[24;30f*[1;30f*[24;31f*[1;31f*[24" +";32f*[1;32f*[24;33f*[1;33f*[24;34f*[1;34f*[24;35f*[1;" +"35f*[24;36f*[1;36f*[24;37f*[1;37f*[24;38f*[1;38f*[24;" +"39f*[1;39f*[24;40f*[1;40f*[24;41f*[1;41f*[24;42f*[1;4" +"2f*[24;43f*[1;43f*[24;44f*[1;44f*[24;45f*[1;45f*[24;4" +"6f*[1;46f*[24;47f*[1;47f*[24;48f*[1;48f*[24;49f*[1;49" +"f*[24;50f*[1;50f*[24;51f*[1;51f*[24;52f*[1;52f*[24;53" +"f*[1;53f*[24;54f*[1;54f*[24;55f*[1;55f*[24;56f*[1;56f" +"*[24;57f*[1;57f*[24;58f*[1;58f*[24;59f*[1;59f*[24;60f" +"*[1;60f*[24;61f*[1;61f*[24;62f*[1;62f*[24;63f*[1;63f*" +"[24;64f*[1;64f*[24;65f*[1;65f*[24;66f*[1;66f*[24;67f*" +"[1;67f*[24;68f*[1;68f*[24;69f*[1;69f*[24;70f*[1;70f*" +"[24;71f*[1;71f*[24;72f*[1;72f*[24;73f*[1;73f*[24;74f*" +"[1;74f*[24;75f*[1;75f*[24;76f*[1;76f*[24;77f*[1;77f*[" +"24;78f*[1;78f*[24;79f*[1;79f*[24;80f*[1;80f*[2;2H+[1D" +"D+[1DD+[1DD+[1DD+[1DD+[1DD+[1DD+[1DD+[1DD+" +"[1DD+[1DD+[1DD+[1DD+[1DD+[1DD+[1DD+[1DD+[1D" +"D+[1DD+[1DD+[1DD+[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1B[0B[10;12H " +" [1B[" +"58D " +" [1B[58D " +" [1B[58D " +" [1B[58D " +" [1B[58D " +" [1B[58D[5A[1CThe screen sho" +"uld be cleared, and have an unbroken bor-[12;13Hder of *'s" +" and +'s around the edge, and exactly in the[13;13Hmiddle" +" there should be a frame of E's around this text[14;13Hwi" +"th one (1) free position around it. Push <RETURN>")))) + +(ert-deftest nterm-vttest-1-3 () + (should (nterm-ut +"3e98ebe35b09b63d405b209dbc53c8d4" "1ab768a2b495fa6e0afac3fb8457fc59" + (concat +"[?7h[?3l[?" +"3lTest of autowrap, mixing control and print characters. T" +"he left/right margins should have letters in order: [3;21" +"r[?6h[19;1HA[19;80Ha [18;80HaB[19;80HB b [19;80HC" +" c[19;2HC [19;80H [18;1HD[18;80Hd[19;1HE[19;80He " +"[18;80HeF[19;80HF f [19;80HG g[19;2HG [19;80H " +"[18;1HH[18;80Hh[19;1HI[19;80Hi [18;80HiJ[19;80HJ j " +"[19;80HK k[19;2HK [19;80H [18;1HL[18;80Hl[19;1HM" +"[19;80Hm [18;80HmN[19;80HN n [19;80HO o[19;2HO " +"[19;80H [18;1HP[18;80Hp[19;1HQ[19;80Hq [18;80HqR[19;" +"80HR r [19;80HS s[19;2HS [19;80H [18;1HT[18;80H" +"t[19;1HU[19;80Hu [18;80HuV[19;80HV v [19;80HW w[" +"19;2HW [19;80H [18;1HX[18;80Hx[19;1HY[19;80Hy [18;" +"80HyZ[19;80HZ z [?6l[r[22;1HPush <RETURN>")))) + +(ert-deftest nterm-vttest-1-5 () + (should (nterm-ut +"ef9d62ea5e6fda8be254102039b3255a" "a80541da236f0833e9c3ef725af7200d" + (concat +"[?" +"3l[2J[1;1HTest of cursor-control characters inside ESC seq" +"uences. Below should be four identical lines: A B C D" +" E F G H I A[2CB[2CC[2CD[2CE[2CF[2CG[2CH[2" +"CI[2C A [ 2CB[ 4CC[ 6CD[ 8CE[ 10CF[ 12CG[ 14CH[ " +"16CI [20lA [1AB [1AC [1AD [1AE [1AF [1AG [1" +"AH [1AI [1A Push <RETURN>")))) + +(ert-deftest nterm-vttest-1-6 () + (should (nterm-ut +"896bbb6c0159f94a75a1415ab62dedda" "ebe079c1fd8b81b5d61ea9188d17dc26" + (concat +"[2J[1;1HTest of leading " +"zeros in ESC sequences. Two lines below you should see the" +" sentence \"This is a correct sentence\".[00000000004;0000000" +"01HT[00000000004;000000002Hh[00000000004;000000003Hi[0000" +"0000004;000000004Hs[00000000004;000000005H [00000000004;00" +"0000006Hi[00000000004;000000007Hs[00000000004;000000008H " +"[00000000004;000000009Ha[00000000004;0000000010H [00000000" +"004;0000000011Hc[00000000004;0000000012Ho[00000000004;0000" +"000013Hr[00000000004;0000000014Hr[00000000004;0000000015He" +"[00000000004;0000000016Hc[00000000004;0000000017Ht[000000" +"00004;0000000018H [00000000004;0000000019Hs[00000000004;00" +"00000020He[00000000004;0000000021Hn[00000000004;0000000022" +"Ht[00000000004;0000000023He[00000000004;0000000024Hn[0000" +"0000004;0000000025Hc[00000000004;0000000026He[20;1HPush <R" +"ETURN>")))) + +;; Copyright (C) 2010 Ivan Kanis +;; Author: Ivan Kanis +;; +;; This program is free software ; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation ; either version 2 of the License, or +;; (at your option) any later version. +;; +;; This program is distributed in the hope that it will be useful, but +;; WITHOUT ANY WARRANTY ; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;; General Public License for more details. +;; +;; You should have received a copy of the GNU General Public License +;; along with this program ; if not, write to the Free Software +;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA