summaryrefslogtreecommitdiffstats
path: root/tests/text.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2021-11-20 06:01:42 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2021-11-20 06:19:39 +0000
commit56eec1de7018759c0ec251dba4455c18f73c3bbd (patch)
tree3aeb2d10356530bc2cc3f24e74f41048a13885b4 /tests/text.js
parentInitial commit. (diff)
downloadzmodemjs-56eec1de7018759c0ec251dba4455c18f73c3bbd.tar.xz
zmodemjs-56eec1de7018759c0ec251dba4455c18f73c3bbd.zip
Adding upstream version 0.1.10+dfsg.upstream/0.1.10+dfsgupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/text.js')
-rwxr-xr-xtests/text.js45
1 files changed, 45 insertions, 0 deletions
diff --git a/tests/text.js b/tests/text.js
new file mode 100755
index 0000000..cdb5200
--- /dev/null
+++ b/tests/text.js
@@ -0,0 +1,45 @@
+#!/usr/bin/env node
+
+"use strict";
+
+var tape = require('blue-tape');
+
+var Zmodem = require('../src/zmodem');
+
+var ZText = Zmodem.Text;
+
+const TEXTS = [
+ [ "-./", [45, 46, 47] ],
+ [ "épée", [195, 169, 112, 195, 169, 101] ],
+ [ "“words”", [226, 128, 156, 119, 111, 114, 100, 115, 226, 128, 157] ],
+ [ "🍊", [240, 159, 141, 138] ],
+ [ "🍊🍊", [240, 159, 141, 138, 240, 159, 141, 138] ],
+];
+
+tape('decoder', function(t) {
+ var decoder = new ZText.Decoder();
+
+ TEXTS.forEach( (tt) => {
+ t.is(
+ decoder.decode( new Uint8Array(tt[1]) ),
+ tt[0],
+ `decode: ${tt[1]} -> ${tt[0]}`
+ );
+ } );
+
+ t.end();
+} );
+
+tape('encoder', function(t) {
+ var encoder = new ZText.Encoder();
+
+ TEXTS.forEach( (tt) => {
+ t.deepEquals(
+ encoder.encode(tt[0]),
+ new Uint8Array( tt[1] ),
+ `encode: ${tt[0]} -> ${tt[1]}`
+ );
+ } );
+
+ t.end();
+} );