nterm unit testing : add first section of vttest

 

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
+"
[?3l#8"
+""
+"[1K"
+"[0K"
+"[1K****[2"
+"4;3f********[2"
+"4;7f********"
+"[24;11f*******"
+"[1;14f*******["
+"24;18f*******["
+"1;21f*******[2"
+"4;25f*******[1"
+";28f*******[24"
+";32f*******[1;"
+"35f*******[24;"
+"39f*******[1;4"
+"2f*******[24;4"
+"6f*******[1;49"
+"f*******[24;53"
+"f*******"
+"*******"
+"********"
+"*******"
+"*******"
+"[24;71f*******"
+"[1;74f*******["
+"24;78f******+"
+"D+D+D+D+D+D+D+D+D+"
+"[1DD+D+D+D+D+D+D+D+"
+"D+D+D+D+D+M+M+M+"
+"[1DM+M+M+M+M+M+M+M+"
+"M+M+M+M+M+M+M+M+M+["
+"1DM+M**E**E**["
+"10DE**E**E**E*[8;80"
+"H*E**E**
**
*"
+"*
**
**
**"
+"
**
**
**
*"
+"[19;80H*
**
**
**"
+"[10D
**
++[2"
+"D+++++["
+"0C++++["
+"1C+++++"
+"[2D+++++"
+"++++"
+"+++++[0"
+"C++++[1"
+"C+++++["
+"2D+++++"
+"[0C++++"
+"[1C+++++"
+"++++"
+"+++++[2"
+"D+++++["
+"0C++++["
+"1C+++++"
+"[2D+++[1"
+"C++++[0"
+"D+++++"
+"[1D++++"
+"[1C++++"
+"[0D++++"
+"+++++[1"
+"D++++[1"
+"C++++[0"
+"D+++++"
+"[1D++++"
+"[1C++++"
+"[0D++++"
+"+++++[1"
+"D++++[1"
+"C++++[0"
+"D+++++"
+"[1D++++"
+"[1C    "
+"                                                      ["
+"58D                                                         "
+"                                                   "
+"                                                   "
+"                                                   "
+"                                                   "
+"                             The screen sho"
+"uld be cleared,  and have an unbroken bor-der of *'s"
+" and +'s around the edge,   and exactly in themiddle"
+"  there should be a frame of E's around this  textwi"
+"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[?6hAa
aBB b
C"
+"		cC

DdEe
"
+"eFF f
G		gG

"
+"[18;1HHhIi
iJJ j
"
+"[19;80HK		kK

LlM"
+"[19;80Hm
mNN n
O		oO
"
+"[19;80H
PpQq
qR[19;"
+"80HR r
S		sS

T"
+"tUu
uVV v
W		w["
+"19;2HW

XxYy
[18;"
+"80HyZZ z
[?6lPush <RETURN>"))))
+
+(ert-deftest nterm-vttest-1-5 ()
+  (should (nterm-ut 
+"ef9d62ea5e6fda8be254102039b3255a" "a80541da236f0833e9c3ef725af7200d"
+ (concat
+"[?"
+"3lTest 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

A [1AB [1AC [1AD [1AE [1AF [1AG [1"
+"AH [1AI [1A



Push <RETURN>"))))
+
+(ert-deftest nterm-vttest-1-6 ()
+  (should (nterm-ut 
+"896bbb6c0159f94a75a1415ab62dedda" "ebe079c1fd8b81b5d61ea9188d17dc26"
+ (concat
+"Test of leading "
+"zeros in ESC sequences.

Two lines below you should see the"
+" sentence \"This is a correct sentence\".[00000000004;0000000"
+"01HThi[0000"
+"0000004;000000004Hs [00000000004;00"
+"0000006His "
+"[00000000004;000000009Ha [00000000"
+"004;0000000011Hco[00000000004;0000"
+"000013Hrre"
+"ct[000000"
+"00004;0000000018H s[00000000004;00"
+"00000020Hen[00000000004;0000000022"
+"Hten[0000"
+"0000004;0000000025HcePush <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


back