mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01:00
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.
This commit is contained in:
parent
8d6fa72d97
commit
f984555d47
@ -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);
|
||||
c[0] = 2576980378;
|
||||
c[1] = 1069128089;
|
||||
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…
Reference in New Issue
Block a user