Skip to content

Commit

Permalink
Adding more tests for universal primitives
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohammad Shokuienia committed Dec 10, 2018
1 parent d8a3bd5 commit 64f5c00
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const TAG_OCTET_STRING = 4;
const TAG_NULL = 5;
const TAG_ENUMERATED = 10;
const TAG_SEQUENCE = 16;
const TAG_IA5STRING = 22;

test('fromTree: class mismatch', (t) => {
const tree = {
Expand Down Expand Up @@ -543,6 +544,21 @@ test('toTree: universal primitive', (t) => {
t.deepEqual(asn1Mapper.toTree(mapped, definition), tree);
});

test('toTree: universal string primitive', (t) => {
const mapped = Buffer.from([ 1, 2, 3 ]);
const definition = {
type: 'IA5String'
};
const tree = {
cls: CLS_UNIVERSAL,
form: FORM_PRIMITIVE,
tagCode: TAG_IA5STRING,
value: Buffer.from([ 1, 2, 3 ])
};

t.deepEqual(asn1Mapper.toTree(mapped, definition), tree);
});

test('toTree: encoding qualified OCTET STRING', (t) => {
const mapped = Buffer.from([ 1, 2, 3 ]);
const definition = {
Expand Down

0 comments on commit 64f5c00

Please sign in to comment.