2019-05-15 01:48:48 +03:00
|
|
|
'use strict';
|
|
|
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
|
|
};
|
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
|
var fs_1 = __importDefault(require("fs"));
|
|
|
|
var path_1 = __importDefault(require("path"));
|
|
|
|
var browserify_zlib_1 = __importDefault(require("browserify-zlib"));
|
2019-11-23 15:38:13 +03:00
|
|
|
var random_1 = require("./random");
|
|
|
|
exports.randomBytes = random_1.randomBytes;
|
|
|
|
exports.randomHexString = random_1.randomHexString;
|
|
|
|
exports.randomNumber = random_1.randomNumber;
|
2019-05-15 01:48:48 +03:00
|
|
|
function saveTests(tag, data) {
|
|
|
|
//let filename = path.resolve(__dirname, 'testcases', tag + '.json.gz');
|
2020-01-07 03:00:55 +03:00
|
|
|
var filename = path_1.default.resolve(__dirname, '../testcases', tag + '.json.gz');
|
2019-05-15 01:48:48 +03:00
|
|
|
fs_1.default.writeFileSync(filename, browserify_zlib_1.default.gzipSync(JSON.stringify(data, undefined, ' ') + '\n'));
|
|
|
|
console.log('Save testcase: ' + filename);
|
|
|
|
}
|
|
|
|
exports.saveTests = saveTests;
|
|
|
|
function loadTests(tag) {
|
2019-08-25 09:39:20 +03:00
|
|
|
var filename = path_1.default.resolve(__dirname, '../testcases', tag + '.json.gz');
|
2019-05-15 01:48:48 +03:00
|
|
|
return JSON.parse(browserify_zlib_1.default.gunzipSync(fs_1.default.readFileSync(filename)).toString());
|
|
|
|
}
|
|
|
|
exports.loadTests = loadTests;
|
|
|
|
function loadData(filename) {
|
|
|
|
return fs_1.default.readFileSync(path_1.default.resolve(__dirname, filename));
|
|
|
|
}
|
|
|
|
exports.loadData = loadData;
|