mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-11 23:04:52 +09:00
31 lines
985 B
JavaScript
31 lines
985 B
JavaScript
const assert = require('assert').strict;
|
|
|
|
const luaTools = require('lib/luaTools');
|
|
|
|
|
|
describe("lib/luaTools", function() {
|
|
describe("escapeString()", function() {
|
|
it("should escape backslashes", function() {
|
|
assert.equal(luaTools.escapeString("\\a"), "\\\\a");
|
|
});
|
|
it("should escape double quotes", function() {
|
|
assert.equal(luaTools.escapeString('"a"'), '\\"a\\"');
|
|
});
|
|
it("should escape single quotes", function() {
|
|
assert.equal(luaTools.escapeString("'a'"), "\\'a\\'");
|
|
});
|
|
it("should escape nul bytes", function() {
|
|
assert.equal(luaTools.escapeString("a\0b"), "a\\0b");
|
|
});
|
|
it("should escape newlines", function() {
|
|
assert.equal(luaTools.escapeString("a\nb"), "a\\nb");
|
|
});
|
|
it("should escape carriage return", function() {
|
|
assert.equal(luaTools.escapeString("a\rb"), "a\\rb");
|
|
});
|
|
it("should escape all combined", function() {
|
|
assert.equal(luaTools.escapeString("a\\b\"c'd\0e\nf\rg"), "a\\\\b\\\"c\\'d\\0e\\nf\\rg");
|
|
});
|
|
});
|
|
});
|