Browse Source

test: make test-smalloc endian aware

The test/simple/test-smalloc.js has an implicit assumption
of the byte order of the data stored for Double and Uint32
values. On a big endian platform this test fails without
these patches.

Use os.endianness() to detect the endian of the platform
and use it to gate the static value used for comparison.
v0.11.13-release
Andrew Low 11 years ago
committed by Fedor Indutny
parent
commit
f984555d47
  1. 6
      test/simple/test-smalloc.js

6
test/simple/test-smalloc.js

@ -21,6 +21,7 @@
var common = require('../common');
var assert = require('assert');
var os = require('os');
// first grab js api's
var smalloc = require('smalloc');
@ -150,8 +151,13 @@ for (var i = 0; i < 6; i++) {
var b = alloc(1, Types.Double);
var c = alloc(2, Types.Uint32);
if (os.endianness() === 'LE') {
c[0] = 2576980378;
c[1] = 1069128089;
} else {
c[0] = 1069128089;
c[1] = 2576980378;
}
copyOnto(c, 0, b, 0, 2);
assert.equal(b[0], 0.1);

Loading…
Cancel
Save