mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01:00
3d2aef3979
Use assert.strictEqual instead of assert.equal in tests, manually convert types where necessary. PR-URL: https://github.com/nodejs/node/pull/10698 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Teddy Katz <teddy.katz@gmail.com>
29 lines
851 B
JavaScript
29 lines
851 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const path = require('path');
|
|
const Buffer = require('buffer').Buffer;
|
|
const fs = require('fs');
|
|
|
|
common.refreshTmpDir();
|
|
|
|
const fn = path.join(common.tmpDir, 'write-string-coerce.txt');
|
|
const data = true;
|
|
const expected = data + '';
|
|
|
|
fs.open(fn, 'w', 0o644, common.mustCall(function(err, fd) {
|
|
assert.ifError(err);
|
|
console.log('open done');
|
|
fs.write(fd, data, 0, 'utf8', common.mustCall(function(err, written) {
|
|
console.log('write done');
|
|
assert.ifError(err);
|
|
assert.strictEqual(Buffer.byteLength(expected), written);
|
|
fs.closeSync(fd);
|
|
const found = fs.readFileSync(fn, 'utf8');
|
|
console.log('expected: "%s"', expected);
|
|
console.log('found: "%s"', found);
|
|
fs.unlinkSync(fn);
|
|
assert.strictEqual(expected, found);
|
|
}));
|
|
}));
|