Reformat all tests for more modern mocha syntax (describe, it)

This commit is contained in:
Andreas Brekken 2014-01-11 13:57:43 +07:00
parent 61992462e3
commit f591cc0111
9 changed files with 299 additions and 257 deletions

View file

@ -1,24 +1,28 @@
/* global describe, it */
var assert = require('assert');
var BigInteger = require('../').BigInteger;
var bytesToHex = require('../').convert.bytesToHex;
var BigInteger = require('../src/jsbn/jsbn.js')
var bytesToHex = require('../src/convert.js').bytesToHex;
test('toByteArraySigned', function() {
function hex(num) {
var bytes = BigInteger.valueOf(num).toByteArraySigned();
var hex = bytesToHex(bytes);
return '0x' + hex;
}
assert.equal(hex( 0), '0x');
assert.equal(hex( 1), '0x01');
assert.equal(hex(-1), '0x81');
assert.equal(hex( 127), '0x7f');
assert.equal(hex(-127), '0xff');
assert.equal(hex( 255), '0x00ff');
assert.equal(hex(-255), '0x80ff');
assert.equal(hex( 16300), '0x3fac');
assert.equal(hex(-16300), '0xbfac');
assert.equal(hex( 62300), '0x00f35c');
assert.equal(hex(-62300), '0x80f35c');
});
describe('BigInteger', function() {
describe('toByteArraySigned', function() {
it('handles examples', function() {
function hex(num) {
var bytes = BigInteger.valueOf(num).toByteArraySigned();
var h = bytesToHex(bytes);
return '0x' + h;
}
assert.equal(hex( 0), '0x');
assert.equal(hex( 1), '0x01');
assert.equal(hex(-1), '0x81');
assert.equal(hex( 127), '0x7f');
assert.equal(hex(-127), '0xff');
assert.equal(hex( 255), '0x00ff');
assert.equal(hex(-255), '0x80ff');
assert.equal(hex( 16300), '0x3fac');
assert.equal(hex(-16300), '0xbfac');
assert.equal(hex( 62300), '0x00f35c');
assert.equal(hex(-62300), '0x80f35c');
})
})
})