diff options
author | Kim Alvefur <zash@zash.se> | 2020-10-15 16:51:16 +0200 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2020-10-15 16:51:16 +0200 |
commit | 66f3fe9d1263faa27e5cd82cc4dfa18b6311cd3c (patch) | |
tree | 4c997bb8ea79972f789b687bf54260336a2befcb /spec/util_strbitop.lua | |
parent | 4f4140fbc363160f859292c8b1eccd701ad7b1e1 (diff) | |
parent | da8eca639abefd5419651d59f83ef06ba9113358 (diff) | |
download | prosody-66f3fe9d1263faa27e5cd82cc4dfa18b6311cd3c.tar.gz prosody-66f3fe9d1263faa27e5cd82cc4dfa18b6311cd3c.zip |
Merge 0.11->trunk
Diffstat (limited to 'spec/util_strbitop.lua')
-rw-r--r-- | spec/util_strbitop.lua | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/spec/util_strbitop.lua b/spec/util_strbitop.lua new file mode 100644 index 00000000..58a13772 --- /dev/null +++ b/spec/util_strbitop.lua @@ -0,0 +1,41 @@ +local strbitop = require "util.strbitop"; +describe("util.strbitop", function () + describe("sand()", function () + it("works", function () + assert.equal(string.rep("Aa", 100), strbitop.sand(string.rep("a", 200), "Aa")); + end); + it("returns empty string if first argument is empty", function () + assert.equal("", strbitop.sand("", "")); + assert.equal("", strbitop.sand("", "key")); + end); + it("returns initial string if key is empty", function () + assert.equal("hello", strbitop.sand("hello", "")); + end); + end); + + describe("sor()", function () + it("works", function () + assert.equal(string.rep("a", 200), strbitop.sor(string.rep("Aa", 100), "a")); + end); + it("returns empty string if first argument is empty", function () + assert.equal("", strbitop.sor("", "")); + assert.equal("", strbitop.sor("", "key")); + end); + it("returns initial string if key is empty", function () + assert.equal("hello", strbitop.sor("hello", "")); + end); + end); + + describe("sxor()", function () + it("works", function () + assert.equal(string.rep("Aa", 100), strbitop.sxor(string.rep("a", 200), " \0")); + end); + it("returns empty string if first argument is empty", function () + assert.equal("", strbitop.sxor("", "")); + assert.equal("", strbitop.sxor("", "key")); + end); + it("returns initial string if key is empty", function () + assert.equal("hello", strbitop.sxor("hello", "")); + end); + end); +end); |