Skip to content

Commit 834f153

Browse files
committed
test: add mocha test, TODO ci
1 parent 93a6feb commit 834f153

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

.evergreen/config.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,10 @@ buildvariants:
263263
display_name: RHEL 8.0
264264
run_on: rhel80-small
265265
tasks: [".node", ".web", "check-eslint-plugin"]
266+
# - name: linux-zseries
267+
# display_name: RHEL 8.3 zSeries
268+
# run_on: rhel83-zseries-small
269+
# tasks: [".node", ".web"]
266270
- name: lint
267271
display_name: lint
268272
run_on: rhel80-small

test/node/utils/number_utils.test.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,32 @@
11
import { expect } from 'chai';
22
import { NumberUtils } from '../../../src/utils/number_utils';
33

4+
const FLOAT = new Float64Array(1);
5+
const FLOAT_BYTES = new Uint8Array(FLOAT.buffer, 0, 8);
6+
7+
FLOAT[0] = -1;
8+
// Little endian [0, 0, 0, 0, 0, 0, 240, 191]
9+
// Big endian [240, 191, 0, 0, 0, 0, 0, 0]
10+
const isBigEndian = FLOAT_BYTES[7] === 0;
11+
412
describe('NumberUtils', () => {
13+
context(`handles ${isBigEndian ? 'big' : 'little'} endianness correctly`, () => {
14+
context('getFloat64LE()', () => {
15+
it('should return -1', () => {
16+
const res = NumberUtils.getFloat64LE(new Uint8Array([0, 0, 0, 0, 0, 0, 240, 191]), 0);
17+
expect(res).to.equal(-1);
18+
});
19+
});
20+
21+
context('setFloat64LE()', () => {
22+
it('should return -1 as little endian bytes', () => {
23+
const buf = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0]);
24+
NumberUtils.setFloat64LE(buf, 0, -1);
25+
expect(buf).to.deep.equal(new Uint8Array([0, 0, 0, 0, 0, 0, 240, 191]));
26+
});
27+
});
28+
});
29+
530
/** Make a Uint8Array in a less verbose way */
631
const b = (...values) => new Uint8Array(values);
732

0 commit comments

Comments
 (0)