tests, padding

This commit is contained in:
2020-04-24 16:57:50 +02:00
parent ee3ac59561
commit fb0b1ac004
2 changed files with 27 additions and 2 deletions

View File

@ -6,6 +6,7 @@
*/
// @ts-nocheck
/* eslint-disable no-magic-numbers */
'use strict';
const test = require ('ava');
@ -26,3 +27,23 @@ test ('encoding to_utf8', (t) => {
const utf = encoding.to_utf8 ('Zm9v', 'base64');
t.is (utf, 'foo');
});
test ('convert num to hex', (t) => {
const res = encoding.num_to_hex (11);
t.is (res, 'b');
});
test ('convert num to hex padded', (t) => {
const res = encoding.num_to_hex (11, 2);
t.is (res, '0b');
});
test ('convert hex to num', (t) => {
const res = encoding.hex_to_num ('b');
t.is (res, 11);
});
test ('convert hex padded to num', (t) => {
const res = encoding.hex_to_num ('0b');
t.is (res, 11);
});