[Pkg-javascript-commits] [node-asn1.js] 115/202: test: 'optional' and 'use'.
Bastien Roucariès
rouca at moszumanska.debian.org
Thu Apr 20 19:18:59 UTC 2017
This is an automated email from the git hooks/post-receive script.
rouca pushed a commit to branch master
in repository node-asn1.js.
commit a631704067a62b215e83ba1f0f4274ecf40db823
Author: felix <felix at userspace.com.au>
Date: Fri Jun 26 16:30:20 2015 +0700
test: 'optional' and 'use'.
---
test/der-decode-test.js | 12 ++++++++++++
test/der-encode-test.js | 13 +++++++++++++
2 files changed, 25 insertions(+)
diff --git a/test/der-decode-test.js b/test/der-decode-test.js
index a898393..fa81b60 100644
--- a/test/der-decode-test.js
+++ b/test/der-decode-test.js
@@ -57,4 +57,16 @@ describe('asn1.js DER decoder', function() {
});
}, '0101ff', { 'type': 'apple', 'value': true });
+ it('should decode optional and use', function() {
+ var B = asn1.define('B', function() {
+ this.int();
+ });
+
+ var A = asn1.define('A', function() {
+ this.optional().use(B);
+ });
+
+ var out = A.decode(new Buffer('020101', 'hex'), 'der');
+ assert.equal(out.toString(10), '1');
+ });
});
diff --git a/test/der-encode-test.js b/test/der-encode-test.js
index f19e75c..fbd91dc 100644
--- a/test/der-encode-test.js
+++ b/test/der-encode-test.js
@@ -68,4 +68,17 @@ describe('asn1.js DER encoder', function() {
this.key('value').int()
);
}, {required: false, value: 1}, '3003020101');
+
+ it('should encode optional and use', function() {
+ var B = asn1.define('B', function() {
+ this.int();
+ });
+
+ var A = asn1.define('A', function() {
+ this.optional().use(B);
+ });
+
+ var out = A.encode(1, 'der');
+ assert.equal(out.toString('hex'), '020101');
+ });
});
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-asn1.js.git
More information about the Pkg-javascript-commits
mailing list