mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-18 07:33:12 +09:00
Improve exchange string tests
This commit is contained in:
5 files changed
+636
-11
No files matched your search
@@ -5,6 +5,7 @@ const zlib = require("zlib");
|
||||
const lib = require("@clusterio/lib");
|
||||
|
||||
const testStrings = require("./test_strings");
|
||||
const testSettings = require("./test_settings");
|
||||
|
||||
|
||||
// Simple linear congruential random number generator
|
||||
@@ -22,12 +23,40 @@ class Random {
|
||||
|
||||
describe("lib/factorio/exchange_string", function() {
|
||||
describe("readMapExchangeString", function() {
|
||||
it("should parse a valid string", function() {
|
||||
let result = lib.readMapExchangeString(testStrings.default);
|
||||
assert.equal(result.map_gen_settings.seed, 1234567890);
|
||||
it("should parse post v0.16 strings", function() {
|
||||
assert.deepEqual(lib.readMapExchangeString(testStrings.default), {
|
||||
version: [1, 1, 33, 0],
|
||||
unknown: 0,
|
||||
map_gen_settings: testSettings.default_map_gen_settings,
|
||||
map_settings: testSettings.default_map_settings,
|
||||
checksum: 3169422966,
|
||||
});
|
||||
|
||||
result = lib.readMapExchangeString(testStrings.modified);
|
||||
assert.equal(result.checksum, 4092204126);
|
||||
assert.deepEqual(lib.readMapExchangeString(testStrings.modified), {
|
||||
version: [1, 1, 33, 0],
|
||||
unknown: 0,
|
||||
map_gen_settings: testSettings.modified_map_gen_settings,
|
||||
map_settings: testSettings.modified_map_settings,
|
||||
checksum: 4092204126,
|
||||
});
|
||||
});
|
||||
|
||||
it("should parse post v2.0 strings", function() {
|
||||
assert.deepEqual(lib.readMapExchangeString(testStrings.modified_v2), {
|
||||
version: [2, 0, 47, 0],
|
||||
unknown: 0,
|
||||
map_gen_settings: testSettings.modified_v2_map_gen_settings,
|
||||
map_settings: testSettings.modified_v2_map_settings,
|
||||
checksum: 979461261,
|
||||
});
|
||||
|
||||
assert.deepEqual(lib.readMapExchangeString(testStrings.modified_space_age), {
|
||||
version: [2, 0, 47, 0],
|
||||
unknown: 0,
|
||||
map_gen_settings: testSettings.modified_space_age_map_gen_settings,
|
||||
map_settings: testSettings.modified_v2_map_settings,
|
||||
checksum: 1746300027,
|
||||
});
|
||||
});
|
||||
|
||||
it("should handle malformed strings", function() {
|
||||
|
||||
Reference in new issue
Block a user